composer.phar 2.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814
  1. #!/usr/bin/env php
  2. <?php
  3. /*
  4. * This file is part of Composer.
  5. *
  6. * (c) Nils Adermann <naderman@naderman.de>
  7. * Jordi Boggiano <j.boggiano@seld.be>
  8. *
  9. * For the full copyright and license information, please view
  10. * the license that is located at the bottom of this file.
  11. */
  12. // Avoid APC causing random fatal errors per https://github.com/composer/composer/issues/264
  13. if (extension_loaded('apc') && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.cache_by_default'), FILTER_VALIDATE_BOOLEAN)) {
  14. if (version_compare(phpversion('apc'), '3.0.12', '>=')) {
  15. ini_set('apc.cache_by_default', 0);
  16. } else {
  17. fwrite(STDERR, 'Warning: APC <= 3.0.12 may cause fatal errors when running composer commands.'.PHP_EOL);
  18. fwrite(STDERR, 'Update APC, or set apc.enable_cli or apc.cache_by_default to 0 in your php.ini.'.PHP_EOL);
  19. }
  20. }
  21. Phar::mapPhar('composer.phar');
  22. define('COMPOSER_DEV_WARNING_TIME', 1608392047);
  23. require 'phar://composer.phar/bin/composer';
  24. __HALT_COMPILER(); ?>
  25. M��������� ���composer.phar����+���src/Composer/Autoload/AutoloadGenerator.php×y��o�_×y��£�˹´������+���src/Composer/Autoload/ClassMapGenerator.phpî��o�_î��í¼šl´���������src/Composer/Cache.phpê��o�_ê��ø¿=9´������%���src/Composer/Command/AboutCommand.phpØ��o�_Ø��ö÷;‡´������'���src/Composer/Command/ArchiveCommand.phpÀ��o�_À��Á’ =´������$���src/Composer/Command/BaseCommand.phpG��o�_G��p›_ƒ´������.���src/Composer/Command/BaseDependencyCommand.php.��o�_.��¿­«´������1���src/Composer/Command/CheckPlatformReqsCommand.php|��o�_|��™�Lc´������*���src/Composer/Command/ClearCacheCommand.phpó��o�_ó��ˆ(*Ô´������&���src/Composer/Command/ConfigCommand.phpNU��o�_NU��ÅhÝV´������-���src/Composer/Command/CreateProjectCommand.phpÉB��o�_ÉB��4
  26. `ÿ´������'���src/Composer/Command/DependsCommand.phpñ��o�_ñ��kU‹{´������(���src/Composer/Command/DiagnoseCommand.phpEQ��o�_EQ���õ­´������,���src/Composer/Command/DumpAutoloadCommand.php±��o�_±��a#®´������$���src/Composer/Command/ExecCommand.php ��o�_ ��X?!“´������$���src/Composer/Command/FundCommand.phph ��o�_h ��!›´������&���src/Composer/Command/GlobalCommand.phpÊ ��o�_Ê ���œE´������$���src/Composer/Command/HomeCommand.php ��o�_ ��àÓ¬´������$���src/Composer/Command/InitCommand.phpÏU��o�_ÏU��ñê>N´������'���src/Composer/Command/InstallCommand.php)��o�_)��”dö´������(���src/Composer/Command/LicensesCommand.php[��o�_[��íŸ!U´������(���src/Composer/Command/OutdatedCommand.php´ ��o�_´ ��&zá'´������)���src/Composer/Command/ProhibitsCommand.php��o�_��_¤éS´������&���src/Composer/Command/RemoveCommand.php})��o�_})��¹ƒç´������'���src/Composer/Command/RequireCommand.phpà6��o�_à6��öRˆQ´������)���src/Composer/Command/RunScriptCommand.phpH��o�_H��,_¼Ë´������+���src/Composer/Command/ScriptAliasCommand.php¯��o�_¯��?=Ñ´������&���src/Composer/Command/SearchCommand.phpU ��o�_U ��…ß´������*���src/Composer/Command/SelfUpdateCommand.phpLC��o�_LC��AoI´������$���src/Composer/Command/ShowCommand.php‹��o�_‹��™'-´������&���src/Composer/Command/StatusCommand.phpò��o�_ò��Ð�ô°´������(���src/Composer/Command/SuggestsCommand.phpœ ��o�_œ ��Ö”´������&���src/Composer/Command/UpdateCommand.phpÍ1��o�_Í1��*ºÆ´������(���src/Composer/Command/ValidateCommand.phpM��o�_M��pwÓ’´���������src/Composer/Composer.phpI ��o�_I ��¶AÜQ´���������src/Composer/Config.php¾$��o�_¾$��zø¡9´������-���src/Composer/Config/ConfigSourceInterface.php��o�_��³ [/´������(���src/Composer/Config/JsonConfigSource.phpŒ��o�_Œ��NÏ„ñ´������$���src/Composer/Console/Application.php;��o�_;��Q×”@´������*���src/Composer/Console/GithubActionError.php`��o�_`��ï×y ´������,���src/Composer/Console/HtmlOutputFormatter.php3��o�_3��Ú�Eu´������-���src/Composer/DependencyResolver/Decisions.php<��o�_<��_$©´������1���src/Composer/DependencyResolver/DefaultPolicy.phpü��o�_ü��q-=´������/���src/Composer/DependencyResolver/GenericRule.php¢��o�_¢��|x¬_´������8���src/Composer/DependencyResolver/LocalRepoTransaction.php”��o�_”�� (o´������3���src/Composer/DependencyResolver/LockTransaction.php ��o�_ ��Ø(õ‰´������5���src/Composer/DependencyResolver/MultiConflictRule.php-��o�_-��´´š´������>���src/Composer/DependencyResolver/Operation/InstallOperation.php·��o�_·��#Ò­’´������I���src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.php��o�_��RØDå´������K���src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.php ��o�_ ��ÇA;Ú´������@���src/Composer/DependencyResolver/Operation/OperationInterface.phpÚ���o�_Ú���Qâè´������=���src/Composer/DependencyResolver/Operation/SolverOperation.phpF��o�_F�� ƒ‹s´������@���src/Composer/DependencyResolver/Operation/UninstallOperation.phpŸ��o�_Ÿ��o ±(´������=���src/Composer/DependencyResolver/Operation/UpdateOperation.phpG��o�_G��–ˆ
  27. ´������3���src/Composer/DependencyResolver/PolicyInterface.php6��o�_6��³m〴������(���src/Composer/DependencyResolver/Pool.php8��o�_8��ãW÷´������/���src/Composer/DependencyResolver/PoolBuilder.phpc0��o�_c0��(¥‚Ö´������+���src/Composer/DependencyResolver/Problem.php,6��o�_,6��­zúÜ´������+���src/Composer/DependencyResolver/Request.php��o�_��{·Ñ´������(���src/Composer/DependencyResolver/Rule.php­&��o�_­&��N£ÿÊ´������1���src/Composer/DependencyResolver/Rule2Literals.php��o�_��ª÷Ï´������+���src/Composer/DependencyResolver/RuleSet.phpt ��o�_t ��Cyoâ´������4���src/Composer/DependencyResolver/RuleSetGenerator.phpV��o�_V��^J §´������3���src/Composer/DependencyResolver/RuleSetIterator.php ��o�_ ��…gØ,´������2���src/Composer/DependencyResolver/RuleWatchChain.phpi��o�_i��hïš,´������2���src/Composer/DependencyResolver/RuleWatchGraph.php< ��o�_< ��š8¿z´������1���src/Composer/DependencyResolver/RuleWatchNode.php3��o�_3��š±aÖ´������*���src/Composer/DependencyResolver/Solver.php¾7��o�_¾7��P‘·Û´������6���src/Composer/DependencyResolver/SolverBugException.php™��o�_™��Xg6´������;���src/Composer/DependencyResolver/SolverProblemsException.phpÒ ��o�_Ò ��Íi¾T´������/���src/Composer/DependencyResolver/Transaction.php,��o�_,��
  28. N´������-���src/Composer/Downloader/ArchiveDownloader.php£ ��o�_£ ��&çâö´������1���src/Composer/Downloader/ChangeReportInterface.phpÌ���o�_Ì���¯à¨¿´������+���src/Composer/Downloader/DownloadManager.php;��o�_;��2q²P´������/���src/Composer/Downloader/DownloaderInterface.php��o�_��<ê ´������3���src/Composer/Downloader/DvcsDownloaderInterface.phpÑ���o�_Ñ���&Áœ¿´������*���src/Composer/Downloader/FileDownloader.phpƒ*��o�_ƒ*��,ê?´������/���src/Composer/Downloader/FilesystemException.php
  29. ��o�_
  30. ��.-‹´������,���src/Composer/Downloader/FossilDownloader.phpÖ ��o�_Ö ��À¯é´������)���src/Composer/Downloader/GitDownloader.php€<��o�_€<��=�>´������*���src/Composer/Downloader/GzipDownloader.phpy��o�_y��·Á�]´������(���src/Composer/Downloader/HgDownloader.php ��o�_ ��«£þ/´������8���src/Composer/Downloader/MaxFileSizeExceededException.phpi���o�_i���Öt~p´������*���src/Composer/Downloader/PathDownloader.phpÅ��o�_Å��¾\8h´������.���src/Composer/Downloader/PerforceDownloader.php��o�_��ܘ´������*���src/Composer/Downloader/PharDownloader.php(��o�_(��”=K´������)���src/Composer/Downloader/RarDownloader.php®��o�_®��]'ƒÇ´������)���src/Composer/Downloader/SvnDownloader.phpF��o�_F��ÊD‡´������)���src/Composer/Downloader/TarDownloader.php&��o�_&��C€—€´������.���src/Composer/Downloader/TransportException.php=��o�_=��ZÎÈÞ´������9���src/Composer/Downloader/VcsCapableDownloaderInterface.phpÔ���o�_Ô���`§ôö´������)���src/Composer/Downloader/VcsDownloader.phpA��o�_A��Nmm ´������(���src/Composer/Downloader/XzDownloader.phpç��o�_ç��x�3.´������)���src/Composer/Downloader/ZipDownloader.php«��o�_«��Õò´������&���src/Composer/EventDispatcher/Event.php ��o�_ ��±™jï´������0���src/Composer/EventDispatcher/EventDispatcher.php/.��o�_/.��KÜ€§´������9���src/Composer/EventDispatcher/EventSubscriberInterface.php©���o�_©���h·0´������9���src/Composer/EventDispatcher/ScriptExecutionException.phpv���o�_v���wZ8S´������9���src/Composer/Exception/IrrecoverableDownloadException.phpv���o�_v���DM½y´������)���src/Composer/Exception/NoSslException.phpf���o�_f���ËíM�´���������src/Composer/Factory.php×A��o�_×A��ƒê´���������src/Composer/IO/BaseIO.php��o�_��´ó|´���������src/Composer/IO/BufferIO.php·��o�_·�� i² ´���������src/Composer/IO/ConsoleIO.phpº��o�_º��'ü¤ø´���������src/Composer/IO/IOInterface.phpØ��o�_Ø��Fò°ð´���������src/Composer/IO/NullIO.phpÀ��o�_À��F`sÊ´������"���src/Composer/InstalledVersions.php- ��o�_- ��&“ò(´���������src/Composer/Installer.phps��o�_s��tÍ è´������*���src/Composer/Installer/BinaryInstaller.php
  31. ��o�_
  32. ��t¤{ø´������2���src/Composer/Installer/BinaryPresenceInterface.phpË���o�_Ë���À5š¨´������.���src/Composer/Installer/InstallationManager.phpD/��o�_D/��Ê»…´������)���src/Composer/Installer/InstallerEvent.phpŒ��o�_Œ��š´Úë´������*���src/Composer/Installer/InstallerEvents.php…���o�_…���nÜ<Á´������-���src/Composer/Installer/InstallerInterface.phpJ��o�_J��hK.U´������+���src/Composer/Installer/LibraryInstaller.phpi��o�_i��‰Á%è´������/���src/Composer/Installer/MetapackageInstaller.phpü��o�_ü��aNÕ‘´������(���src/Composer/Installer/NoopInstaller.php]��o�_]��Û‰öÓ´������'���src/Composer/Installer/PackageEvent.php��o�_��=Éд������(���src/Composer/Installer/PackageEvents.php¸��o�_¸��dbØs´������*���src/Composer/Installer/PluginInstaller.phpK
  33. ��o�_K
  34. ��´S‚´������+���src/Composer/Installer/ProjectInstaller.phpf��o�_f��ÙÇ“B´������4���src/Composer/Installer/SuggestedPackagesReporter.php��o�_��Vt–´���������src/Composer/Json/JsonFile.phpÿ��o�_ÿ��²†»Ò´������#���src/Composer/Json/JsonFormatter.php^��o�_^��‚£.î´������%���src/Composer/Json/JsonManipulator.php)5��o�_)5��"pà´������-���src/Composer/Json/JsonValidationException.php\��o�_\��.XóÜ´������%���src/Composer/Package/AliasPackage.php½��o�_½��Y÷ÿa´������7���src/Composer/Package/Archiver/ArchivableFilesFilter.php ��o�_ ��yY+¦´������7���src/Composer/Package/Archiver/ArchivableFilesFinder.phpÞ��o�_Þ�� ²²¹´������0���src/Composer/Package/Archiver/ArchiveManager.phpf��o�_f��‹ ½"´������3���src/Composer/Package/Archiver/ArchiverInterface.php��o�_��ñ´> ´������3���src/Composer/Package/Archiver/BaseExcludeFilter.php–��o�_–��y¶=Æ´������7���src/Composer/Package/Archiver/ComposerExcludeFilter.php��o�_��‹SZ0´������2���src/Composer/Package/Archiver/GitExcludeFilter.phpr��o�_r��3‘Mh´������1���src/Composer/Package/Archiver/HgExcludeFilter.php ��o�_ �� •¦S´������.���src/Composer/Package/Archiver/PharArchiver.php?��o�_?��®— u´������-���src/Composer/Package/Archiver/ZipArchiver.phpX��o�_X��¤k�~´������$���src/Composer/Package/BasePackage.php��o�_��Þ)’Ë´������*���src/Composer/Package/Comparer/Comparer.php½��o�_½��¡fK}´������(���src/Composer/Package/CompletePackage.php§��o�_§�� h“´������1���src/Composer/Package/CompletePackageInterface.php��o�_��2%ž´������+���src/Composer/Package/Dumper/ArrayDumper.php ��o�_ ��Ã@Q´���������src/Composer/Package/Link.phpÝ��o�_Ý��Ãðÿд������+���src/Composer/Package/Loader/ArrayLoader.phpã&��o�_ã&��ª>l´������7���src/Composer/Package/Loader/InvalidPackageException.phpE��o�_E��xb¾´������*���src/Composer/Package/Loader/JsonLoader.php°��o�_°��Vœ\‹´������/���src/Composer/Package/Loader/LoaderInterface.php²���o�_²���¦}úδ������1���src/Composer/Package/Loader/RootPackageLoader.phpr��o�_r�� Gý´������5���src/Composer/Package/Loader/ValidatingArrayLoader.php«A��o�_«A��çë‹á´���������src/Composer/Package/Locker.php#��o�_#��ðJ´������ ���src/Composer/Package/Package.php��o�_��¯°æg´������)���src/Composer/Package/PackageInterface.php� ��o�_� ��H^K_´������)���src/Composer/Package/RootAliasPackage.phpH ��o�_H ��ëie`´������$���src/Composer/Package/RootPackage.php��o�_��ŽÎ_´������-���src/Composer/Package/RootPackageInterface.php¹��o�_¹��"maV´������0���src/Composer/Package/Version/StabilityFilter.phpë��o�_ë���H ´������/���src/Composer/Package/Version/VersionGuesser.phpº$��o�_º$��ÐDJT´������.���src/Composer/Package/Version/VersionParser.phpý��o�_ý��4º�δ������0���src/Composer/Package/Version/VersionSelector.phpÝ��o�_Ý��3l`{´������&���src/Composer/Platform/HhvmDetector.phpð��o�_ð��Ë›ª´������!���src/Composer/Platform/Runtime.php@��o�_@��ª™ˆ`´������!���src/Composer/Platform/Version.php’��o�_’��wLão´������-���src/Composer/Plugin/Capability/Capability.phpW���o�_W���æ_¨1´������2���src/Composer/Plugin/Capability/CommandProvider.php—���o�_—���ûOâ>´���������src/Composer/Plugin/Capable.php���o�_���Æq+´������$���src/Composer/Plugin/CommandEvent.phpâ��o�_â��³ÆÇW´������$���src/Composer/Plugin/PluginEvents.phpe��o�_e��*U~r´������'���src/Composer/Plugin/PluginInterface.phpŽ��o�_Ž���4%~´������%���src/Composer/Plugin/PluginManager.php·,��o�_·,��¡°‚m´������-���src/Composer/Plugin/PostFileDownloadEvent.phpä��o�_ä��À¤}ý´������*���src/Composer/Plugin/PreCommandRunEvent.phpõ��o�_õ��:ðd´������,���src/Composer/Plugin/PreFileDownloadEvent.phpO��o�_O��¾­wÀ´������*���src/Composer/Plugin/PrePoolCreateEvent.phpu��o�_u��6sS„´������4���src/Composer/Question/StrictConfirmationQuestion.php��o�_��'.³è´������+���src/Composer/Repository/ArrayRepository.phpì��o�_ì��Œ†ó6´������.���src/Composer/Repository/ArtifactRepository.phpô ��o�_ô ��›©Ñn´������.���src/Composer/Repository/ComposerRepository.php­…��o�_­…��‡Ç<3´������/���src/Composer/Repository/CompositeRepository.phpO ��o�_O ��·P¯´������;���src/Composer/Repository/ConfigurableRepositoryInterface.php…���o�_…���±Ÿ_´������0���src/Composer/Repository/FilesystemRepository.phpz��o�_z��ë½Ê´������,���src/Composer/Repository/FilterRepository.php��o�_��×y¯¢´������4���src/Composer/Repository/InstalledArrayRepository.php3��o�_3��…¥)n´������9���src/Composer/Repository/InstalledFilesystemRepository.php1��o�_1��y&êÍ´������/���src/Composer/Repository/InstalledRepository.php��o�_��‡ù´M´������8���src/Composer/Repository/InstalledRepositoryInterface.php¥���o�_¥���Ã%´������6���src/Composer/Repository/InvalidRepositoryException.phpn���o�_n���à“똴������/���src/Composer/Repository/LockArrayRepository.php¥���o�_¥���524´������-���src/Composer/Repository/PackageRepository.phpÒ��o�_Ò��åÒd´������*���src/Composer/Repository/PathRepository.php%��o�_%��õœjš´������*���src/Composer/Repository/PearRepository.phpQ��o�_Q��cø´������.���src/Composer/Repository/PlatformRepository.php¡H��o�_¡H���¨Iÿ´������-���src/Composer/Repository/RepositoryFactory.php¦��o�_¦��Ÿ�&<´������/���src/Composer/Repository/RepositoryInterface.php;��o�_;�� _‹´������-���src/Composer/Repository/RepositoryManager.php ��o�_ ��´=x´������7���src/Composer/Repository/RepositorySecurityException.phpo���o�_o���pÕ«ª´������)���src/Composer/Repository/RepositorySet.phpÏ��o�_Ï��^ì È´������1���src/Composer/Repository/RootPackageRepository.php@��o�_@��X¦Ž´������/���src/Composer/Repository/Vcs/BitbucketDriver.phpŠ ��o�_Š ��Ä›ÊV´������,���src/Composer/Repository/Vcs/FossilDriver.phpl��o�_l��wàù ´������2���src/Composer/Repository/Vcs/GitBitbucketDriver.phpé��o�_é��jºãe´������)���src/Composer/Repository/Vcs/GitDriver.phpô��o�_ô��íI�`´������,���src/Composer/Repository/Vcs/GitHubDriver.phpü4��o�_ü4��¸Ðtå´������,���src/Composer/Repository/Vcs/GitLabDriver.php+��o�_+��´P•z´������1���src/Composer/Repository/Vcs/HgBitbucketDriver.phpã��o�_ã��¬}ñ´������(���src/Composer/Repository/Vcs/HgDriver.php��o�_��_8¬­´������.���src/Composer/Repository/Vcs/PerforceDriver.php¾ ��o�_¾ ��ˆáÀ´������)���src/Composer/Repository/Vcs/SvnDriver.php›��o�_›��†
  35. \�����)���src/Composer/Repository/Vcs/VcsDriver.phpz
  36. ��o�_z
  37. ��}ãh´������2���src/Composer/Repository/Vcs/VcsDriverInterface.php÷��o�_÷��ÇX[‰´������)���src/Composer/Repository/VcsRepository.php`2��o�_`2��twˆJ´������1���src/Composer/Repository/VersionCacheInterface.php”���o�_”���A?Rï´������3���src/Composer/Repository/WritableArrayRepository.phpm��o�_m��š11`´������7���src/Composer/Repository/WritableRepositoryInterface.phpé��o�_é��ïŸÒ¥´���������src/Composer/Script/Event.phpš��o�_š��Óô©´������$���src/Composer/Script/ScriptEvents.phpÜ��o�_Ü��ÆíÁ´������ ���src/Composer/SelfUpdate/Keys.php���o�_��� îÊN´������$���src/Composer/SelfUpdate/Versions.phpR��o�_R��Ï×8�´������ ���src/Composer/Util/AuthHelper.php€��o�_€��ðüŠ­´���������src/Composer/Util/Bitbucket.phpÞ��o�_Þ��¤½¸@´������$���src/Composer/Util/ComposerMirror.php±��o�_±��­½øØ´������%���src/Composer/Util/ConfigValidator.phpI��o�_I��š a´������"���src/Composer/Util/ErrorHandler.php»��o�_»��O›rk´������ ���src/Composer/Util/Filesystem.phpà2��o�_à2��µŒç´���������src/Composer/Util/Git.phpÁ0��o�_Á0��W¶ÂK´���������src/Composer/Util/GitHub.phpW ��o�_W ��–¹H´���������src/Composer/Util/GitLab.php’��o�_’��vu˜¼´���������src/Composer/Util/Hg.php¶��o�_¶��²?Ü´������)���src/Composer/Util/Http/CurlDownloader.php¸8��o�_¸8��¨ØûŠ´������#���src/Composer/Util/Http/Response.phph��o�_h��Ö^ÒÇ´������$���src/Composer/Util/HttpDownloader.phpÕ��o�_Õ��Ï�L´���������src/Composer/Util/IniHelper.phph��o�_h��;FP´���������src/Composer/Util/Loop.phpÀ��o�_À��ùÿKô������&���src/Composer/Util/MetadataMinifier.php¼��o�_¼��$Ž.w´������$���src/Composer/Util/NoProxyPattern.php|��o�_|��¸|ää´������#���src/Composer/Util/PackageSorter.phpð��o�_ð��9hÑ­´���������src/Composer/Util/Perforce.php^2��o�_^2��=´MÔ´���������src/Composer/Util/Platform.php��o�_��_ë3+´������%���src/Composer/Util/ProcessExecutor.php��o�_��Gs˜X´������&���src/Composer/Util/RemoteFilesystem.phpxM��o�_xM��0H®ê´���������src/Composer/Util/Silencer.phpé��o�_é��“Vjf´������*���src/Composer/Util/StreamContextFactory.phpz��o�_z��ÏEHt´���������src/Composer/Util/Svn.php)��o�_)��¬íGj´������ ���src/Composer/Util/SyncHelper.php;��o�_;��Ž(¸´���������src/Composer/Util/Tar.phpb��o�_b��å]–´���������src/Composer/Util/TlsHelper.phpL
  38. ��o�_L
  39. ��" i´���������src/Composer/Util/Url.php× ��o�_× ��;‘bÕ´���������src/Composer/Util/Zip.phpð��o�_ð��î’j•´���������src/bootstrap.php¹��o�_¹��I}œ´������%���src/Composer/Autoload/ClassLoader.php£4��o�_£4��?ÁT¨´������#���res/composer-repository-schema.jsonñ��o�_ñ��|0à„´���������res/composer-schema.json€ª��o�_€ª���ÅÇH´������6���vendor/composer/spdx-licenses/res/spdx-exceptions.json¸ ��o�_¸ ��Â4DC´������4���vendor/composer/spdx-licenses/res/spdx-licenses.jsoná£��o�_á£��Ú¼Ó´������4���vendor/symfony/console/Resources/bin/hiddeninput.exe�$��o�_�$��•�¥v´������&���vendor/symfony/console/Application.php=X��o�_=X��� S’´������*���vendor/symfony/console/Command/Command.phpî"��o�_î"��x°jÕ´������.���vendor/symfony/console/Command/HelpCommand.phpØ��o�_Ø��¦Ú-:´������.���vendor/symfony/console/Command/ListCommand.phpZ��o�_Z��»w`´������(���vendor/symfony/console/ConsoleEvents.phpé���o�_é���RÛÔe´������<���vendor/symfony/console/Descriptor/ApplicationDescription.phpÐ��o�_Ð��™Ž5°´������0���vendor/symfony/console/Descriptor/Descriptor.php���o�_���¿N•´������9���vendor/symfony/console/Descriptor/DescriptorInterface.phpü���o�_ü���±Qµ´������4���vendor/symfony/console/Descriptor/JsonDescriptor.phpÜ ��o�_Ü ��*û�É´������8���vendor/symfony/console/Descriptor/MarkdownDescriptor.php¶��o�_¶��·Ô;Ý´������4���vendor/symfony/console/Descriptor/TextDescriptor.php¼��o�_¼��òç$´������3���vendor/symfony/console/Descriptor/XmlDescriptor.php��o�_��b{<´������4���vendor/symfony/console/Event/ConsoleCommandEvent.php°��o�_°��!�È´������-���vendor/symfony/console/Event/ConsoleEvent.phpÅ��o�_Å��ÒxÛ\´������6���vendor/symfony/console/Event/ConsoleExceptionEvent.php��o�_��á2é´������6���vendor/symfony/console/Event/ConsoleTerminateEvent.phpz��o�_z��³,îL´������=���vendor/symfony/console/Exception/CommandNotFoundException.phpÔ��o�_Ô��È÷ L´������7���vendor/symfony/console/Exception/ExceptionInterface.phpf���o�_f���¡ABª´������=���vendor/symfony/console/Exception/InvalidArgumentException.php¦���o�_¦���Ö̽Z´������;���vendor/symfony/console/Exception/InvalidOptionException.php¦���o�_¦���Ë×H´������3���vendor/symfony/console/Exception/LogicException.php’���o�_’���ÍO\e´������5���vendor/symfony/console/Exception/RuntimeException.php–���o�_–���Ùí,6´������4���vendor/symfony/console/Formatter/OutputFormatter.php6��o�_6��?=¨´������=���vendor/symfony/console/Formatter/OutputFormatterInterface.phpŒ��o�_Œ��òññÀ´������9���vendor/symfony/console/Formatter/OutputFormatterStyle.phpF��o�_F��𦴴������B���vendor/symfony/console/Formatter/OutputFormatterStyleInterface.php„��o�_„��÷½G´������>���vendor/symfony/console/Formatter/OutputFormatterStyleStack.php@��o�_@��G¨ýU´������6���vendor/symfony/console/Helper/DebugFormatterHelper.phpy��o�_y��Ì8ÆÐ´������2���vendor/symfony/console/Helper/DescriptorHelper.phpw��o�_w��|¦C´������.���vendor/symfony/console/Helper/DialogHelper.php��o�_��¹ÜÃ_´������1���vendor/symfony/console/Helper/FormatterHelper.phpd��o�_d��§×,¸´������(���vendor/symfony/console/Helper/Helper.php«��o�_«��!�§—´������1���vendor/symfony/console/Helper/HelperInterface.phpå���o�_å���Š ´������+���vendor/symfony/console/Helper/HelperSet.phpÊ��o�_Ê��áÏW"´������2���vendor/symfony/console/Helper/InputAwareHelper.phpc��o�_c��Ìøƒ´������/���vendor/symfony/console/Helper/ProcessHelper.phpÓ ��o�_Ó ��©w‚R´������-���vendor/symfony/console/Helper/ProgressBar.phpl%��o�_l%�� díÛ´������0���vendor/symfony/console/Helper/ProgressHelper.php]��o�_]��ù»‰X´������3���vendor/symfony/console/Helper/ProgressIndicator.phpN��o�_N��ÿ§³l´������0���vendor/symfony/console/Helper/QuestionHelper.phpl��o�_l��Ntó´������7���vendor/symfony/console/Helper/SymfonyQuestionHelper.php–
  40. ��o�_–
  41. ��- Ø´������'���vendor/symfony/console/Helper/Table.phpÄ*��o�_Ä*��¾™ØT´������+���vendor/symfony/console/Helper/TableCell.php���o�_���åV^´������-���vendor/symfony/console/Helper/TableHelper.php ��o�_ ��›uô™´������0���vendor/symfony/console/Helper/TableSeparator.phpÊ���o�_Ê���az´������,���vendor/symfony/console/Helper/TableStyle.php
  42. ��o�_
  43. ��_ÍI"´������*���vendor/symfony/console/Input/ArgvInput.php��o�_��×ö†›´������+���vendor/symfony/console/Input/ArrayInput.php) ��o�_) ��¥ÑC´������&���vendor/symfony/console/Input/Input.php£ ��o�_£ ��f¡?´������.���vendor/symfony/console/Input/InputArgument.php��o�_��D £´������4���vendor/symfony/console/Input/InputAwareInterface.php˜���o�_˜���­O°´������0���vendor/symfony/console/Input/InputDefinition.php†��o�_†��¤U)¤´������/���vendor/symfony/console/Input/InputInterface.php£��o�_£��ÆBŒ'´������,���vendor/symfony/console/Input/InputOption.php ��o�_ ��\¢Ü=´������,���vendor/symfony/console/Input/StringInput.phpš��o�_š��žµ è´���������vendor/symfony/console/LICENSE)��o�_)��NUN½´������/���vendor/symfony/console/Logger/ConsoleLogger.php0 ��o�_0 ��…� ¸´������0���vendor/symfony/console/Output/BufferedOutput.php_��o�__��‹ >P´������/���vendor/symfony/console/Output/ConsoleOutput.php±��o�_±��nì!f´������8���vendor/symfony/console/Output/ConsoleOutputInterface.phpà���o�_à���‡†ÆÊ´������,���vendor/symfony/console/Output/NullOutput.phpÏ��o�_Ï��®˜‹Z´������(���vendor/symfony/console/Output/Output.php˜ ��o�_˜ ��0p´������1���vendor/symfony/console/Output/OutputInterface.php��o�_���ì&´������.���vendor/symfony/console/Output/StreamOutput.php���o�_���Ä’Oç´������2���vendor/symfony/console/Question/ChoiceQuestion.phpx
  44. ��o�_x
  45. ��W€!´������8���vendor/symfony/console/Question/ConfirmationQuestion.phpè��o�_è��/Ô�´������,���vendor/symfony/console/Question/Question.phpÎ ��o�_Î ��lF´������ ���vendor/symfony/console/Shell.phpæ��o�_æ��¼XÒA´������,���vendor/symfony/console/Style/OutputStyle.php\��o�_\��wפ´������/���vendor/symfony/console/Style/StyleInterface.phpÏ��o�_Ï��&nÅÑ´������-���vendor/symfony/console/Style/SymfonyStyle.phpä��o�_ä��­å (´������3���vendor/symfony/console/Tester/ApplicationTester.phpÏ��o�_Ï��sž9i´������/���vendor/symfony/console/Tester/CommandTester.phpª��o�_ª��¬K z´������(���vendor/symfony/debug/BufferingLogger.phpt��o�_t��=�hÜ´���������vendor/symfony/debug/Debug.php,��o�_,��Ë~Ž.´������)���vendor/symfony/debug/DebugClassLoader.phpµ��o�_µ��1rEÓ´������%���vendor/symfony/debug/ErrorHandler.phpH��o�_H��¹:D#´������9���vendor/symfony/debug/Exception/ClassNotFoundException.php–��o�_–��i‰æô´������8���vendor/symfony/debug/Exception/ContextErrorException.php˜��o�_˜��-
  46. d2´������1���vendor/symfony/debug/Exception/DummyException.php��o�_��®+Ãê´������6���vendor/symfony/debug/Exception/FatalErrorException.php��o�_��™Ä´������6���vendor/symfony/debug/Exception/FatalThrowableError.phpW��o�_W��?àèK´������3���vendor/symfony/debug/Exception/FlattenException.php¼��o�_¼�� ×´������7���vendor/symfony/debug/Exception/OutOfMemoryException.php~���o�_~���ë¨oâ´������=���vendor/symfony/debug/Exception/UndefinedFunctionException.phpš��o�_š���ñJÀ´������;���vendor/symfony/debug/Exception/UndefinedMethodException.php˜��o�_˜��nöêØ´������)���vendor/symfony/debug/ExceptionHandler.php)3��o�_)3���h5=´������I���vendor/symfony/debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.phpA��o�_A��Ϥ¹l´������E���vendor/symfony/debug/FatalErrorHandler/FatalErrorHandlerInterface.php��o�_��ĹBV´������M���vendor/symfony/debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.phpx��o�_x��~ò"´������K���vendor/symfony/debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.phpO��o�_O���ž¦*´���������vendor/symfony/debug/LICENSE)��o�_)��NUN½´������:���vendor/symfony/filesystem/Exception/ExceptionInterface.phpi���o�_i���$ ÿ›´������=���vendor/symfony/filesystem/Exception/FileNotFoundException.php¼��o�_¼��pí\¶´������3���vendor/symfony/filesystem/Exception/IOException.php‡��o�_‡��€ü#Ñ´������<���vendor/symfony/filesystem/Exception/IOExceptionInterface.php¦���o�_¦���jÙwM´������(���vendor/symfony/filesystem/Filesystem.phpc4��o�_c4��‹×@þ´������!���vendor/symfony/filesystem/LICENSE)��o�_)��NUN½´������)���vendor/symfony/filesystem/LockHandler.phpö��o�_ö��ŸZµ1´������1���vendor/symfony/finder/Adapter/AbstractAdapter.php\ ��o�_\ ��hˆB´������5���vendor/symfony/finder/Adapter/AbstractFindAdapter.php���o�_���HC€/´������2���vendor/symfony/finder/Adapter/AdapterInterface.php›��o�_›��Mþ´������0���vendor/symfony/finder/Adapter/BsdFindAdapter.php3��o�_3��75$·´������0���vendor/symfony/finder/Adapter/GnuFindAdapter.php��o�_��Ÿ`]´������,���vendor/symfony/finder/Adapter/PhpAdapter.phpô��o�_ô��Þdè;´������/���vendor/symfony/finder/Comparator/Comparator.php���o�_���¾üœµ´������3���vendor/symfony/finder/Comparator/DateComparator.php#��o�_#��°δ������5���vendor/symfony/finder/Comparator/NumberComparator.php|��o�_|��ITÇÍ´������9���vendor/symfony/finder/Exception/AccessDeniedException.php„���o�_„���½¾sœ´������;���vendor/symfony/finder/Exception/AdapterFailureException.php¬��o�_¬��wR´������6���vendor/symfony/finder/Exception/ExceptionInterface.php„���o�_„���Gz-´������A���vendor/symfony/finder/Exception/OperationNotPermitedException.php)��o�_)��x§e´������@���vendor/symfony/finder/Exception/ShellCommandFailureException.phpº��o�_º��˜þ˜´������/���vendor/symfony/finder/Expression/Expression.php��o�_��i¥:Å´������)���vendor/symfony/finder/Expression/Glob.phpf��o�_f��DÞcj´������*���vendor/symfony/finder/Expression/Regex.php��o�_��ü(ÃÏ´������3���vendor/symfony/finder/Expression/ValueInterface.phpÍ��o�_Í��\p4†´������ ���vendor/symfony/finder/Finder.phpc.��o�_c.��:ˆ5g´���������vendor/symfony/finder/Glob.phpL��o�_L��jÍ9×´������7���vendor/symfony/finder/Iterator/CustomFilterIterator.php]��o�_]��ÎoÅÆ´������:���vendor/symfony/finder/Iterator/DateRangeFilterIterator.phpx��o�_x��ôP´������;���vendor/symfony/finder/Iterator/DepthRangeFilterIterator.phpî��o�_î��üÍ�q´������A���vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.phpí��o�_í��nõH´������4���vendor/symfony/finder/Iterator/FilePathsIterator.php#��o�_#��G?T½´������9���vendor/symfony/finder/Iterator/FileTypeFilterIterator.phpZ��o�_Z��(&ø´������<���vendor/symfony/finder/Iterator/FilecontentFilterIterator.php5��o�_5��ší´������9���vendor/symfony/finder/Iterator/FilenameFilterIterator.phpr��o�_r��tu´������1���vendor/symfony/finder/Iterator/FilterIterator.phpÃ��o�_Ã��š+µÞ´������=���vendor/symfony/finder/Iterator/MultiplePcreFilterIterator.php-��o�_-��ºÎÒ_´������5���vendor/symfony/finder/Iterator/PathFilterIterator.phpÐ��o�_Ð��‚c´������=���vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php ��o�_ ��ë]í»´������:���vendor/symfony/finder/Iterator/SizeRangeFilterIterator.phpe��o�_e��Ÿ’áé´������3���vendor/symfony/finder/Iterator/SortableIterator.php+��o�_+��õÝË ´���������vendor/symfony/finder/LICENSE)��o�_)��NUN½´������'���vendor/symfony/finder/Shell/Command.php> ��o�_> ��_~u ´������%���vendor/symfony/finder/Shell/Shell.phpr��o�_r��þpN´������%���vendor/symfony/finder/SplFileInfo.php��o�_��þ�íù´������'���vendor/symfony/polyfill-ctype/Ctype.phpH ��o�_H ��³�ÕÝ´������%���vendor/symfony/polyfill-ctype/LICENSE)��o�_)��´`e0´������+���vendor/symfony/polyfill-ctype/bootstrap.phpä��o�_ä��—o£´������(���vendor/symfony/polyfill-mbstring/LICENSE)��o�_)��“\ª´������-���vendor/symfony/polyfill-mbstring/Mbstring.php€G��o�_€G��ɖз´������@���vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php÷T��o�_÷T��ß2ª?´������F���vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.phpã��o�_ã��öy_•´������@���vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.phpîU��o�_îU��`þ8Q´������.���vendor/symfony/polyfill-mbstring/bootstrap.php)��o�_)��p¼B´������7���vendor/symfony/process/Exception/ExceptionInterface.phpf���o�_f���]ö>T´������=���vendor/symfony/process/Exception/InvalidArgumentException.php¨���o�_¨���ÐÀ+_´������3���vendor/symfony/process/Exception/LogicException.php”���o�_”��� ³ãñ´������;���vendor/symfony/process/Exception/ProcessFailedException.phpx��o�_x��¨Ìzy´������=���vendor/symfony/process/Exception/ProcessTimedOutException.php��o�_��ï«´������5���vendor/symfony/process/Exception/RuntimeException.php˜���o�_˜���¢Ø:´������+���vendor/symfony/process/ExecutableFinder.php���o�_���ûus€´���������vendor/symfony/process/LICENSE)��o�_)��NUN½´������.���vendor/symfony/process/PhpExecutableFinder.phpÏ��o�_Ï��Î%h´������%���vendor/symfony/process/PhpProcess.phpü��o�_ü��‡jûü´������.���vendor/symfony/process/Pipes/AbstractPipes.php½��o�_½��憴������/���vendor/symfony/process/Pipes/PipesInterface.phpD��o�_D��vØî¡´������*���vendor/symfony/process/Pipes/UnixPipes.php>��o�_>��ª•ir´������-���vendor/symfony/process/Pipes/WindowsPipes.phpp ��o�_p ��âU~É´������"���vendor/symfony/process/Process.php·R��o�_·R��Š`Õ´������)���vendor/symfony/process/ProcessBuilder.phpâ
  47. ��o�_â
  48. ��†M¶´������'���vendor/symfony/process/ProcessUtils.phpQ��o�_Q��b-$m´���������vendor/seld/jsonlint/LICENSE"��o�_"��aƒsy´������@���vendor/seld/jsonlint/src/Seld/JsonLint/DuplicateKeyException.phpk��o�_k��Zù¶Ã´������5���vendor/seld/jsonlint/src/Seld/JsonLint/JsonParser.phpU2��o�_U2��ús.Æ´������0���vendor/seld/jsonlint/src/Seld/JsonLint/Lexer.php#��o�_#��Úá@,´������;���vendor/seld/jsonlint/src/Seld/JsonLint/ParsingException.php%��o�_%��`a„|´������4���vendor/seld/jsonlint/src/Seld/JsonLint/Undefined.php>���o�_>���ÿqŸŸ´������(���vendor/justinrainbow/json-schema/LICENSE ��o�_ ��ºç©´������.���vendor/justinrainbow/json-schema/demo/demo.phpñ��o�_ñ��fC´������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/BaseConstraint.php¡ ��o�_¡ ��†wÌl´������T���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/CollectionConstraint.php�
  49. ��o�_�
  50. ��ÍèÓ¯´������J���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Constraint.php§ ��o�_§ ��›VØ´������S���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ConstraintInterface.php¼��o�_¼��ÿ Qœ´������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/EnumConstraint.php]��o�_]��VŽU<´������G���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Factory.phpã ��o�_ã ��á0;´������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/FormatConstraint.php…��o�_…��“TœÚ´������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/NumberConstraint.php‡ ��o�_‡ ��ï›(´������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ObjectConstraint.phpÃ��o�_Ã��©Å¼x´������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/SchemaConstraint.php0 ��o�_0 ��×j´˜´������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/StringConstraint.php��o�_��¥wš‡´������X���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/LooseTypeCheck.phpa��o�_a�� qô������Y���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/StrictTypeCheck.php—��o�_—��4~¾ ´������\���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/TypeCheckInterface.php‰��o�_‰��“µ+j´������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeConstraint.php&��o�_&��4˜©T´������S���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/UndefinedConstraint.phpS"��o�_S"��¼¾õ:´������F���vendor/justinrainbow/json-schema/src/JsonSchema/Entity/JsonPointer.phpè��o�_è��{N–´������P���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ExceptionInterface.phpI���o�_I���%|°´������V���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidArgumentException.php•���o�_•���‹àG´������T���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidConfigException.phpl���o�_l���A!L×´������T���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSchemaException.phpl���o�_l���è2÷þ´������]���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSchemaMediaTypeException.phpu���o�_u���=hç´������W���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSourceUriException.phpw���o�_w���N-ò[´������S���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/JsonDecodingException.phpÞ��o�_Þ��\¸
  51. ´������W���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ResourceNotFoundException.phpo���o�_o���píÛù´������N���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/RuntimeException.php…���o�_…���%…—´������^���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/UnresolvableJsonPointerException.php€���o�_€���u-#1´������R���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/UriResolverException.phpj���o�_j���å>�´������Q���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ValidationException.phpf���o�_f���¬¤„þ´������K���vendor/justinrainbow/json-schema/src/JsonSchema/Iterator/ObjectIterator.phpþ��o�_þ��M�„õ´������;���vendor/justinrainbow/json-schema/src/JsonSchema/Rfc3339.php ��o�_ ��f4÷³´������A���vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.phpœ ��o�_œ ��åfO´������J���vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorageInterface.php��o�_��oŠ+}´������T���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/AbstractRetriever.phpá���o�_á���[þA�´������G���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/Curl.php¥��o�_¥��Ô§Lb´������R���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/FileGetContents.php%��o�_%��5" ´������R���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/PredefinedArray.php,��o�_,��1•5þ´������X���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/UriRetrieverInterface.php®���o�_®���ÿ‹Áå´������C���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriResolver.php ��o�_ ��£Ÿ)à´������D���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.phpF��o�_F��¨IaD´������H���vendor/justinrainbow/json-schema/src/JsonSchema/UriResolverInterface.phpƒ���o�_ƒ���J€´������I���vendor/justinrainbow/json-schema/src/JsonSchema/UriRetrieverInterface.php…���o�_…���íæe´������=���vendor/justinrainbow/json-schema/src/JsonSchema/Validator.phpv��o�_v��õÍg´������%���vendor/composer/spdx-licenses/LICENSE��o�_��Bhí´������2���vendor/composer/spdx-licenses/src/SpdxLicenses.phpH��o�_H��͉T´���������vendor/composer/semver/LICENSE��o�_��Bhí´������)���vendor/composer/semver/src/Comparator.php��o�_��^ÝŠ’´������/���vendor/composer/semver/src/CompilingMatcher.phpo��o�_o��Æ7L§´������/���vendor/composer/semver/src/Constraint/Bound.phpt��o�_t��ùÛœ´������4���vendor/composer/semver/src/Constraint/Constraint.phpj��o�_j��7k)´������=���vendor/composer/semver/src/Constraint/ConstraintInterface.php˜��o�_˜��œ?[´������<���vendor/composer/semver/src/Constraint/MatchAllConstraint.php§��o�_§��ÃÛé´������=���vendor/composer/semver/src/Constraint/MatchNoneConstraint.phpÁ��o�_Á��ê´ �´������9���vendor/composer/semver/src/Constraint/MultiConstraint.php!��o�_!��q)Åà´������'���vendor/composer/semver/src/Interval.phpè��o�_è�� È�Û´������(���vendor/composer/semver/src/Intervals.phpù+��o�_ù+��Íòc»´������%���vendor/composer/semver/src/Semver.phpü��o�_ü��`°e´������,���vendor/composer/semver/src/VersionParser.phpÊ+��o�_Ê+��7m´������!���vendor/composer/ca-bundle/LICENSE��o�_��*!^`´������*���vendor/composer/ca-bundle/src/CaBundle.phpR��o�_R��!Ã%�´������&���vendor/composer/xdebug-handler/LICENSE)��o�_)��#Ô;^´������0���vendor/composer/xdebug-handler/src/PhpConfig.php´��o�_´��*D’�´������.���vendor/composer/xdebug-handler/src/Process.phpp ��o�_p ��i,i‘´������-���vendor/composer/xdebug-handler/src/Status.php
  52. ��o�_
  53. ��$Ÿv-´������4���vendor/composer/xdebug-handler/src/XdebugHandler.php#��o�_#��ñ†B´���������vendor/psr/log/LICENSE=��o�_=��p±ŽO´������)���vendor/psr/log/Psr/Log/AbstractLogger.php;��o�_;��ñ>3[´������3���vendor/psr/log/Psr/Log/InvalidArgumentException.php`���o�_`��� ˆX1´������#���vendor/psr/log/Psr/Log/LogLevel.phpû���o�_û���jðñ8´������/���vendor/psr/log/Psr/Log/LoggerAwareInterface.php|���o�_|���$£ˆ´������+���vendor/psr/log/Psr/Log/LoggerAwareTrait.php§���o�_§���T½úB´������*���vendor/psr/log/Psr/Log/LoggerInterface.phpÈ��o�_È��šx´������&���vendor/psr/log/Psr/Log/LoggerTrait.phpk��o�_k��£}‰’´������%���vendor/psr/log/Psr/Log/NullLogger.php ���o�_ ���ÆDi¯´������)���vendor/psr/log/Psr/Log/Test/DummyTest.phpp���o�_p���δ������3���vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php ��o�_ ��$/Ò´������*���vendor/psr/log/Psr/Log/Test/TestLogger.php<��o�_<��þ(åI´���������vendor/react/promise/LICENSE%��o�_%��¦H˜U´������F���vendor/react/promise/src/React/Promise/CancellablePromiseInterface.php����o�_���� ƒ<�´������3���vendor/react/promise/src/React/Promise/Deferred.phpð ��o�_ð ��o(ퟴ������:���vendor/react/promise/src/React/Promise/DeferredPromise.phpÇ��o�_Ç��º`W´������;���vendor/react/promise/src/React/Promise/DeferredResolver.phpÃ��o�_Ã��7Ëu´������;���vendor/react/promise/src/React/Promise/FulfilledPromise.phpÍ��o�_Í��´–U´������6���vendor/react/promise/src/React/Promise/LazyPromise.php��o�_��Š»´������2���vendor/react/promise/src/React/Promise/Promise.php��o�_��º6Jµ´������;���vendor/react/promise/src/React/Promise/PromiseInterface.phpŸ���o�_Ÿ��� ½¨n´������<���vendor/react/promise/src/React/Promise/PromisorInterface.php\���o�_\���Wèêà´������:���vendor/react/promise/src/React/Promise/RejectedPromise.php¾��o�_¾��fC¿´������<���vendor/react/promise/src/React/Promise/ResolverInterface.php¼���o�_¼���û �O´������/���vendor/react/promise/src/React/Promise/Util.phpè���o�_è���Ëý$:´������/���vendor/react/promise/src/React/Promise/When.phpÇ��o�_Ç��¤o´������4���vendor/react/promise/src/React/Promise/functions.phpÒ ��o�_Ò ��š§Ë¥´������<���vendor/react/promise/src/React/Promise/functions_include.php\���o�_\���1…‰^´���������vendor/autoload.php‚���o�_‚���…´������'���vendor/composer/autoload_namespaces.php¢���o�_¢����R7c´������!���vendor/composer/autoload_psr4.php÷��o�_÷��Å*š´������%���vendor/composer/autoload_classmap.phpµ���o�_µ���x’ý»´������"���vendor/composer/autoload_files.phpŒ��o�_Œ��� ´������!���vendor/composer/autoload_real.phpG��o�_G��nÇWÊ´������#���vendor/composer/autoload_static.php¹ ��o�_¹ ��'ö鯴���������vendor/composer/installed.php© ��o�_© ��ÂÝY´������%���vendor/composer/InstalledVersions.phpÊ��o�_Ê��hT÷´���������vendor/composer/ClassLoader.php¶��o�_¶��ôJ1´������(���vendor/composer/ca-bundle/res/cacert.pemÜc�o�_Üc�9ç‹ù´������ ���bin/composer6��o�_6�� 9Øï´���������LICENSE.��o�_.�� Õ´������<?php
  54. namespace Composer\Autoload;
  55. use Composer\Config;
  56. use Composer\EventDispatcher\EventDispatcher;
  57. use Composer\Installer\InstallationManager;
  58. use Composer\IO\IOInterface;
  59. use Composer\Package\AliasPackage;
  60. use Composer\Package\PackageInterface;
  61. use Composer\Repository\InstalledRepositoryInterface;
  62. use Composer\Repository\PlatformRepository;
  63. use Composer\Semver\Constraint\Bound;
  64. use Composer\Semver\Constraint\MatchAllConstraint;
  65. use Composer\Util\Filesystem;
  66. use Composer\Script\ScriptEvents;
  67. use Composer\Util\PackageSorter;
  68. class AutoloadGenerator
  69. {
  70. private $eventDispatcher;
  71. private $io;
  72. private $devMode = false;
  73. private $classMapAuthoritative = false;
  74. private $apcu = false;
  75. private $apcuPrefix;
  76. private $runScripts = false;
  77. private $ignorePlatformReqs = false;
  78. public function __construct(EventDispatcher $eventDispatcher, IOInterface $io = null)
  79. {
  80. $this->eventDispatcher = $eventDispatcher;
  81. $this->io = $io;
  82. }
  83. public function setDevMode($devMode = true)
  84. {
  85. $this->devMode = (bool) $devMode;
  86. }
  87. public function setClassMapAuthoritative($classMapAuthoritative)
  88. {
  89. $this->classMapAuthoritative = (bool) $classMapAuthoritative;
  90. }
  91. public function setApcu($apcu, $apcuPrefix = null)
  92. {
  93. $this->apcu = (bool) $apcu;
  94. $this->apcuPrefix = $apcuPrefix !== null ? (string) $apcuPrefix : $apcuPrefix;
  95. }
  96. public function setRunScripts($runScripts = true)
  97. {
  98. $this->runScripts = (bool) $runScripts;
  99. }
  100. public function setIgnorePlatformRequirements($ignorePlatformReqs)
  101. {
  102. if (is_array($ignorePlatformReqs)) {
  103. $this->ignorePlatformReqs = array_filter($ignorePlatformReqs, function ($req) {
  104. return PlatformRepository::isPlatformPackage($req);
  105. });
  106. } else {
  107. $this->ignorePlatformReqs = (bool) $ignorePlatformReqs;
  108. }
  109. }
  110. public function dump(Config $config, InstalledRepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir, $scanPsrPackages = false, $suffix = '')
  111. {
  112. if ($this->classMapAuthoritative) {
  113. $scanPsrPackages = true;
  114. }
  115. if ($this->runScripts) {
  116. $this->eventDispatcher->dispatchScript(ScriptEvents::PRE_AUTOLOAD_DUMP, $this->devMode, array(), array(
  117. 'optimize' => (bool) $scanPsrPackages,
  118. ));
  119. }
  120. $filesystem = new Filesystem();
  121. $filesystem->ensureDirectoryExists($config->get('vendor-dir'));
  122. $basePath = $filesystem->normalizePath(realpath(realpath(getcwd())));
  123. $vendorPath = $filesystem->normalizePath(realpath(realpath($config->get('vendor-dir'))));
  124. $useGlobalIncludePath = (bool) $config->get('use-include-path');
  125. $prependAutoloader = $config->get('prepend-autoloader') === false ? 'false' : 'true';
  126. $targetDir = $vendorPath.'/'.$targetDir;
  127. $filesystem->ensureDirectoryExists($targetDir);
  128. $vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);
  129. $vendorPathCode52 = str_replace('__DIR__', 'dirname(__FILE__)', $vendorPathCode);
  130. $vendorPathToTargetDirCode = $filesystem->findShortestPathCode($vendorPath, realpath($targetDir), true);
  131. $appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, $basePath, true);
  132. $appBaseDirCode = str_replace('__DIR__', '$vendorDir', $appBaseDirCode);
  133. $namespacesFile = <<<EOF
  134. <?php
  135. // autoload_namespaces.php @generated by Composer
  136. \$vendorDir = $vendorPathCode52;
  137. \$baseDir = $appBaseDirCode;
  138. return array(
  139. EOF;
  140. $psr4File = <<<EOF
  141. <?php
  142. // autoload_psr4.php @generated by Composer
  143. \$vendorDir = $vendorPathCode52;
  144. \$baseDir = $appBaseDirCode;
  145. return array(
  146. EOF;
  147. $packageMap = $this->buildPackageMap($installationManager, $mainPackage, $localRepo->getCanonicalPackages());
  148. $autoloads = $this->parseAutoloads($packageMap, $mainPackage, $this->devMode === false);
  149. foreach ($autoloads['psr-0'] as $namespace => $paths) {
  150. $exportedPaths = array();
  151. foreach ($paths as $path) {
  152. $exportedPaths[] = $this->getPathCode($filesystem, $basePath, $vendorPath, $path);
  153. }
  154. $exportedPrefix = var_export($namespace, true);
  155. $namespacesFile .= " $exportedPrefix => ";
  156. $namespacesFile .= "array(".implode(', ', $exportedPaths)."),\n";
  157. }
  158. $namespacesFile .= ");\n";
  159. foreach ($autoloads['psr-4'] as $namespace => $paths) {
  160. $exportedPaths = array();
  161. foreach ($paths as $path) {
  162. $exportedPaths[] = $this->getPathCode($filesystem, $basePath, $vendorPath, $path);
  163. }
  164. $exportedPrefix = var_export($namespace, true);
  165. $psr4File .= " $exportedPrefix => ";
  166. $psr4File .= "array(".implode(', ', $exportedPaths)."),\n";
  167. }
  168. $psr4File .= ");\n";
  169. $classmapFile = <<<EOF
  170. <?php
  171. // autoload_classmap.php @generated by Composer
  172. \$vendorDir = $vendorPathCode52;
  173. \$baseDir = $appBaseDirCode;
  174. return array(
  175. EOF;
  176. $targetDirLoader = null;
  177. $mainAutoload = $mainPackage->getAutoload();
  178. if ($mainPackage->getTargetDir() && !empty($mainAutoload['psr-0'])) {
  179. $levels = substr_count($filesystem->normalizePath($mainPackage->getTargetDir()), '/') + 1;
  180. $prefixes = implode(', ', array_map(function ($prefix) {
  181. return var_export($prefix, true);
  182. }, array_keys($mainAutoload['psr-0'])));
  183. $baseDirFromTargetDirCode = $filesystem->findShortestPathCode($targetDir, $basePath, true);
  184. $targetDirLoader = <<<EOF
  185. public static function autoload(\$class)
  186. {
  187. \$dir = $baseDirFromTargetDirCode . '/';
  188. \$prefixes = array($prefixes);
  189. foreach (\$prefixes as \$prefix) {
  190. if (0 !== strpos(\$class, \$prefix)) {
  191. continue;
  192. }
  193. \$path = \$dir . implode('/', array_slice(explode('\\\\', \$class), $levels)).'.php';
  194. if (!\$path = stream_resolve_include_path(\$path)) {
  195. return false;
  196. }
  197. require \$path;
  198. return true;
  199. }
  200. }
  201. EOF;
  202. }
  203. $excluded = null;
  204. if (!empty($autoloads['exclude-from-classmap'])) {
  205. $excluded = '{(' . implode('|', $autoloads['exclude-from-classmap']) . ')}';
  206. }
  207. $classMap = array();
  208. $ambiguousClasses = array();
  209. $scannedFiles = array();
  210. foreach ($autoloads['classmap'] as $dir) {
  211. $classMap = $this->addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $excluded, null, null, $classMap, $ambiguousClasses, $scannedFiles);
  212. }
  213. if ($scanPsrPackages) {
  214. $namespacesToScan = array();
  215. foreach (array('psr-4', 'psr-0') as $psrType) {
  216. foreach ($autoloads[$psrType] as $namespace => $paths) {
  217. $namespacesToScan[$namespace][] = array('paths' => $paths, 'type' => $psrType);
  218. }
  219. }
  220. krsort($namespacesToScan);
  221. foreach ($namespacesToScan as $namespace => $groups) {
  222. foreach ($groups as $group) {
  223. foreach ($group['paths'] as $dir) {
  224. $dir = $filesystem->normalizePath($filesystem->isAbsolutePath($dir) ? $dir : $basePath.'/'.$dir);
  225. if (!is_dir($dir)) {
  226. continue;
  227. }
  228. $classMap = $this->addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $excluded, $namespace, $group['type'], $classMap, $ambiguousClasses, $scannedFiles);
  229. }
  230. }
  231. }
  232. }
  233. foreach ($ambiguousClasses as $className => $ambigiousPaths) {
  234. $cleanPath = str_replace(array('$vendorDir . \'', '$baseDir . \'', "',\n"), array($vendorPath, $basePath, ''), $classMap[$className]);
  235. $this->io->writeError(
  236. '<warning>Warning: Ambiguous class resolution, "'.$className.'"'.
  237. ' was found '. (count($ambigiousPaths) + 1) .'x: in "'.$cleanPath.'" and "'. implode('", "', $ambigiousPaths) .'", the first will be used.</warning>'
  238. );
  239. }
  240. $classMap['Composer\\InstalledVersions'] = "\$vendorDir . '/composer/InstalledVersions.php',\n";
  241. ksort($classMap);
  242. foreach ($classMap as $class => $code) {
  243. $classmapFile .= ' '.var_export($class, true).' => '.$code;
  244. }
  245. $classmapFile .= ");\n";
  246. if (!$suffix) {
  247. if (!$config->get('autoloader-suffix') && is_readable($vendorPath.'/autoload.php')) {
  248. $content = file_get_contents($vendorPath.'/autoload.php');
  249. if (preg_match('{ComposerAutoloaderInit([^:\s]+)::}', $content, $match)) {
  250. $suffix = $match[1];
  251. }
  252. }
  253. if (!$suffix) {
  254. $suffix = $config->get('autoloader-suffix') ?: md5(uniqid('', true));
  255. }
  256. }
  257. $filesystem->filePutContentsIfModified($targetDir.'/autoload_namespaces.php', $namespacesFile);
  258. $filesystem->filePutContentsIfModified($targetDir.'/autoload_psr4.php', $psr4File);
  259. $filesystem->filePutContentsIfModified($targetDir.'/autoload_classmap.php', $classmapFile);
  260. $includePathFilePath = $targetDir.'/include_paths.php';
  261. if ($includePathFileContents = $this->getIncludePathsFile($packageMap, $filesystem, $basePath, $vendorPath, $vendorPathCode52, $appBaseDirCode)) {
  262. $filesystem->filePutContentsIfModified($includePathFilePath, $includePathFileContents);
  263. } elseif (file_exists($includePathFilePath)) {
  264. unlink($includePathFilePath);
  265. }
  266. $includeFilesFilePath = $targetDir.'/autoload_files.php';
  267. if ($includeFilesFileContents = $this->getIncludeFilesFile($autoloads['files'], $filesystem, $basePath, $vendorPath, $vendorPathCode52, $appBaseDirCode)) {
  268. $filesystem->filePutContentsIfModified($includeFilesFilePath, $includeFilesFileContents);
  269. } elseif (file_exists($includeFilesFilePath)) {
  270. unlink($includeFilesFilePath);
  271. }
  272. $filesystem->filePutContentsIfModified($targetDir.'/autoload_static.php', $this->getStaticFile($suffix, $targetDir, $vendorPath, $basePath, $staticPhpVersion));
  273. $checkPlatform = $config->get('platform-check') && $this->ignorePlatformReqs !== true;
  274. $platformCheckContent = null;
  275. if ($checkPlatform) {
  276. $platformCheckContent = $this->getPlatformCheck($packageMap, $this->ignorePlatformReqs ?: array());
  277. if (null === $platformCheckContent) {
  278. $checkPlatform = false;
  279. }
  280. }
  281. if ($checkPlatform) {
  282. $filesystem->filePutContentsIfModified($targetDir.'/platform_check.php', $platformCheckContent);
  283. } elseif (file_exists($targetDir.'/platform_check.php')) {
  284. unlink($targetDir.'/platform_check.php');
  285. }
  286. $filesystem->filePutContentsIfModified($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix));
  287. $filesystem->filePutContentsIfModified($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion, $checkPlatform));
  288. $filesystem->safeCopy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
  289. $filesystem->safeCopy(__DIR__.'/../../../LICENSE', $targetDir.'/LICENSE');
  290. if ($this->runScripts) {
  291. $this->eventDispatcher->dispatchScript(ScriptEvents::POST_AUTOLOAD_DUMP, $this->devMode, array(), array(
  292. 'optimize' => (bool) $scanPsrPackages,
  293. ));
  294. }
  295. return count($classMap);
  296. }
  297. private function addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $excluded, $namespaceFilter, $autoloadType, array $classMap, array &$ambiguousClasses, array &$scannedFiles)
  298. {
  299. foreach ($this->generateClassMap($dir, $excluded, $namespaceFilter, $autoloadType, true, $scannedFiles) as $class => $path) {
  300. $pathCode = $this->getPathCode($filesystem, $basePath, $vendorPath, $path).",\n";
  301. if (!isset($classMap[$class])) {
  302. $classMap[$class] = $pathCode;
  303. } elseif ($this->io && $classMap[$class] !== $pathCode && !preg_match('{/(test|fixture|example|stub)s?/}i', strtr($classMap[$class].' '.$path, '\\', '/'))) {
  304. $ambiguousClasses[$class][] = $path;
  305. }
  306. }
  307. return $classMap;
  308. }
  309. private function generateClassMap($dir, $excluded, $namespaceFilter, $autoloadType, $showAmbiguousWarning, array &$scannedFiles)
  310. {
  311. return ClassMapGenerator::createMap($dir, $excluded, $showAmbiguousWarning ? $this->io : null, $namespaceFilter, $autoloadType, $scannedFiles);
  312. }
  313. public function buildPackageMap(InstallationManager $installationManager, PackageInterface $mainPackage, array $packages)
  314. {
  315. $packageMap = array(array($mainPackage, ''));
  316. foreach ($packages as $package) {
  317. if ($package instanceof AliasPackage) {
  318. continue;
  319. }
  320. $this->validatePackage($package);
  321. $packageMap[] = array(
  322. $package,
  323. $installationManager->getInstallPath($package),
  324. );
  325. }
  326. return $packageMap;
  327. }
  328. protected function validatePackage(PackageInterface $package)
  329. {
  330. $autoload = $package->getAutoload();
  331. if (!empty($autoload['psr-4']) && null !== $package->getTargetDir()) {
  332. $name = $package->getName();
  333. $package->getTargetDir();
  334. throw new \InvalidArgumentException("PSR-4 autoloading is incompatible with the target-dir property, remove the target-dir in package '$name'.");
  335. }
  336. if (!empty($autoload['psr-4'])) {
  337. foreach ($autoload['psr-4'] as $namespace => $dirs) {
  338. if ($namespace !== '' && '\\' !== substr($namespace, -1)) {
  339. throw new \InvalidArgumentException("psr-4 namespaces must end with a namespace separator, '$namespace' does not, use '$namespace\\'.");
  340. }
  341. }
  342. }
  343. }
  344. public function parseAutoloads(array $packageMap, PackageInterface $mainPackage, $filterOutRequireDevPackages = false)
  345. {
  346. $mainPackageMap = array_shift($packageMap);
  347. if ($filterOutRequireDevPackages) {
  348. $packageMap = $this->filterPackageMap($packageMap, $mainPackage);
  349. }
  350. $sortedPackageMap = $this->sortPackageMap($packageMap);
  351. $sortedPackageMap[] = $mainPackageMap;
  352. array_unshift($packageMap, $mainPackageMap);
  353. $psr0 = $this->parseAutoloadsType($packageMap, 'psr-0', $mainPackage);
  354. $psr4 = $this->parseAutoloadsType($packageMap, 'psr-4', $mainPackage);
  355. $classmap = $this->parseAutoloadsType(array_reverse($sortedPackageMap), 'classmap', $mainPackage);
  356. $files = $this->parseAutoloadsType($sortedPackageMap, 'files', $mainPackage);
  357. $exclude = $this->parseAutoloadsType($sortedPackageMap, 'exclude-from-classmap', $mainPackage);
  358. krsort($psr0);
  359. krsort($psr4);
  360. return array(
  361. 'psr-0' => $psr0,
  362. 'psr-4' => $psr4,
  363. 'classmap' => $classmap,
  364. 'files' => $files,
  365. 'exclude-from-classmap' => $exclude,
  366. );
  367. }
  368. public function createLoader(array $autoloads)
  369. {
  370. $loader = new ClassLoader();
  371. if (isset($autoloads['psr-0'])) {
  372. foreach ($autoloads['psr-0'] as $namespace => $path) {
  373. $loader->add($namespace, $path);
  374. }
  375. }
  376. if (isset($autoloads['psr-4'])) {
  377. foreach ($autoloads['psr-4'] as $namespace => $path) {
  378. $loader->addPsr4($namespace, $path);
  379. }
  380. }
  381. if (isset($autoloads['classmap'])) {
  382. $excluded = null;
  383. if (!empty($autoloads['exclude-from-classmap'])) {
  384. $excluded = '{(' . implode('|', $autoloads['exclude-from-classmap']) . ')}';
  385. }
  386. $scannedFiles = array();
  387. foreach ($autoloads['classmap'] as $dir) {
  388. try {
  389. $loader->addClassMap($this->generateClassMap($dir, $excluded, null, null, false, $scannedFiles));
  390. } catch (\RuntimeException $e) {
  391. $this->io->writeError('<warning>'.$e->getMessage().'</warning>');
  392. }
  393. }
  394. }
  395. return $loader;
  396. }
  397. protected function getIncludePathsFile(array $packageMap, Filesystem $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)
  398. {
  399. $includePaths = array();
  400. foreach ($packageMap as $item) {
  401. list($package, $installPath) = $item;
  402. if (null !== $package->getTargetDir() && strlen($package->getTargetDir()) > 0) {
  403. $installPath = substr($installPath, 0, -strlen('/'.$package->getTargetDir()));
  404. }
  405. foreach ($package->getIncludePaths() as $includePath) {
  406. $includePath = trim($includePath, '/');
  407. $includePaths[] = empty($installPath) ? $includePath : $installPath.'/'.$includePath;
  408. }
  409. }
  410. if (!$includePaths) {
  411. return;
  412. }
  413. $includePathsCode = '';
  414. foreach ($includePaths as $path) {
  415. $includePathsCode .= " " . $this->getPathCode($filesystem, $basePath, $vendorPath, $path) . ",\n";
  416. }
  417. return <<<EOF
  418. <?php
  419. // include_paths.php @generated by Composer
  420. \$vendorDir = $vendorPathCode;
  421. \$baseDir = $appBaseDirCode;
  422. return array(
  423. $includePathsCode);
  424. EOF;
  425. }
  426. protected function getIncludeFilesFile(array $files, Filesystem $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)
  427. {
  428. $filesCode = '';
  429. foreach ($files as $fileIdentifier => $functionFile) {
  430. $filesCode .= ' ' . var_export($fileIdentifier, true) . ' => '
  431. . $this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile) . ",\n";
  432. }
  433. if (!$filesCode) {
  434. return false;
  435. }
  436. return <<<EOF
  437. <?php
  438. // autoload_files.php @generated by Composer
  439. \$vendorDir = $vendorPathCode;
  440. \$baseDir = $appBaseDirCode;
  441. return array(
  442. $filesCode);
  443. EOF;
  444. }
  445. protected function getPathCode(Filesystem $filesystem, $basePath, $vendorPath, $path)
  446. {
  447. if (!$filesystem->isAbsolutePath($path)) {
  448. $path = $basePath . '/' . $path;
  449. }
  450. $path = $filesystem->normalizePath($path);
  451. $baseDir = '';
  452. if (strpos($path.'/', $vendorPath.'/') === 0) {
  453. $path = substr($path, strlen($vendorPath));
  454. $baseDir = '$vendorDir';
  455. if ($path !== false) {
  456. $baseDir .= " . ";
  457. }
  458. } else {
  459. $path = $filesystem->normalizePath($filesystem->findShortestPath($basePath, $path, true));
  460. if (!$filesystem->isAbsolutePath($path)) {
  461. $baseDir = '$baseDir . ';
  462. $path = '/' . $path;
  463. }
  464. }
  465. if (strpos($path, '.phar') !== false) {
  466. $baseDir = "'phar://' . " . $baseDir;
  467. }
  468. return $baseDir . (($path !== false) ? var_export($path, true) : "");
  469. }
  470. protected function getPlatformCheck($packageMap, array $ignorePlatformReqs)
  471. {
  472. $lowestPhpVersion = Bound::zero();
  473. $requiredExtensions = array();
  474. $extensionProviders = array();
  475. foreach ($packageMap as $item) {
  476. $package = $item[0];
  477. foreach (array_merge($package->getReplaces(), $package->getProvides()) as $link) {
  478. if (preg_match('{^ext-(.+)$}iD', $link->getTarget(), $match)) {
  479. $extensionProviders[$match[1]][] = $link->getConstraint() ?: new MatchAllConstraint();
  480. }
  481. }
  482. }
  483. foreach ($packageMap as $item) {
  484. $package = $item[0];
  485. foreach ($package->getRequires() as $link) {
  486. if (in_array($link->getTarget(), $ignorePlatformReqs, true)) {
  487. continue;
  488. }
  489. if ('php' === $link->getTarget() && ($constraint = $link->getConstraint())) {
  490. if ($constraint->getLowerBound()->compareTo($lowestPhpVersion, '>')) {
  491. $lowestPhpVersion = $constraint->getLowerBound();
  492. }
  493. }
  494. if (preg_match('{^ext-(.+)$}iD', $link->getTarget(), $match)) {
  495. if (isset($extensionProviders[$match[1]])) {
  496. foreach ($extensionProviders[$match[1]] as $provided) {
  497. if (!$link->getConstraint() || $provided->matches($link->getConstraint())) {
  498. continue 2;
  499. }
  500. }
  501. }
  502. if ($match[1] === 'zend-opcache') {
  503. $match[1] = 'zend opcache';
  504. }
  505. $extension = var_export($match[1], true);
  506. if ($match[1] === 'pcntl' || $match[1] === 'readline') {
  507. $requiredExtensions[$extension] = "PHP_SAPI !== 'cli' || extension_loaded($extension) || \$missingExtensions[] = $extension;\n";
  508. } else {
  509. $requiredExtensions[$extension] = "extension_loaded($extension) || \$missingExtensions[] = $extension;\n";
  510. }
  511. }
  512. }
  513. }
  514. ksort($requiredExtensions);
  515. $formatToPhpVersionId = function (Bound $bound) {
  516. if ($bound->isZero()) {
  517. return 0;
  518. }
  519. if ($bound->isPositiveInfinity()) {
  520. return 99999;
  521. }
  522. $version = str_replace('-', '.', $bound->getVersion());
  523. $chunks = array_map('intval', explode('.', $version));
  524. return $chunks[0] * 10000 + $chunks[1] * 100 + $chunks[2];
  525. };
  526. $formatToHumanReadable = function (Bound $bound) {
  527. if ($bound->isZero()) {
  528. return 0;
  529. }
  530. if ($bound->isPositiveInfinity()) {
  531. return 99999;
  532. }
  533. $version = str_replace('-', '.', $bound->getVersion());
  534. $chunks = explode('.', $version);
  535. $chunks = array_slice($chunks, 0, 3);
  536. return implode('.', $chunks);
  537. };
  538. $requiredPhp = '';
  539. $requiredPhpError = '';
  540. if (!$lowestPhpVersion->isZero()) {
  541. $operator = $lowestPhpVersion->isInclusive() ? '>=' : '>';
  542. $requiredPhp = 'PHP_VERSION_ID '.$operator.' '.$formatToPhpVersionId($lowestPhpVersion);
  543. $requiredPhpError = '"'.$operator.' '.$formatToHumanReadable($lowestPhpVersion).'"';
  544. }
  545. if ($requiredPhp) {
  546. $requiredPhp = <<<PHP_CHECK
  547. if (!($requiredPhp)) {
  548. \$issues[] = 'Your Composer dependencies require a PHP version $requiredPhpError. You are running ' . PHP_VERSION . '.';
  549. }
  550. PHP_CHECK;
  551. }
  552. $requiredExtensions = implode('', $requiredExtensions);
  553. if ('' !== $requiredExtensions) {
  554. $requiredExtensions = <<<EXT_CHECKS
  555. \$missingExtensions = array();
  556. $requiredExtensions
  557. if (\$missingExtensions) {
  558. \$issues[] = 'Your Composer dependencies require the following PHP extensions to be installed: ' . implode(', ', \$missingExtensions);
  559. }
  560. EXT_CHECKS;
  561. }
  562. if (!$requiredPhp && !$requiredExtensions) {
  563. return null;
  564. }
  565. return <<<PLATFORM_CHECK
  566. <?php
  567. // platform_check.php @generated by Composer
  568. \$issues = array();
  569. ${requiredPhp}${requiredExtensions}
  570. if (\$issues) {
  571. echo 'Composer detected issues in your platform:' . "\\n\\n" . implode("\\n", \$issues);
  572. exit(104);
  573. }
  574. PLATFORM_CHECK;
  575. }
  576. protected function getAutoloadFile($vendorPathToTargetDirCode, $suffix)
  577. {
  578. $lastChar = $vendorPathToTargetDirCode[strlen($vendorPathToTargetDirCode) - 1];
  579. if ("'" === $lastChar || '"' === $lastChar) {
  580. $vendorPathToTargetDirCode = substr($vendorPathToTargetDirCode, 0, -1).'/autoload_real.php'.$lastChar;
  581. } else {
  582. $vendorPathToTargetDirCode .= " . '/autoload_real.php'";
  583. }
  584. return <<<AUTOLOAD
  585. <?php
  586. // autoload.php @generated by Composer
  587. require_once $vendorPathToTargetDirCode;
  588. return ComposerAutoloaderInit$suffix::getLoader();
  589. AUTOLOAD;
  590. }
  591. protected function getAutoloadRealFile($useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion, $checkPlatform)
  592. {
  593. $file = <<<HEADER
  594. <?php
  595. // autoload_real.php @generated by Composer
  596. class ComposerAutoloaderInit$suffix
  597. {
  598. private static \$loader;
  599. public static function loadClassLoader(\$class)
  600. {
  601. if ('Composer\\Autoload\\ClassLoader' === \$class) {
  602. require __DIR__ . '/ClassLoader.php';
  603. }
  604. }
  605. /**
  606. * @return \Composer\Autoload\ClassLoader
  607. */
  608. public static function getLoader()
  609. {
  610. if (null !== self::\$loader) {
  611. return self::\$loader;
  612. }
  613. HEADER;
  614. if ($checkPlatform) {
  615. $file .= <<<'PLATFORM_CHECK'
  616. require __DIR__ . '/platform_check.php';
  617. PLATFORM_CHECK;
  618. }
  619. $file .= <<<CLASSLOADER_INIT
  620. spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'), true, $prependAutoloader);
  621. self::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader();
  622. spl_autoload_unregister(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'));
  623. CLASSLOADER_INIT;
  624. if ($useIncludePath) {
  625. $file .= <<<'INCLUDE_PATH'
  626. $includePaths = require __DIR__ . '/include_paths.php';
  627. $includePaths[] = get_include_path();
  628. set_include_path(implode(PATH_SEPARATOR, $includePaths));
  629. INCLUDE_PATH;
  630. }
  631. $file .= <<<STATIC_INIT
  632. \$useStaticLoader = PHP_VERSION_ID >= $staticPhpVersion && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
  633. if (\$useStaticLoader) {
  634. require __DIR__ . '/autoload_static.php';
  635. call_user_func(\Composer\Autoload\ComposerStaticInit$suffix::getInitializer(\$loader));
  636. } else {
  637. STATIC_INIT;
  638. if (!$this->classMapAuthoritative) {
  639. $file .= <<<'PSR04'
  640. $map = require __DIR__ . '/autoload_namespaces.php';
  641. foreach ($map as $namespace => $path) {
  642. $loader->set($namespace, $path);
  643. }
  644. $map = require __DIR__ . '/autoload_psr4.php';
  645. foreach ($map as $namespace => $path) {
  646. $loader->setPsr4($namespace, $path);
  647. }
  648. PSR04;
  649. }
  650. if ($useClassMap) {
  651. $file .= <<<'CLASSMAP'
  652. $classMap = require __DIR__ . '/autoload_classmap.php';
  653. if ($classMap) {
  654. $loader->addClassMap($classMap);
  655. }
  656. CLASSMAP;
  657. }
  658. $file .= " }\n\n";
  659. if ($this->classMapAuthoritative) {
  660. $file .= <<<'CLASSMAPAUTHORITATIVE'
  661. $loader->setClassMapAuthoritative(true);
  662. CLASSMAPAUTHORITATIVE;
  663. }
  664. if ($this->apcu) {
  665. $apcuPrefix = var_export(($this->apcuPrefix !== null ? $this->apcuPrefix : substr(base64_encode(md5(uniqid('', true), true)), 0, -3)), true);
  666. $file .= <<<APCU
  667. \$loader->setApcuPrefix($apcuPrefix);
  668. APCU;
  669. }
  670. if ($useGlobalIncludePath) {
  671. $file .= <<<'INCLUDEPATH'
  672. $loader->setUseIncludePath(true);
  673. INCLUDEPATH;
  674. }
  675. if ($targetDirLoader) {
  676. $file .= <<<REGISTER_TARGET_DIR_AUTOLOAD
  677. spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'autoload'), true, true);
  678. REGISTER_TARGET_DIR_AUTOLOAD;
  679. }
  680. $file .= <<<REGISTER_LOADER
  681. \$loader->register($prependAutoloader);
  682. REGISTER_LOADER;
  683. if ($useIncludeFiles) {
  684. $file .= <<<INCLUDE_FILES
  685. if (\$useStaticLoader) {
  686. \$includeFiles = Composer\Autoload\ComposerStaticInit$suffix::\$files;
  687. } else {
  688. \$includeFiles = require __DIR__ . '/autoload_files.php';
  689. }
  690. foreach (\$includeFiles as \$fileIdentifier => \$file) {
  691. composerRequire$suffix(\$fileIdentifier, \$file);
  692. }
  693. INCLUDE_FILES;
  694. }
  695. $file .= <<<METHOD_FOOTER
  696. return \$loader;
  697. }
  698. METHOD_FOOTER;
  699. $file .= $targetDirLoader;
  700. if ($useIncludeFiles) {
  701. return $file . <<<FOOTER
  702. }
  703. function composerRequire$suffix(\$fileIdentifier, \$file)
  704. {
  705. if (empty(\$GLOBALS['__composer_autoload_files'][\$fileIdentifier])) {
  706. require \$file;
  707. \$GLOBALS['__composer_autoload_files'][\$fileIdentifier] = true;
  708. }
  709. }
  710. FOOTER;
  711. }
  712. return $file . <<<FOOTER
  713. }
  714. FOOTER;
  715. }
  716. protected function getStaticFile($suffix, $targetDir, $vendorPath, $basePath, &$staticPhpVersion)
  717. {
  718. $staticPhpVersion = 50600;
  719. $file = <<<HEADER
  720. <?php
  721. // autoload_static.php @generated by Composer
  722. namespace Composer\Autoload;
  723. class ComposerStaticInit$suffix
  724. {
  725. HEADER;
  726. $loader = new ClassLoader();
  727. $map = require $targetDir . '/autoload_namespaces.php';
  728. foreach ($map as $namespace => $path) {
  729. $loader->set($namespace, $path);
  730. }
  731. $map = require $targetDir . '/autoload_psr4.php';
  732. foreach ($map as $namespace => $path) {
  733. $loader->setPsr4($namespace, $path);
  734. }
  735. $classMap = require $targetDir . '/autoload_classmap.php';
  736. if ($classMap) {
  737. $loader->addClassMap($classMap);
  738. }
  739. $filesystem = new Filesystem();
  740. $vendorPathCode = ' => ' . $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true, true) . " . '/";
  741. $vendorPharPathCode = ' => \'phar://\' . ' . $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true, true) . " . '/";
  742. $appBaseDirCode = ' => ' . $filesystem->findShortestPathCode(realpath($targetDir), $basePath, true, true) . " . '/";
  743. $appBaseDirPharCode = ' => \'phar://\' . ' . $filesystem->findShortestPathCode(realpath($targetDir), $basePath, true, true) . " . '/";
  744. $absoluteVendorPathCode = ' => ' . substr(var_export(rtrim($vendorDir, '\\/') . '/', true), 0, -1);
  745. $absoluteVendorPharPathCode = ' => ' . substr(var_export(rtrim('phar://' . $vendorDir, '\\/') . '/', true), 0, -1);
  746. $absoluteAppBaseDirCode = ' => ' . substr(var_export(rtrim($baseDir, '\\/') . '/', true), 0, -1);
  747. $absoluteAppBaseDirPharCode = ' => ' . substr(var_export(rtrim('phar://' . $baseDir, '\\/') . '/', true), 0, -1);
  748. $initializer = '';
  749. $prefix = "\0Composer\Autoload\ClassLoader\0";
  750. $prefixLen = strlen($prefix);
  751. if (file_exists($targetDir . '/autoload_files.php')) {
  752. $maps = array('files' => require $targetDir . '/autoload_files.php');
  753. } else {
  754. $maps = array();
  755. }
  756. foreach ((array) $loader as $prop => $value) {
  757. if ($value && 0 === strpos($prop, $prefix)) {
  758. $maps[substr($prop, $prefixLen)] = $value;
  759. }
  760. }
  761. foreach ($maps as $prop => $value) {
  762. if (count($value) > 32767) {
  763. $staticPhpVersion = 70000;
  764. }
  765. $value = strtr(
  766. var_export($value, true),
  767. array(
  768. $absoluteVendorPathCode => $vendorPathCode,
  769. $absoluteVendorPharPathCode => $vendorPharPathCode,
  770. $absoluteAppBaseDirCode => $appBaseDirCode,
  771. $absoluteAppBaseDirPharCode => $appBaseDirPharCode,
  772. )
  773. );
  774. $value = ltrim(preg_replace('/^ */m', ' $0$0', $value));
  775. $file .= sprintf(" public static $%s = %s;\n\n", $prop, $value);
  776. if ('files' !== $prop) {
  777. $initializer .= " \$loader->$prop = ComposerStaticInit$suffix::\$$prop;\n";
  778. }
  779. }
  780. return $file . <<<INITIALIZER
  781. public static function getInitializer(ClassLoader \$loader)
  782. {
  783. return \Closure::bind(function () use (\$loader) {
  784. $initializer
  785. }, null, ClassLoader::class);
  786. }
  787. }
  788. INITIALIZER;
  789. }
  790. protected function parseAutoloadsType(array $packageMap, $type, PackageInterface $mainPackage)
  791. {
  792. $autoloads = array();
  793. foreach ($packageMap as $item) {
  794. list($package, $installPath) = $item;
  795. $autoload = $package->getAutoload();
  796. if ($this->devMode && $package === $mainPackage) {
  797. $autoload = array_merge_recursive($autoload, $package->getDevAutoload());
  798. }
  799. if (!isset($autoload[$type]) || !is_array($autoload[$type])) {
  800. continue;
  801. }
  802. if (null !== $package->getTargetDir() && $package !== $mainPackage) {
  803. $installPath = substr($installPath, 0, -strlen('/'.$package->getTargetDir()));
  804. }
  805. foreach ($autoload[$type] as $namespace => $paths) {
  806. foreach ((array) $paths as $path) {
  807. if (($type === 'files' || $type === 'classmap' || $type === 'exclude-from-classmap') && $package->getTargetDir() && !is_readable($installPath.'/'.$path)) {
  808. if ($package === $mainPackage) {
  809. $targetDir = str_replace('\\<dirsep\\>', '[\\\\/]', preg_quote(str_replace(array('/', '\\'), '<dirsep>', $package->getTargetDir())));
  810. $path = ltrim(preg_replace('{^'.$targetDir.'}', '', ltrim($path, '\\/')), '\\/');
  811. } else {
  812. $path = $package->getTargetDir() . '/' . $path;
  813. }
  814. }
  815. if ($type === 'exclude-from-classmap') {
  816. $path = preg_replace('{/+}', '/', preg_quote(trim(strtr($path, '\\', '/'), '/')));
  817. $path = strtr($path, array('\\*\\*' => '.+?', '\\*' => '[^/]+?'));
  818. $updir = null;
  819. $path = preg_replace_callback(
  820. '{^((?:(?:\\\\\\.){1,2}+/)+)}',
  821. function ($matches) use (&$updir) {
  822. if (isset($matches[1])) {
  823. $updir = str_replace('\\.', '.', $matches[1]);
  824. }
  825. return '';
  826. },
  827. $path
  828. );
  829. if (empty($installPath)) {
  830. $installPath = strtr(getcwd(), '\\', '/');
  831. }
  832. $resolvedPath = realpath($installPath . '/' . $updir);
  833. $autoloads[] = preg_quote(strtr($resolvedPath, '\\', '/')) . '/' . $path . '($|/)';
  834. continue;
  835. }
  836. $relativePath = empty($installPath) ? (empty($path) ? '.' : $path) : $installPath.'/'.$path;
  837. if ($type === 'files') {
  838. $autoloads[$this->getFileIdentifier($package, $path)] = $relativePath;
  839. continue;
  840. }
  841. if ($type === 'classmap') {
  842. $autoloads[] = $relativePath;
  843. continue;
  844. }
  845. $autoloads[$namespace][] = $relativePath;
  846. }
  847. }
  848. }
  849. return $autoloads;
  850. }
  851. protected function getFileIdentifier(PackageInterface $package, $path)
  852. {
  853. return md5($package->getName() . ':' . $path);
  854. }
  855. protected function filterPackageMap(array $packageMap, PackageInterface $mainPackage)
  856. {
  857. $packages = array();
  858. $include = array();
  859. $replacedBy = array();
  860. foreach ($packageMap as $item) {
  861. $package = $item[0];
  862. $name = $package->getName();
  863. $packages[$name] = $package;
  864. foreach ($package->getReplaces() as $replace) {
  865. $replacedBy[$replace->getTarget()] = $name;
  866. }
  867. }
  868. $add = function (PackageInterface $package) use (&$add, $packages, &$include, $replacedBy) {
  869. foreach ($package->getRequires() as $link) {
  870. $target = $link->getTarget();
  871. if (isset($replacedBy[$target])) {
  872. $target = $replacedBy[$target];
  873. }
  874. if (!isset($include[$target])) {
  875. $include[$target] = true;
  876. if (isset($packages[$target])) {
  877. $add($packages[$target]);
  878. }
  879. }
  880. }
  881. };
  882. $add($mainPackage);
  883. return array_filter(
  884. $packageMap,
  885. function ($item) use ($include) {
  886. $package = $item[0];
  887. foreach ($package->getNames() as $name) {
  888. if (isset($include[$name])) {
  889. return true;
  890. }
  891. }
  892. return false;
  893. }
  894. );
  895. }
  896. protected function sortPackageMap(array $packageMap)
  897. {
  898. $packages = array();
  899. $paths = array();
  900. foreach ($packageMap as $item) {
  901. list($package, $path) = $item;
  902. $name = $package->getName();
  903. $packages[$name] = $package;
  904. $paths[$name] = $path;
  905. }
  906. $sortedPackages = PackageSorter::sortPackages($packages);
  907. $sortedPackageMap = array();
  908. foreach ($sortedPackages as $package) {
  909. $name = $package->getName();
  910. $sortedPackageMap[] = array($packages[$name], $paths[$name]);
  911. }
  912. return $sortedPackageMap;
  913. }
  914. }
  915. <?php
  916. namespace Composer\Autoload;
  917. use Symfony\Component\Finder\Finder;
  918. use Composer\IO\IOInterface;
  919. use Composer\Util\Filesystem;
  920. class ClassMapGenerator
  921. {
  922. public static function dump($dirs, $file)
  923. {
  924. $maps = array();
  925. foreach ($dirs as $dir) {
  926. $maps = array_merge($maps, static::createMap($dir));
  927. }
  928. file_put_contents($file, sprintf('<?php return %s;', var_export($maps, true)));
  929. }
  930. public static function createMap($path, $excluded = null, IOInterface $io = null, $namespace = null, $autoloadType = null, &$scannedFiles = array())
  931. {
  932. $basePath = $path;
  933. if (is_string($path)) {
  934. if (is_file($path)) {
  935. $path = array(new \SplFileInfo($path));
  936. } elseif (is_dir($path) || strpos($path, '*') !== false) {
  937. $path = Finder::create()->files()->followLinks()->name('/\.(php|inc|hh)$/')->in($path);
  938. } else {
  939. throw new \RuntimeException(
  940. 'Could not scan for classes inside "'.$path.
  941. '" which does not appear to be a file nor a folder'
  942. );
  943. }
  944. } elseif (null !== $autoloadType) {
  945. throw new \RuntimeException('Path must be a string when specifying an autoload type');
  946. }
  947. $map = array();
  948. $filesystem = new Filesystem();
  949. $cwd = realpath(getcwd());
  950. foreach ($path as $file) {
  951. $filePath = $file->getPathname();
  952. if (!in_array(pathinfo($filePath, PATHINFO_EXTENSION), array('php', 'inc', 'hh'))) {
  953. continue;
  954. }
  955. if (!$filesystem->isAbsolutePath($filePath)) {
  956. $filePath = $cwd . '/' . $filePath;
  957. $filePath = $filesystem->normalizePath($filePath);
  958. } else {
  959. $filePath = preg_replace('{[\\\\/]{2,}}', '/', $filePath);
  960. }
  961. $realPath = realpath($filePath);
  962. if (isset($scannedFiles[$realPath])) {
  963. continue;
  964. }
  965. if ($excluded && preg_match($excluded, strtr($realPath, '\\', '/'))) {
  966. continue;
  967. }
  968. if ($excluded && preg_match($excluded, strtr($filePath, '\\', '/'))) {
  969. continue;
  970. }
  971. $classes = self::findClasses($filePath);
  972. if (null !== $autoloadType) {
  973. $classes = self::filterByNamespace($classes, $filePath, $namespace, $autoloadType, $basePath, $io);
  974. if ($classes) {
  975. $scannedFiles[$realPath] = true;
  976. }
  977. } else {
  978. $scannedFiles[$realPath] = true;
  979. }
  980. foreach ($classes as $class) {
  981. if (null === $autoloadType && null !== $namespace && '' !== $namespace && 0 !== strpos($class, $namespace)) {
  982. continue;
  983. }
  984. if (!isset($map[$class])) {
  985. $map[$class] = $filePath;
  986. } elseif ($io && $map[$class] !== $filePath && !preg_match('{/(test|fixture|example|stub)s?/}i', strtr($map[$class].' '.$filePath, '\\', '/'))) {
  987. $io->writeError(
  988. '<warning>Warning: Ambiguous class resolution, "'.$class.'"'.
  989. ' was found in both "'.$map[$class].'" and "'.$filePath.'", the first will be used.</warning>'
  990. );
  991. }
  992. }
  993. }
  994. return $map;
  995. }
  996. private static function filterByNamespace($classes, $filePath, $baseNamespace, $namespaceType, $basePath, $io)
  997. {
  998. $validClasses = array();
  999. $rejectedClasses = array();
  1000. $realSubPath = substr($filePath, strlen($basePath) + 1);
  1001. $realSubPath = substr($realSubPath, 0, strrpos($realSubPath, '.'));
  1002. foreach ($classes as $class) {
  1003. if ('' !== $baseNamespace && 0 !== strpos($class, $baseNamespace)) {
  1004. continue;
  1005. }
  1006. if ('psr-0' === $namespaceType) {
  1007. $namespaceLength = strrpos($class, '\\');
  1008. if (false !== $namespaceLength) {
  1009. $namespace = substr($class, 0, $namespaceLength + 1);
  1010. $className = substr($class, $namespaceLength + 1);
  1011. $subPath = str_replace('\\', DIRECTORY_SEPARATOR, $namespace)
  1012. . str_replace('_', DIRECTORY_SEPARATOR, $className);
  1013. }
  1014. else {
  1015. $subPath = str_replace('_', DIRECTORY_SEPARATOR, $class);
  1016. }
  1017. } elseif ('psr-4' === $namespaceType) {
  1018. $subNamespace = ('' !== $baseNamespace) ? substr($class, strlen($baseNamespace)) : $class;
  1019. $subPath = str_replace('\\', DIRECTORY_SEPARATOR, $subNamespace);
  1020. } else {
  1021. throw new \RuntimeException("namespaceType must be psr-0 or psr-4, $namespaceType given");
  1022. }
  1023. if ($subPath === $realSubPath) {
  1024. $validClasses[] = $class;
  1025. } else {
  1026. $rejectedClasses[] = $class;
  1027. }
  1028. }
  1029. if (empty($validClasses)) {
  1030. foreach ($rejectedClasses as $class) {
  1031. if ($io) {
  1032. $io->writeError("<warning>Class $class located in ".preg_replace('{^'.preg_quote(getcwd()).'}', '.', $filePath, 1)." does not comply with $namespaceType autoloading standard. Skipping.</warning>");
  1033. }
  1034. }
  1035. return array();
  1036. }
  1037. return $validClasses;
  1038. }
  1039. private static function findClasses($path)
  1040. {
  1041. $extraTypes = PHP_VERSION_ID < 50400 ? '' : '|trait';
  1042. if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '3.3', '>=')) {
  1043. $extraTypes .= '|enum';
  1044. }
  1045. $contents = @php_strip_whitespace($path);
  1046. if (!$contents) {
  1047. if (!file_exists($path)) {
  1048. $message = 'File at "%s" does not exist, check your classmap definitions';
  1049. } elseif (!is_readable($path)) {
  1050. $message = 'File at "%s" is not readable, check its permissions';
  1051. } elseif ('' === trim(file_get_contents($path))) {
  1052. return array();
  1053. } else {
  1054. $message = 'File at "%s" could not be parsed as PHP, it may be binary or corrupted';
  1055. }
  1056. $error = error_get_last();
  1057. if (isset($error['message'])) {
  1058. $message .= PHP_EOL . 'The following message may be helpful:' . PHP_EOL . $error['message'];
  1059. }
  1060. throw new \RuntimeException(sprintf($message, $path));
  1061. }
  1062. if (!preg_match('{\b(?:class|interface'.$extraTypes.')\s}i', $contents)) {
  1063. return array();
  1064. }
  1065. $contents = preg_replace('{<<<[ \t]*([\'"]?)(\w+)\\1(?:\r\n|\n|\r)(?:.*?)(?:\r\n|\n|\r)(?:\s*)\\2(?=\s+|[;,.)])}s', 'null', $contents);
  1066. $contents = preg_replace('{"[^"\\\\]*+(\\\\.[^"\\\\]*+)*+"|\'[^\'\\\\]*+(\\\\.[^\'\\\\]*+)*+\'}s', 'null', $contents);
  1067. if (strpos($contents, '<?') !== 0) {
  1068. $contents = preg_replace('{^.+?<\?}s', '<?', $contents, 1, $replacements);
  1069. if ($replacements === 0) {
  1070. return array();
  1071. }
  1072. }
  1073. $contents = preg_replace('{\?>(?:[^<]++|<(?!\?))*+<\?}s', '?><?', $contents);
  1074. $pos = strrpos($contents, '?>');
  1075. if (false !== $pos && false === strpos(substr($contents, $pos), '<?')) {
  1076. $contents = substr($contents, 0, $pos);
  1077. }
  1078. if (preg_match('{(<\?)(?!(php|hh))}i', $contents)) {
  1079. $contents = preg_replace('{//.* | /\*(?:[^*]++|\*(?!/))*\*/}x', '', $contents);
  1080. }
  1081. preg_match_all('{
  1082. (?:
  1083. \b(?<![\$:>])(?P<type>class|interface'.$extraTypes.') \s++ (?P<name>[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:\-]*+)
  1084. | \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*+ [\{;]
  1085. )
  1086. }ix', $contents, $matches);
  1087. $classes = array();
  1088. $namespace = '';
  1089. for ($i = 0, $len = count($matches['type']); $i < $len; $i++) {
  1090. if (!empty($matches['ns'][$i])) {
  1091. $namespace = str_replace(array(' ', "\t", "\r", "\n"), '', $matches['nsname'][$i]) . '\\';
  1092. } else {
  1093. $name = $matches['name'][$i];
  1094. if ($name === 'extends' || $name === 'implements') {
  1095. continue;
  1096. }
  1097. if ($name[0] === ':') {
  1098. $name = 'xhp'.substr(str_replace(array('-', ':'), array('_', '__'), $name), 1);
  1099. } elseif ($matches['type'][$i] === 'enum') {
  1100. $name = rtrim($name, ':');
  1101. }
  1102. $classes[] = ltrim($namespace . $name, '\\');
  1103. }
  1104. }
  1105. return $classes;
  1106. }
  1107. }
  1108. <?php
  1109. namespace Composer;
  1110. use Composer\IO\IOInterface;
  1111. use Composer\Util\Filesystem;
  1112. use Composer\Util\Silencer;
  1113. use Symfony\Component\Finder\Finder;
  1114. class Cache
  1115. {
  1116. private static $cacheCollected = false;
  1117. private $io;
  1118. private $root;
  1119. private $enabled = true;
  1120. private $allowlist;
  1121. private $filesystem;
  1122. private $readOnly;
  1123. public function __construct(IOInterface $io, $cacheDir, $allowlist = 'a-z0-9.', Filesystem $filesystem = null, $readOnly = false)
  1124. {
  1125. $this->io = $io;
  1126. $this->root = rtrim($cacheDir, '/\\') . '/';
  1127. $this->allowlist = $allowlist;
  1128. $this->filesystem = $filesystem ?: new Filesystem();
  1129. $this->readOnly = (bool) $readOnly;
  1130. if (!self::isUsable($cacheDir)) {
  1131. $this->enabled = false;
  1132. return;
  1133. }
  1134. if (
  1135. (!is_dir($this->root) && !Silencer::call('mkdir', $this->root, 0777, true))
  1136. || !is_writable($this->root)
  1137. ) {
  1138. $this->io->writeError('<warning>Cannot create cache directory ' . $this->root . ', or directory is not writable. Proceeding without cache</warning>');
  1139. $this->enabled = false;
  1140. }
  1141. }
  1142. public function setReadOnly($readOnly)
  1143. {
  1144. $this->readOnly = (bool) $readOnly;
  1145. }
  1146. public function isReadOnly()
  1147. {
  1148. return $this->readOnly;
  1149. }
  1150. public static function isUsable($path)
  1151. {
  1152. return !preg_match('{(^|[\\\\/])(\$null|nul|NUL|/dev/null)([\\\\/]|$)}', $path);
  1153. }
  1154. public function isEnabled()
  1155. {
  1156. return $this->enabled;
  1157. }
  1158. public function getRoot()
  1159. {
  1160. return $this->root;
  1161. }
  1162. public function read($file)
  1163. {
  1164. if ($this->enabled) {
  1165. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1166. if (file_exists($this->root . $file)) {
  1167. $this->io->writeError('Reading '.$this->root . $file.' from cache', true, IOInterface::DEBUG);
  1168. return file_get_contents($this->root . $file);
  1169. }
  1170. }
  1171. return false;
  1172. }
  1173. public function write($file, $contents)
  1174. {
  1175. if ($this->enabled && !$this->readOnly) {
  1176. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1177. $this->io->writeError('Writing '.$this->root . $file.' into cache', true, IOInterface::DEBUG);
  1178. try {
  1179. return file_put_contents($this->root . $file, $contents);
  1180. } catch (\ErrorException $e) {
  1181. $this->io->writeError('<warning>Failed to write into cache: '.$e->getMessage().'</warning>', true, IOInterface::DEBUG);
  1182. if (preg_match('{^file_put_contents\(\): Only ([0-9]+) of ([0-9]+) bytes written}', $e->getMessage(), $m)) {
  1183. unlink($this->root . $file);
  1184. $message = sprintf(
  1185. '<warning>Writing %1$s into cache failed after %2$u of %3$u bytes written, only %4$u bytes of free space available</warning>',
  1186. $this->root . $file,
  1187. $m[1],
  1188. $m[2],
  1189. @disk_free_space($this->root . dirname($file))
  1190. );
  1191. $this->io->writeError($message);
  1192. return false;
  1193. }
  1194. throw $e;
  1195. }
  1196. }
  1197. return false;
  1198. }
  1199. public function copyFrom($file, $source)
  1200. {
  1201. if ($this->enabled && !$this->readOnly) {
  1202. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1203. $this->filesystem->ensureDirectoryExists(dirname($this->root . $file));
  1204. if (!file_exists($source)) {
  1205. $this->io->writeError('<error>'.$source.' does not exist, can not write into cache</error>');
  1206. } elseif ($this->io->isDebug()) {
  1207. $this->io->writeError('Writing '.$this->root . $file.' into cache from '.$source);
  1208. }
  1209. return copy($source, $this->root . $file);
  1210. }
  1211. return false;
  1212. }
  1213. public function copyTo($file, $target)
  1214. {
  1215. if ($this->enabled) {
  1216. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1217. if (file_exists($this->root . $file)) {
  1218. try {
  1219. touch($this->root . $file, filemtime($this->root . $file), time());
  1220. } catch (\ErrorException $e) {
  1221. Silencer::call('touch', $this->root . $file);
  1222. }
  1223. $this->io->writeError('Reading '.$this->root . $file.' from cache', true, IOInterface::DEBUG);
  1224. return copy($this->root . $file, $target);
  1225. }
  1226. }
  1227. return false;
  1228. }
  1229. public function gcIsNecessary()
  1230. {
  1231. return (!self::$cacheCollected && !mt_rand(0, 50));
  1232. }
  1233. public function remove($file)
  1234. {
  1235. if ($this->enabled) {
  1236. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1237. if (file_exists($this->root . $file)) {
  1238. return $this->filesystem->unlink($this->root . $file);
  1239. }
  1240. }
  1241. return false;
  1242. }
  1243. public function clear()
  1244. {
  1245. if ($this->enabled) {
  1246. $this->filesystem->emptyDirectory($this->root);
  1247. return true;
  1248. }
  1249. return false;
  1250. }
  1251. public function gc($ttl, $maxSize)
  1252. {
  1253. if ($this->enabled) {
  1254. $expire = new \DateTime();
  1255. $expire->modify('-'.$ttl.' seconds');
  1256. $finder = $this->getFinder()->date('until '.$expire->format('Y-m-d H:i:s'));
  1257. foreach ($finder as $file) {
  1258. $this->filesystem->unlink($file->getPathname());
  1259. }
  1260. $totalSize = $this->filesystem->size($this->root);
  1261. if ($totalSize > $maxSize) {
  1262. $iterator = $this->getFinder()->sortByAccessedTime()->getIterator();
  1263. while ($totalSize > $maxSize && $iterator->valid()) {
  1264. $filepath = $iterator->current()->getPathname();
  1265. $totalSize -= $this->filesystem->size($filepath);
  1266. $this->filesystem->unlink($filepath);
  1267. $iterator->next();
  1268. }
  1269. }
  1270. self::$cacheCollected = true;
  1271. return true;
  1272. }
  1273. return false;
  1274. }
  1275. public function sha1($file)
  1276. {
  1277. if ($this->enabled) {
  1278. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1279. if (file_exists($this->root . $file)) {
  1280. return sha1_file($this->root . $file);
  1281. }
  1282. }
  1283. return false;
  1284. }
  1285. public function sha256($file)
  1286. {
  1287. if ($this->enabled) {
  1288. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1289. if (file_exists($this->root . $file)) {
  1290. return hash_file('sha256', $this->root . $file);
  1291. }
  1292. }
  1293. return false;
  1294. }
  1295. protected function getFinder()
  1296. {
  1297. return Finder::create()->in($this->root)->files();
  1298. }
  1299. }
  1300. <?php
  1301. namespace Composer\Command;
  1302. use Symfony\Component\Console\Input\InputInterface;
  1303. use Symfony\Component\Console\Output\OutputInterface;
  1304. class AboutCommand extends BaseCommand
  1305. {
  1306. protected function configure()
  1307. {
  1308. $this
  1309. ->setName('about')
  1310. ->setDescription('Shows the short information about Composer.')
  1311. ->setHelp(
  1312. <<<EOT
  1313. <info>php composer.phar about</info>
  1314. EOT
  1315. )
  1316. ;
  1317. }
  1318. protected function execute(InputInterface $input, OutputInterface $output)
  1319. {
  1320. $this->getIO()->write(
  1321. <<<EOT
  1322. <info>Composer - Dependency Manager for PHP</info>
  1323. <comment>Composer is a dependency manager tracking local dependencies of your projects and libraries.
  1324. See https://getcomposer.org/ for more information.</comment>
  1325. EOT
  1326. );
  1327. return 0;
  1328. }
  1329. }
  1330. <?php
  1331. namespace Composer\Command;
  1332. use Composer\Factory;
  1333. use Composer\IO\IOInterface;
  1334. use Composer\Config;
  1335. use Composer\Composer;
  1336. use Composer\Repository\CompositeRepository;
  1337. use Composer\Repository\RepositoryFactory;
  1338. use Composer\Script\ScriptEvents;
  1339. use Composer\Plugin\CommandEvent;
  1340. use Composer\Plugin\PluginEvents;
  1341. use Composer\Util\Filesystem;
  1342. use Composer\Util\Loop;
  1343. use Composer\Util\ProcessExecutor;
  1344. use Symfony\Component\Console\Input\InputArgument;
  1345. use Symfony\Component\Console\Input\InputInterface;
  1346. use Symfony\Component\Console\Input\InputOption;
  1347. use Symfony\Component\Console\Output\OutputInterface;
  1348. class ArchiveCommand extends BaseCommand
  1349. {
  1350. protected function configure()
  1351. {
  1352. $this
  1353. ->setName('archive')
  1354. ->setDescription('Creates an archive of this composer package.')
  1355. ->setDefinition(array(
  1356. new InputArgument('package', InputArgument::OPTIONAL, 'The package to archive instead of the current project'),
  1357. new InputArgument('version', InputArgument::OPTIONAL, 'A version constraint to find the package to archive'),
  1358. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the resulting archive: tar or zip'),
  1359. new InputOption('dir', null, InputOption::VALUE_REQUIRED, 'Write the archive to this directory'),
  1360. new InputOption('file', null, InputOption::VALUE_REQUIRED, 'Write the archive with the given file name.'
  1361. .' Note that the format will be appended.'),
  1362. new InputOption('ignore-filters', false, InputOption::VALUE_NONE, 'Ignore filters when saving package'),
  1363. ))
  1364. ->setHelp(
  1365. <<<EOT
  1366. The <info>archive</info> command creates an archive of the specified format
  1367. containing the files and directories of the Composer project or the specified
  1368. package in the specified version and writes it to the specified directory.
  1369. <info>php composer.phar archive [--format=zip] [--dir=/foo] [package [version]]</info>
  1370. Read more at https://getcomposer.org/doc/03-cli.md#archive
  1371. EOT
  1372. )
  1373. ;
  1374. }
  1375. protected function execute(InputInterface $input, OutputInterface $output)
  1376. {
  1377. $composer = $this->getComposer(false);
  1378. $config = null;
  1379. if ($composer) {
  1380. $config = $composer->getConfig();
  1381. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'archive', $input, $output);
  1382. $eventDispatcher = $composer->getEventDispatcher();
  1383. $eventDispatcher->dispatch($commandEvent->getName(), $commandEvent);
  1384. $eventDispatcher->dispatchScript(ScriptEvents::PRE_ARCHIVE_CMD);
  1385. }
  1386. if (!$config) {
  1387. $config = Factory::createConfig();
  1388. }
  1389. if (null === $input->getOption('format')) {
  1390. $input->setOption('format', $config->get('archive-format'));
  1391. }
  1392. if (null === $input->getOption('dir')) {
  1393. $input->setOption('dir', $config->get('archive-dir'));
  1394. }
  1395. $returnCode = $this->archive(
  1396. $this->getIO(),
  1397. $config,
  1398. $input->getArgument('package'),
  1399. $input->getArgument('version'),
  1400. $input->getOption('format'),
  1401. $input->getOption('dir'),
  1402. $input->getOption('file'),
  1403. $input->getOption('ignore-filters'),
  1404. $composer
  1405. );
  1406. if (0 === $returnCode && $composer) {
  1407. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ARCHIVE_CMD);
  1408. }
  1409. return $returnCode;
  1410. }
  1411. protected function archive(IOInterface $io, Config $config, $packageName = null, $version = null, $format = 'tar', $dest = '.', $fileName = null, $ignoreFilters = false, Composer $composer = null)
  1412. {
  1413. if ($composer) {
  1414. $archiveManager = $composer->getArchiveManager();
  1415. } else {
  1416. $factory = new Factory;
  1417. $process = new ProcessExecutor();
  1418. $httpDownloader = Factory::createHttpDownloader($io, $config);
  1419. $downloadManager = $factory->createDownloadManager($io, $config, $httpDownloader, $process);
  1420. $archiveManager = $factory->createArchiveManager($config, $downloadManager, new Loop($httpDownloader, $process));
  1421. }
  1422. if ($packageName) {
  1423. $package = $this->selectPackage($io, $packageName, $version);
  1424. if (!$package) {
  1425. return 1;
  1426. }
  1427. } else {
  1428. $package = $this->getComposer()->getPackage();
  1429. }
  1430. $io->writeError('<info>Creating the archive into "'.$dest.'".</info>');
  1431. $packagePath = $archiveManager->archive($package, $format, $dest, $fileName, $ignoreFilters);
  1432. $fs = new Filesystem;
  1433. $shortPath = $fs->findShortestPath(getcwd(), $packagePath, true);
  1434. $io->writeError('Created: ', false);
  1435. $io->write(strlen($shortPath) < strlen($packagePath) ? $shortPath : $packagePath);
  1436. return 0;
  1437. }
  1438. protected function selectPackage(IOInterface $io, $packageName, $version = null)
  1439. {
  1440. $io->writeError('<info>Searching for the specified package.</info>');
  1441. if ($composer = $this->getComposer(false)) {
  1442. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  1443. $repo = new CompositeRepository(array_merge(array($localRepo), $composer->getRepositoryManager()->getRepositories()));
  1444. } else {
  1445. $defaultRepos = RepositoryFactory::defaultRepos($this->getIO());
  1446. $io->writeError('No composer.json found in the current directory, searching packages from ' . implode(', ', array_keys($defaultRepos)));
  1447. $repo = new CompositeRepository($defaultRepos);
  1448. }
  1449. $packages = $repo->findPackages($packageName, $version);
  1450. if (count($packages) > 1) {
  1451. $package = reset($packages);
  1452. $io->writeError('<info>Found multiple matches, selected '.$package->getPrettyString().'.</info>');
  1453. $io->writeError('Alternatives were '.implode(', ', array_map(function ($p) {
  1454. return $p->getPrettyString();
  1455. }, $packages)).'.');
  1456. $io->writeError('<comment>Please use a more specific constraint to pick a different package.</comment>');
  1457. } elseif ($packages) {
  1458. $package = reset($packages);
  1459. $io->writeError('<info>Found an exact match '.$package->getPrettyString().'.</info>');
  1460. } else {
  1461. $io->writeError('<error>Could not find a package matching '.$packageName.'.</error>');
  1462. return false;
  1463. }
  1464. return $package;
  1465. }
  1466. }
  1467. <?php
  1468. namespace Composer\Command;
  1469. use Composer\Composer;
  1470. use Composer\Config;
  1471. use Composer\Console\Application;
  1472. use Composer\Factory;
  1473. use Composer\IO\IOInterface;
  1474. use Composer\IO\NullIO;
  1475. use Composer\Plugin\PreCommandRunEvent;
  1476. use Composer\Package\Version\VersionParser;
  1477. use Composer\Plugin\PluginEvents;
  1478. use Symfony\Component\Console\Helper\Table;
  1479. use Symfony\Component\Console\Input\InputInterface;
  1480. use Symfony\Component\Console\Output\OutputInterface;
  1481. use Symfony\Component\Console\Command\Command;
  1482. abstract class BaseCommand extends Command
  1483. {
  1484. private $composer;
  1485. private $io;
  1486. public function getComposer($required = true, $disablePlugins = null)
  1487. {
  1488. if (null === $this->composer) {
  1489. $application = $this->getApplication();
  1490. if ($application instanceof Application) {
  1491. $this->composer = $application->getComposer($required, $disablePlugins);
  1492. } elseif ($required) {
  1493. throw new \RuntimeException(
  1494. 'Could not create a Composer\Composer instance, you must inject '.
  1495. 'one if this command is not used with a Composer\Console\Application instance'
  1496. );
  1497. }
  1498. }
  1499. return $this->composer;
  1500. }
  1501. public function setComposer(Composer $composer)
  1502. {
  1503. $this->composer = $composer;
  1504. }
  1505. public function resetComposer()
  1506. {
  1507. $this->composer = null;
  1508. $this->getApplication()->resetComposer();
  1509. }
  1510. public function isProxyCommand()
  1511. {
  1512. return false;
  1513. }
  1514. public function getIO()
  1515. {
  1516. if (null === $this->io) {
  1517. $application = $this->getApplication();
  1518. if ($application instanceof Application) {
  1519. $this->io = $application->getIO();
  1520. } else {
  1521. $this->io = new NullIO();
  1522. }
  1523. }
  1524. return $this->io;
  1525. }
  1526. public function setIO(IOInterface $io)
  1527. {
  1528. $this->io = $io;
  1529. }
  1530. protected function initialize(InputInterface $input, OutputInterface $output)
  1531. {
  1532. $disablePlugins = $input->hasParameterOption('--no-plugins');
  1533. $composer = $this->getComposer(false, $disablePlugins);
  1534. if (null === $composer) {
  1535. $composer = Factory::createGlobal($this->getIO(), $disablePlugins);
  1536. }
  1537. if ($composer) {
  1538. $preCommandRunEvent = new PreCommandRunEvent(PluginEvents::PRE_COMMAND_RUN, $input, $this->getName());
  1539. $composer->getEventDispatcher()->dispatch($preCommandRunEvent->getName(), $preCommandRunEvent);
  1540. }
  1541. if (true === $input->hasParameterOption(array('--no-ansi')) && $input->hasOption('no-progress')) {
  1542. $input->setOption('no-progress', true);
  1543. }
  1544. parent::initialize($input, $output);
  1545. }
  1546. protected function getPreferredInstallOptions(Config $config, InputInterface $input, $keepVcsRequiresPreferSource = false)
  1547. {
  1548. $preferSource = false;
  1549. $preferDist = false;
  1550. switch ($config->get('preferred-install')) {
  1551. case 'source':
  1552. $preferSource = true;
  1553. break;
  1554. case 'dist':
  1555. $preferDist = true;
  1556. break;
  1557. case 'auto':
  1558. default:
  1559. break;
  1560. }
  1561. if ($input->getOption('prefer-source') || $input->getOption('prefer-dist') || ($keepVcsRequiresPreferSource && $input->hasOption('keep-vcs') && $input->getOption('keep-vcs'))) {
  1562. $preferSource = $input->getOption('prefer-source') || ($keepVcsRequiresPreferSource && $input->hasOption('keep-vcs') && $input->getOption('keep-vcs'));
  1563. $preferDist = (bool) $input->getOption('prefer-dist');
  1564. }
  1565. return array($preferSource, $preferDist);
  1566. }
  1567. protected function formatRequirements(array $requirements)
  1568. {
  1569. $requires = array();
  1570. $requirements = $this->normalizeRequirements($requirements);
  1571. foreach ($requirements as $requirement) {
  1572. if (!isset($requirement['version'])) {
  1573. throw new \UnexpectedValueException('Option '.$requirement['name'] .' is missing a version constraint, use e.g. '.$requirement['name'].':^1.0');
  1574. }
  1575. $requires[$requirement['name']] = $requirement['version'];
  1576. }
  1577. return $requires;
  1578. }
  1579. protected function normalizeRequirements(array $requirements)
  1580. {
  1581. $parser = new VersionParser();
  1582. return $parser->parseNameVersionPairs($requirements);
  1583. }
  1584. protected function renderTable(array $table, OutputInterface $output)
  1585. {
  1586. $renderer = new Table($output);
  1587. $renderer->setStyle('compact');
  1588. $rendererStyle = $renderer->getStyle();
  1589. if (method_exists($rendererStyle, 'setVerticalBorderChars')) {
  1590. $rendererStyle->setVerticalBorderChars('');
  1591. } else {
  1592. $rendererStyle->setVerticalBorderChar('');
  1593. }
  1594. $rendererStyle->setCellRowContentFormat('%s ');
  1595. $renderer->setRows($table)->render();
  1596. }
  1597. }
  1598. <?php
  1599. namespace Composer\Command;
  1600. use Composer\Package\Link;
  1601. use Composer\Package\PackageInterface;
  1602. use Composer\Repository\InstalledArrayRepository;
  1603. use Composer\Repository\CompositeRepository;
  1604. use Composer\Repository\RootPackageRepository;
  1605. use Composer\Repository\InstalledRepository;
  1606. use Composer\Repository\PlatformRepository;
  1607. use Composer\Repository\RepositoryFactory;
  1608. use Composer\Plugin\CommandEvent;
  1609. use Composer\Plugin\PluginEvents;
  1610. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  1611. use Composer\Package\Version\VersionParser;
  1612. use Symfony\Component\Console\Input\InputArgument;
  1613. use Symfony\Component\Console\Input\InputInterface;
  1614. use Symfony\Component\Console\Input\InputOption;
  1615. use Symfony\Component\Console\Output\OutputInterface;
  1616. class BaseDependencyCommand extends BaseCommand
  1617. {
  1618. const ARGUMENT_PACKAGE = 'package';
  1619. const ARGUMENT_CONSTRAINT = 'constraint';
  1620. const OPTION_RECURSIVE = 'recursive';
  1621. const OPTION_TREE = 'tree';
  1622. protected $colors;
  1623. protected function configure()
  1624. {
  1625. $this->setDefinition(array(
  1626. new InputArgument(self::ARGUMENT_PACKAGE, InputArgument::REQUIRED, 'Package to inspect'),
  1627. new InputArgument(self::ARGUMENT_CONSTRAINT, InputArgument::OPTIONAL, 'Optional version constraint', '*'),
  1628. new InputOption(self::OPTION_RECURSIVE, 'r', InputOption::VALUE_NONE, 'Recursively resolves up to the root package'),
  1629. new InputOption(self::OPTION_TREE, 't', InputOption::VALUE_NONE, 'Prints the results as a nested tree'),
  1630. ));
  1631. }
  1632. protected function doExecute(InputInterface $input, OutputInterface $output, $inverted = false)
  1633. {
  1634. $composer = $this->getComposer();
  1635. $commandEvent = new CommandEvent(PluginEvents::COMMAND, $this->getName(), $input, $output);
  1636. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  1637. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  1638. $installedRepo = new InstalledRepository(array(
  1639. new RootPackageRepository($composer->getPackage()),
  1640. $composer->getRepositoryManager()->getLocalRepository(),
  1641. new PlatformRepository(array(), $platformOverrides),
  1642. ));
  1643. list($needle, $textConstraint) = array_pad(
  1644. explode(':', $input->getArgument(self::ARGUMENT_PACKAGE)),
  1645. 2,
  1646. $input->getArgument(self::ARGUMENT_CONSTRAINT)
  1647. );
  1648. $packages = $installedRepo->findPackagesWithReplacersAndProviders($needle);
  1649. if (empty($packages)) {
  1650. throw new \InvalidArgumentException(sprintf('Could not find package "%s" in your project', $needle));
  1651. }
  1652. if (!$installedRepo->findPackage($needle, $textConstraint)) {
  1653. $defaultRepos = new CompositeRepository(RepositoryFactory::defaultRepos($this->getIO()));
  1654. if ($match = $defaultRepos->findPackage($needle, $textConstraint)) {
  1655. $installedRepo->addRepository(new InstalledArrayRepository(array(clone $match)));
  1656. }
  1657. }
  1658. $needles = array($needle);
  1659. if ($inverted) {
  1660. foreach ($packages as $package) {
  1661. $needles = array_merge($needles, array_map(function (Link $link) {
  1662. return $link->getTarget();
  1663. }, $package->getReplaces()));
  1664. }
  1665. }
  1666. if ('*' !== $textConstraint) {
  1667. $versionParser = new VersionParser();
  1668. $constraint = $versionParser->parseConstraints($textConstraint);
  1669. } else {
  1670. $constraint = null;
  1671. }
  1672. $renderTree = $input->getOption(self::OPTION_TREE);
  1673. $recursive = $renderTree || $input->getOption(self::OPTION_RECURSIVE);
  1674. $results = $installedRepo->getDependents($needles, $constraint, $inverted, $recursive);
  1675. if (empty($results)) {
  1676. $extra = (null !== $constraint) ? sprintf(' in versions %smatching %s', $inverted ? 'not ' : '', $textConstraint) : '';
  1677. $this->getIO()->writeError(sprintf(
  1678. '<info>There is no installed package depending on "%s"%s</info>',
  1679. $needle,
  1680. $extra
  1681. ));
  1682. } elseif ($renderTree) {
  1683. $this->initStyles($output);
  1684. $root = $packages[0];
  1685. $this->getIO()->write(sprintf('<info>%s</info> %s %s', $root->getPrettyName(), $root->getPrettyVersion(), $root->getDescription()));
  1686. $this->printTree($results);
  1687. } else {
  1688. $this->printTable($output, $results);
  1689. }
  1690. return 0;
  1691. }
  1692. protected function printTable(OutputInterface $output, $results)
  1693. {
  1694. $table = array();
  1695. $doubles = array();
  1696. do {
  1697. $queue = array();
  1698. $rows = array();
  1699. foreach ($results as $result) {
  1700. list($package, $link, $children) = $result;
  1701. $unique = (string) $link;
  1702. if (isset($doubles[$unique])) {
  1703. continue;
  1704. }
  1705. $doubles[$unique] = true;
  1706. $version = (strpos($package->getPrettyVersion(), 'No version set') === 0) ? '-' : $package->getPrettyVersion();
  1707. $rows[] = array($package->getPrettyName(), $version, $link->getDescription(), sprintf('%s (%s)', $link->getTarget(), $link->getPrettyConstraint()));
  1708. if ($children) {
  1709. $queue = array_merge($queue, $children);
  1710. }
  1711. }
  1712. $results = $queue;
  1713. $table = array_merge($rows, $table);
  1714. } while (!empty($results));
  1715. $this->renderTable($table, $output);
  1716. }
  1717. protected function initStyles(OutputInterface $output)
  1718. {
  1719. $this->colors = array(
  1720. 'green',
  1721. 'yellow',
  1722. 'cyan',
  1723. 'magenta',
  1724. 'blue',
  1725. );
  1726. foreach ($this->colors as $color) {
  1727. $style = new OutputFormatterStyle($color);
  1728. $output->getFormatter()->setStyle($color, $style);
  1729. }
  1730. }
  1731. protected function printTree($results, $prefix = '', $level = 1)
  1732. {
  1733. $count = count($results);
  1734. $idx = 0;
  1735. foreach ($results as $result) {
  1736. list($package, $link, $children) = $result;
  1737. $color = $this->colors[$level % count($this->colors)];
  1738. $prevColor = $this->colors[($level - 1) % count($this->colors)];
  1739. $isLast = (++$idx == $count);
  1740. $versionText = (strpos($package->getPrettyVersion(), 'No version set') === 0) ? '' : $package->getPrettyVersion();
  1741. $packageText = rtrim(sprintf('<%s>%s</%1$s> %s', $color, $package->getPrettyName(), $versionText));
  1742. $linkText = sprintf('%s <%s>%s</%2$s> %s', $link->getDescription(), $prevColor, $link->getTarget(), $link->getPrettyConstraint());
  1743. $circularWarn = $children === false ? '(circular dependency aborted here)' : '';
  1744. $this->writeTreeLine(rtrim(sprintf("%s%s%s (%s) %s", $prefix, $isLast ? '└──' : '├──', $packageText, $linkText, $circularWarn)));
  1745. if ($children) {
  1746. $this->printTree($children, $prefix . ($isLast ? ' ' : '│ '), $level + 1);
  1747. }
  1748. }
  1749. }
  1750. private function writeTreeLine($line)
  1751. {
  1752. $io = $this->getIO();
  1753. if (!$io->isDecorated()) {
  1754. $line = str_replace(array('└', '├', '──', '│'), array('`-', '|-', '-', '|'), $line);
  1755. }
  1756. $io->write($line);
  1757. }
  1758. }
  1759. <?php
  1760. namespace Composer\Command;
  1761. use Composer\Package\Link;
  1762. use Composer\Package\PackageInterface;
  1763. use Composer\Semver\Constraint\Constraint;
  1764. use Symfony\Component\Console\Input\InputInterface;
  1765. use Symfony\Component\Console\Input\InputOption;
  1766. use Symfony\Component\Console\Output\OutputInterface;
  1767. use Composer\Repository\PlatformRepository;
  1768. use Composer\Repository\RootPackageRepository;
  1769. use Composer\Repository\InstalledRepository;
  1770. class CheckPlatformReqsCommand extends BaseCommand
  1771. {
  1772. protected function configure()
  1773. {
  1774. $this->setName('check-platform-reqs')
  1775. ->setDescription('Check that platform requirements are satisfied.')
  1776. ->setDefinition(array(
  1777. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables checking of require-dev packages requirements.'),
  1778. ))
  1779. ->setHelp(
  1780. <<<EOT
  1781. Checks that your PHP and extensions versions match the platform requirements of the installed packages.
  1782. 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.
  1783. <info>php composer.phar check-platform-reqs</info>
  1784. EOT
  1785. );
  1786. }
  1787. protected function execute(InputInterface $input, OutputInterface $output)
  1788. {
  1789. $composer = $this->getComposer();
  1790. $requires = array();
  1791. if ($input->getOption('no-dev')) {
  1792. $installedRepo = $composer->getLocker()->getLockedRepository(!$input->getOption('no-dev'));
  1793. } else {
  1794. $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
  1795. if (!$installedRepo->getPackages()) {
  1796. $installedRepo = $composer->getLocker()->getLockedRepository(true);
  1797. }
  1798. $requires += $composer->getPackage()->getDevRequires();
  1799. }
  1800. foreach ($requires as $require => $link) {
  1801. $requires[$require] = array($link);
  1802. }
  1803. $installedRepo = new InstalledRepository(array($installedRepo, new RootPackageRepository($composer->getPackage())));
  1804. foreach ($installedRepo->getPackages() as $package) {
  1805. foreach ($package->getRequires() as $require => $link) {
  1806. $requires[$require][] = $link;
  1807. }
  1808. }
  1809. ksort($requires);
  1810. $installedRepo->addRepository(new PlatformRepository(array(), array()));
  1811. $results = array();
  1812. $exitCode = 0;
  1813. foreach ($requires as $require => $links) {
  1814. if (PlatformRepository::isPlatformPackage($require)) {
  1815. $candidates = $installedRepo->findPackagesWithReplacersAndProviders($require);
  1816. if ($candidates) {
  1817. $reqResults = array();
  1818. foreach ($candidates as $candidate) {
  1819. $candidateConstraint = null;
  1820. if ($candidate->getName() === $require) {
  1821. $candidateConstraint = new Constraint('=', $candidate->getVersion());
  1822. $candidateConstraint->setPrettyString($candidate->getPrettyVersion());
  1823. } else {
  1824. foreach (array_merge($candidate->getProvides(), $candidate->getReplaces()) as $link) {
  1825. if ($link->getTarget() === $require) {
  1826. $candidateConstraint = $link->getConstraint();
  1827. break;
  1828. }
  1829. }
  1830. }
  1831. if (!$candidateConstraint) {
  1832. continue;
  1833. }
  1834. foreach ($links as $link) {
  1835. if (!$link->getConstraint()->matches($candidateConstraint)) {
  1836. $reqResults[] = array(
  1837. $candidate->getName() === $require ? $candidate->getPrettyName() : $require,
  1838. $candidateConstraint->getPrettyString(),
  1839. $link,
  1840. '<error>failed</error>'.($candidate->getName() === $require ? '' : ' <comment>provided by '.$candidate->getPrettyName().'</comment>'),
  1841. );
  1842. continue 2;
  1843. }
  1844. }
  1845. $results[] = array(
  1846. $candidate->getName() === $require ? $candidate->getPrettyName() : $require,
  1847. $candidateConstraint->getPrettyString(),
  1848. null,
  1849. '<info>success</info>'.($candidate->getName() === $require ? '' : ' <comment>provided by '.$candidate->getPrettyName().'</comment>'),
  1850. );
  1851. continue 2;
  1852. }
  1853. $results = array_merge($results, $reqResults);
  1854. $exitCode = max($exitCode, 1);
  1855. continue;
  1856. }
  1857. $results[] = array(
  1858. $require,
  1859. 'n/a',
  1860. $links[0],
  1861. '<error>missing</error>',
  1862. );
  1863. $exitCode = max($exitCode, 2);
  1864. }
  1865. }
  1866. $this->printTable($output, $results);
  1867. return $exitCode;
  1868. }
  1869. protected function printTable(OutputInterface $output, $results)
  1870. {
  1871. $rows = array();
  1872. foreach ($results as $result) {
  1873. list($platformPackage, $version, $link, $status) = $result;
  1874. $rows[] = array(
  1875. $platformPackage,
  1876. $version,
  1877. $link ? sprintf('%s %s %s (%s)', $link->getSource(), $link->getDescription(), $link->getTarget(), $link->getPrettyConstraint()) : '',
  1878. $status,
  1879. );
  1880. }
  1881. $this->renderTable($rows, $output);
  1882. }
  1883. }
  1884. <?php
  1885. namespace Composer\Command;
  1886. use Composer\Cache;
  1887. use Composer\Factory;
  1888. use Symfony\Component\Console\Input\InputInterface;
  1889. use Symfony\Component\Console\Output\OutputInterface;
  1890. class ClearCacheCommand extends BaseCommand
  1891. {
  1892. protected function configure()
  1893. {
  1894. $this
  1895. ->setName('clear-cache')
  1896. ->setAliases(array('clearcache', 'cc'))
  1897. ->setDescription('Clears composer\'s internal package cache.')
  1898. ->setHelp(
  1899. <<<EOT
  1900. The <info>clear-cache</info> deletes all cached packages from composer's
  1901. cache directory.
  1902. Read more at https://getcomposer.org/doc/03-cli.md#clear-cache-clearcache-cc
  1903. EOT
  1904. )
  1905. ;
  1906. }
  1907. protected function execute(InputInterface $input, OutputInterface $output)
  1908. {
  1909. $config = Factory::createConfig();
  1910. $io = $this->getIO();
  1911. $cachePaths = array(
  1912. 'cache-vcs-dir' => $config->get('cache-vcs-dir'),
  1913. 'cache-repo-dir' => $config->get('cache-repo-dir'),
  1914. 'cache-files-dir' => $config->get('cache-files-dir'),
  1915. 'cache-dir' => $config->get('cache-dir'),
  1916. );
  1917. foreach ($cachePaths as $key => $cachePath) {
  1918. $cachePath = realpath($cachePath);
  1919. if (!$cachePath) {
  1920. $io->writeError("<info>Cache directory does not exist ($key): $cachePath</info>");
  1921. continue;
  1922. }
  1923. $cache = new Cache($io, $cachePath);
  1924. $cache->setReadOnly($config->get('cache-read-only'));
  1925. if (!$cache->isEnabled()) {
  1926. $io->writeError("<info>Cache is not enabled ($key): $cachePath</info>");
  1927. continue;
  1928. }
  1929. $io->writeError("<info>Clearing cache ($key): $cachePath</info>");
  1930. $cache->clear();
  1931. }
  1932. $io->writeError('<info>All caches cleared.</info>');
  1933. return 0;
  1934. }
  1935. }
  1936. <?php
  1937. namespace Composer\Command;
  1938. use Composer\Util\Platform;
  1939. use Composer\Util\Silencer;
  1940. use Symfony\Component\Console\Input\InputInterface;
  1941. use Symfony\Component\Console\Input\InputArgument;
  1942. use Symfony\Component\Console\Input\InputOption;
  1943. use Symfony\Component\Console\Output\OutputInterface;
  1944. use Composer\Config;
  1945. use Composer\Config\JsonConfigSource;
  1946. use Composer\Factory;
  1947. use Composer\IO\IOInterface;
  1948. use Composer\Json\JsonFile;
  1949. use Composer\Semver\VersionParser;
  1950. use Composer\Package\BasePackage;
  1951. class ConfigCommand extends BaseCommand
  1952. {
  1953. protected $config;
  1954. protected $configFile;
  1955. protected $configSource;
  1956. protected $authConfigFile;
  1957. protected $authConfigSource;
  1958. protected function configure()
  1959. {
  1960. $this
  1961. ->setName('config')
  1962. ->setDescription('Sets config options.')
  1963. ->setDefinition(array(
  1964. new InputOption('global', 'g', InputOption::VALUE_NONE, 'Apply command to the global config file'),
  1965. new InputOption('editor', 'e', InputOption::VALUE_NONE, 'Open editor'),
  1966. new InputOption('auth', 'a', InputOption::VALUE_NONE, 'Affect auth config file (only used for --editor)'),
  1967. new InputOption('unset', null, InputOption::VALUE_NONE, 'Unset the given setting-key'),
  1968. new InputOption('list', 'l', InputOption::VALUE_NONE, 'List configuration settings'),
  1969. new InputOption('file', 'f', InputOption::VALUE_REQUIRED, 'If you want to choose a different composer.json or config.json'),
  1970. new InputOption('absolute', null, InputOption::VALUE_NONE, 'Returns absolute paths when fetching *-dir config values instead of relative'),
  1971. new InputOption('json', 'j', InputOption::VALUE_NONE, 'JSON decode the setting value, to be used with extra.* keys'),
  1972. 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'),
  1973. new InputArgument('setting-key', null, 'Setting key'),
  1974. new InputArgument('setting-value', InputArgument::IS_ARRAY, 'Setting value'),
  1975. ))
  1976. ->setHelp(
  1977. <<<EOT
  1978. This command allows you to edit composer config settings and repositories
  1979. in either the local composer.json file or the global config.json file.
  1980. Additionally it lets you edit most properties in the local composer.json.
  1981. To set a config setting:
  1982. <comment>%command.full_name% bin-dir bin/</comment>
  1983. To read a config setting:
  1984. <comment>%command.full_name% bin-dir</comment>
  1985. Outputs: <info>bin</info>
  1986. To edit the global config.json file:
  1987. <comment>%command.full_name% --global</comment>
  1988. To add a repository:
  1989. <comment>%command.full_name% repositories.foo vcs https://bar.com</comment>
  1990. To remove a repository (repo is a short alias for repositories):
  1991. <comment>%command.full_name% --unset repo.foo</comment>
  1992. To disable packagist:
  1993. <comment>%command.full_name% repo.packagist false</comment>
  1994. You can alter repositories in the global config.json file by passing in the
  1995. <info>--global</info> option.
  1996. To add or edit suggested packages you can use:
  1997. <comment>%command.full_name% suggest.package reason for the suggestion</comment>
  1998. To add or edit extra properties you can use:
  1999. <comment>%command.full_name% extra.property value</comment>
  2000. Or to add a complex value you can use json with:
  2001. <comment>%command.full_name% extra.property --json '{"foo":true, "bar": []}'</comment>
  2002. To edit the file in an external editor:
  2003. <comment>%command.full_name% --editor</comment>
  2004. To choose your editor you can set the "EDITOR" env variable.
  2005. To get a list of configuration values in the file:
  2006. <comment>%command.full_name% --list</comment>
  2007. You can always pass more than one option. As an example, if you want to edit the
  2008. global config.json file.
  2009. <comment>%command.full_name% --editor --global</comment>
  2010. Read more at https://getcomposer.org/doc/03-cli.md#config
  2011. EOT
  2012. )
  2013. ;
  2014. }
  2015. protected function initialize(InputInterface $input, OutputInterface $output)
  2016. {
  2017. parent::initialize($input, $output);
  2018. if ($input->getOption('global') && null !== $input->getOption('file')) {
  2019. throw new \RuntimeException('--file and --global can not be combined');
  2020. }
  2021. $io = $this->getIO();
  2022. $this->config = Factory::createConfig($io);
  2023. $configFile = $input->getOption('global')
  2024. ? ($this->config->get('home') . '/config.json')
  2025. : ($input->getOption('file') ?: Factory::getComposerFile());
  2026. if (
  2027. ($configFile === 'composer.json' || $configFile === './composer.json')
  2028. && !file_exists($configFile)
  2029. && realpath(getcwd()) === realpath($this->config->get('home'))
  2030. ) {
  2031. file_put_contents($configFile, "{\n}\n");
  2032. }
  2033. $this->configFile = new JsonFile($configFile, null, $io);
  2034. $this->configSource = new JsonConfigSource($this->configFile);
  2035. $authConfigFile = $input->getOption('global')
  2036. ? ($this->config->get('home') . '/auth.json')
  2037. : dirname(realpath($configFile)) . '/auth.json';
  2038. $this->authConfigFile = new JsonFile($authConfigFile, null, $io);
  2039. $this->authConfigSource = new JsonConfigSource($this->authConfigFile, true);
  2040. if ($input->getOption('global') && !$this->configFile->exists()) {
  2041. touch($this->configFile->getPath());
  2042. $this->configFile->write(array('config' => new \ArrayObject));
  2043. Silencer::call('chmod', $this->configFile->getPath(), 0600);
  2044. }
  2045. if ($input->getOption('global') && !$this->authConfigFile->exists()) {
  2046. touch($this->authConfigFile->getPath());
  2047. $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));
  2048. Silencer::call('chmod', $this->authConfigFile->getPath(), 0600);
  2049. }
  2050. if (!$this->configFile->exists()) {
  2051. throw new \RuntimeException(sprintf('File "%s" cannot be found in the current directory', $configFile));
  2052. }
  2053. }
  2054. protected function execute(InputInterface $input, OutputInterface $output)
  2055. {
  2056. if ($input->getOption('editor')) {
  2057. $editor = escapeshellcmd(getenv('EDITOR'));
  2058. if (!$editor) {
  2059. if (Platform::isWindows()) {
  2060. $editor = 'notepad';
  2061. } else {
  2062. foreach (array('editor', 'vim', 'vi', 'nano', 'pico', 'ed') as $candidate) {
  2063. if (exec('which '.$candidate)) {
  2064. $editor = $candidate;
  2065. break;
  2066. }
  2067. }
  2068. }
  2069. }
  2070. $file = $input->getOption('auth') ? $this->authConfigFile->getPath() : $this->configFile->getPath();
  2071. system($editor . ' ' . $file . (Platform::isWindows() ? '' : ' > `tty`'));
  2072. return 0;
  2073. }
  2074. if (!$input->getOption('global')) {
  2075. $this->config->merge($this->configFile->read());
  2076. $this->config->merge(array('config' => $this->authConfigFile->exists() ? $this->authConfigFile->read() : array()));
  2077. }
  2078. if ($input->getOption('list')) {
  2079. $this->listConfiguration($this->config->all(), $this->config->raw(), $output);
  2080. return 0;
  2081. }
  2082. $settingKey = $input->getArgument('setting-key');
  2083. if (!$settingKey || !is_string($settingKey)) {
  2084. return 0;
  2085. }
  2086. if (array() !== $input->getArgument('setting-value') && $input->getOption('unset')) {
  2087. throw new \RuntimeException('You can not combine a setting value with --unset');
  2088. }
  2089. if (array() === $input->getArgument('setting-value') && !$input->getOption('unset')) {
  2090. $properties = array('name', 'type', 'description', 'homepage', 'version', 'minimum-stability', 'prefer-stable', 'keywords', 'license', 'extra');
  2091. $rawData = $this->configFile->read();
  2092. $data = $this->config->all();
  2093. if (preg_match('/^repos?(?:itories)?(?:\.(.+))?/', $settingKey, $matches)) {
  2094. if (!isset($matches[1]) || $matches[1] === '') {
  2095. $value = isset($data['repositories']) ? $data['repositories'] : array();
  2096. } else {
  2097. if (!isset($data['repositories'][$matches[1]])) {
  2098. throw new \InvalidArgumentException('There is no '.$matches[1].' repository defined');
  2099. }
  2100. $value = $data['repositories'][$matches[1]];
  2101. }
  2102. } elseif (strpos($settingKey, '.')) {
  2103. $bits = explode('.', $settingKey);
  2104. if ($bits[0] === 'extra') {
  2105. $data = $rawData;
  2106. } else {
  2107. $data = $data['config'];
  2108. }
  2109. $match = false;
  2110. foreach ($bits as $bit) {
  2111. $key = isset($key) ? $key.'.'.$bit : $bit;
  2112. $match = false;
  2113. if (isset($data[$key])) {
  2114. $match = true;
  2115. $data = $data[$key];
  2116. unset($key);
  2117. }
  2118. }
  2119. if (!$match) {
  2120. throw new \RuntimeException($settingKey.' is not defined.');
  2121. }
  2122. $value = $data;
  2123. } elseif (isset($data['config'][$settingKey])) {
  2124. $value = $this->config->get($settingKey, $input->getOption('absolute') ? 0 : Config::RELATIVE_PATHS);
  2125. } elseif (isset($rawData[$settingKey]) && in_array($settingKey, $properties, true)) {
  2126. $value = $rawData[$settingKey];
  2127. } else {
  2128. throw new \RuntimeException($settingKey.' is not defined');
  2129. }
  2130. if (is_array($value)) {
  2131. $value = json_encode($value);
  2132. }
  2133. $this->getIO()->write($value, true, IOInterface::QUIET);
  2134. return 0;
  2135. }
  2136. $values = $input->getArgument('setting-value');
  2137. $booleanValidator = function ($val) {
  2138. return in_array($val, array('true', 'false', '1', '0'), true);
  2139. };
  2140. $booleanNormalizer = function ($val) {
  2141. return $val !== 'false' && (bool) $val;
  2142. };
  2143. $uniqueConfigValues = array(
  2144. 'process-timeout' => array('is_numeric', 'intval'),
  2145. 'use-include-path' => array($booleanValidator, $booleanNormalizer),
  2146. 'use-github-api' => array($booleanValidator, $booleanNormalizer),
  2147. 'preferred-install' => array(
  2148. function ($val) {
  2149. return in_array($val, array('auto', 'source', 'dist'), true);
  2150. },
  2151. function ($val) {
  2152. return $val;
  2153. },
  2154. ),
  2155. 'store-auths' => array(
  2156. function ($val) {
  2157. return in_array($val, array('true', 'false', 'prompt'), true);
  2158. },
  2159. function ($val) {
  2160. if ('prompt' === $val) {
  2161. return 'prompt';
  2162. }
  2163. return $val !== 'false' && (bool) $val;
  2164. },
  2165. ),
  2166. 'notify-on-install' => array($booleanValidator, $booleanNormalizer),
  2167. 'vendor-dir' => array('is_string', function ($val) {
  2168. return $val;
  2169. }),
  2170. 'bin-dir' => array('is_string', function ($val) {
  2171. return $val;
  2172. }),
  2173. 'archive-dir' => array('is_string', function ($val) {
  2174. return $val;
  2175. }),
  2176. 'archive-format' => array('is_string', function ($val) {
  2177. return $val;
  2178. }),
  2179. 'data-dir' => array('is_string', function ($val) {
  2180. return $val;
  2181. }),
  2182. 'cache-dir' => array('is_string', function ($val) {
  2183. return $val;
  2184. }),
  2185. 'cache-files-dir' => array('is_string', function ($val) {
  2186. return $val;
  2187. }),
  2188. 'cache-repo-dir' => array('is_string', function ($val) {
  2189. return $val;
  2190. }),
  2191. 'cache-vcs-dir' => array('is_string', function ($val) {
  2192. return $val;
  2193. }),
  2194. 'cache-ttl' => array('is_numeric', 'intval'),
  2195. 'cache-files-ttl' => array('is_numeric', 'intval'),
  2196. 'cache-files-maxsize' => array(
  2197. function ($val) {
  2198. return preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $val) > 0;
  2199. },
  2200. function ($val) {
  2201. return $val;
  2202. },
  2203. ),
  2204. 'bin-compat' => array(
  2205. function ($val) {
  2206. return in_array($val, array('auto', 'full'));
  2207. },
  2208. function ($val) {
  2209. return $val;
  2210. },
  2211. ),
  2212. 'discard-changes' => array(
  2213. function ($val) {
  2214. return in_array($val, array('stash', 'true', 'false', '1', '0'), true);
  2215. },
  2216. function ($val) {
  2217. if ('stash' === $val) {
  2218. return 'stash';
  2219. }
  2220. return $val !== 'false' && (bool) $val;
  2221. },
  2222. ),
  2223. 'autoloader-suffix' => array('is_string', function ($val) {
  2224. return $val === 'null' ? null : $val;
  2225. }),
  2226. 'sort-packages' => array($booleanValidator, $booleanNormalizer),
  2227. 'optimize-autoloader' => array($booleanValidator, $booleanNormalizer),
  2228. 'classmap-authoritative' => array($booleanValidator, $booleanNormalizer),
  2229. 'apcu-autoloader' => array($booleanValidator, $booleanNormalizer),
  2230. 'prepend-autoloader' => array($booleanValidator, $booleanNormalizer),
  2231. 'disable-tls' => array($booleanValidator, $booleanNormalizer),
  2232. 'secure-http' => array($booleanValidator, $booleanNormalizer),
  2233. 'cafile' => array(
  2234. function ($val) {
  2235. return file_exists($val) && is_readable($val);
  2236. },
  2237. function ($val) {
  2238. return $val === 'null' ? null : $val;
  2239. },
  2240. ),
  2241. 'capath' => array(
  2242. function ($val) {
  2243. return is_dir($val) && is_readable($val);
  2244. },
  2245. function ($val) {
  2246. return $val === 'null' ? null : $val;
  2247. },
  2248. ),
  2249. 'github-expose-hostname' => array($booleanValidator, $booleanNormalizer),
  2250. 'htaccess-protect' => array($booleanValidator, $booleanNormalizer),
  2251. 'lock' => array($booleanValidator, $booleanNormalizer),
  2252. 'platform-check' => array($booleanValidator, $booleanNormalizer),
  2253. );
  2254. $multiConfigValues = array(
  2255. 'github-protocols' => array(
  2256. function ($vals) {
  2257. if (!is_array($vals)) {
  2258. return 'array expected';
  2259. }
  2260. foreach ($vals as $val) {
  2261. if (!in_array($val, array('git', 'https', 'ssh'))) {
  2262. return 'valid protocols include: git, https, ssh';
  2263. }
  2264. }
  2265. return true;
  2266. },
  2267. function ($vals) {
  2268. return $vals;
  2269. },
  2270. ),
  2271. 'github-domains' => array(
  2272. function ($vals) {
  2273. if (!is_array($vals)) {
  2274. return 'array expected';
  2275. }
  2276. return true;
  2277. },
  2278. function ($vals) {
  2279. return $vals;
  2280. },
  2281. ),
  2282. 'gitlab-domains' => array(
  2283. function ($vals) {
  2284. if (!is_array($vals)) {
  2285. return 'array expected';
  2286. }
  2287. return true;
  2288. },
  2289. function ($vals) {
  2290. return $vals;
  2291. },
  2292. ),
  2293. );
  2294. if ($input->getOption('unset') && (isset($uniqueConfigValues[$settingKey]) || isset($multiConfigValues[$settingKey]))) {
  2295. if ($settingKey === 'disable-tls' && $this->config->get('disable-tls')) {
  2296. $this->getIO()->writeError('<info>You are now running Composer with SSL/TLS protection enabled.</info>');
  2297. }
  2298. $this->configSource->removeConfigSetting($settingKey);
  2299. return 0;
  2300. }
  2301. if (isset($uniqueConfigValues[$settingKey])) {
  2302. $this->handleSingleValue($settingKey, $uniqueConfigValues[$settingKey], $values, 'addConfigSetting');
  2303. return 0;
  2304. }
  2305. if (isset($multiConfigValues[$settingKey])) {
  2306. $this->handleMultiValue($settingKey, $multiConfigValues[$settingKey], $values, 'addConfigSetting');
  2307. return 0;
  2308. }
  2309. if (preg_match('/^preferred-install\.(.+)/', $settingKey, $matches)) {
  2310. if ($input->getOption('unset')) {
  2311. $this->configSource->removeConfigSetting($settingKey);
  2312. return 0;
  2313. }
  2314. list($validator) = $uniqueConfigValues['preferred-install'];
  2315. if (!$validator($values[0])) {
  2316. throw new \RuntimeException('Invalid value for '.$settingKey.'. Should be one of: auto, source, or dist');
  2317. }
  2318. $this->configSource->addConfigSetting($settingKey, $values[0]);
  2319. return 0;
  2320. }
  2321. $uniqueProps = array(
  2322. 'name' => array('is_string', function ($val) {
  2323. return $val;
  2324. }),
  2325. 'type' => array('is_string', function ($val) {
  2326. return $val;
  2327. }),
  2328. 'description' => array('is_string', function ($val) {
  2329. return $val;
  2330. }),
  2331. 'homepage' => array('is_string', function ($val) {
  2332. return $val;
  2333. }),
  2334. 'version' => array('is_string', function ($val) {
  2335. return $val;
  2336. }),
  2337. 'minimum-stability' => array(
  2338. function ($val) {
  2339. return isset(BasePackage::$stabilities[VersionParser::normalizeStability($val)]);
  2340. },
  2341. function ($val) {
  2342. return VersionParser::normalizeStability($val);
  2343. },
  2344. ),
  2345. 'prefer-stable' => array($booleanValidator, $booleanNormalizer),
  2346. );
  2347. $multiProps = array(
  2348. 'keywords' => array(
  2349. function ($vals) {
  2350. if (!is_array($vals)) {
  2351. return 'array expected';
  2352. }
  2353. return true;
  2354. },
  2355. function ($vals) {
  2356. return $vals;
  2357. },
  2358. ),
  2359. 'license' => array(
  2360. function ($vals) {
  2361. if (!is_array($vals)) {
  2362. return 'array expected';
  2363. }
  2364. return true;
  2365. },
  2366. function ($vals) {
  2367. return $vals;
  2368. },
  2369. ),
  2370. );
  2371. if ($input->getOption('global') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]) || strpos($settingKey, 'extra.') === 0)) {
  2372. 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');
  2373. }
  2374. if ($input->getOption('unset') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]))) {
  2375. $this->configSource->removeProperty($settingKey);
  2376. return 0;
  2377. }
  2378. if (isset($uniqueProps[$settingKey])) {
  2379. $this->handleSingleValue($settingKey, $uniqueProps[$settingKey], $values, 'addProperty');
  2380. return 0;
  2381. }
  2382. if (isset($multiProps[$settingKey])) {
  2383. $this->handleMultiValue($settingKey, $multiProps[$settingKey], $values, 'addProperty');
  2384. return 0;
  2385. }
  2386. if (preg_match('/^repos?(?:itories)?\.(.+)/', $settingKey, $matches)) {
  2387. if ($input->getOption('unset')) {
  2388. $this->configSource->removeRepository($matches[1]);
  2389. return 0;
  2390. }
  2391. if (2 === count($values)) {
  2392. $this->configSource->addRepository($matches[1], array(
  2393. 'type' => $values[0],
  2394. 'url' => $values[1],
  2395. ));
  2396. return 0;
  2397. }
  2398. if (1 === count($values)) {
  2399. $value = strtolower($values[0]);
  2400. if (true === $booleanValidator($value)) {
  2401. if (false === $booleanNormalizer($value)) {
  2402. $this->configSource->addRepository($matches[1], false);
  2403. return 0;
  2404. }
  2405. } else {
  2406. $value = JsonFile::parseJson($values[0]);
  2407. $this->configSource->addRepository($matches[1], $value);
  2408. return 0;
  2409. }
  2410. }
  2411. throw new \RuntimeException('You must pass the type and a url. Example: php composer.phar config repositories.foo vcs https://bar.com');
  2412. }
  2413. if (preg_match('/^extra\.(.+)/', $settingKey, $matches)) {
  2414. if ($input->getOption('unset')) {
  2415. $this->configSource->removeProperty($settingKey);
  2416. return 0;
  2417. }
  2418. $value = $values[0];
  2419. if ($input->getOption('json')) {
  2420. $value = JsonFile::parseJson($value);
  2421. if ($input->getOption('merge')) {
  2422. $currentValue = $this->configFile->read();
  2423. $bits = explode('.', $settingKey);
  2424. foreach ($bits as $bit) {
  2425. $currentValue = isset($currentValue[$bit]) ? $currentValue[$bit] : null;
  2426. }
  2427. if (is_array($currentValue)) {
  2428. $value = array_merge($currentValue, $value);
  2429. }
  2430. }
  2431. }
  2432. $this->configSource->addProperty($settingKey, $value);
  2433. return 0;
  2434. }
  2435. if (preg_match('/^suggest\.(.+)/', $settingKey, $matches)) {
  2436. if ($input->getOption('unset')) {
  2437. $this->configSource->removeProperty($settingKey);
  2438. return 0;
  2439. }
  2440. $this->configSource->addProperty($settingKey, implode(' ', $values));
  2441. return 0;
  2442. }
  2443. if (in_array($settingKey, array('suggest', 'extra'), true) && $input->getOption('unset')) {
  2444. $this->configSource->removeProperty($settingKey);
  2445. return 0;
  2446. }
  2447. if (preg_match('/^platform\.(.+)/', $settingKey, $matches)) {
  2448. if ($input->getOption('unset')) {
  2449. $this->configSource->removeConfigSetting($settingKey);
  2450. return 0;
  2451. }
  2452. $this->configSource->addConfigSetting($settingKey, $values[0]);
  2453. return 0;
  2454. }
  2455. if ($settingKey === 'platform' && $input->getOption('unset')) {
  2456. $this->configSource->removeConfigSetting($settingKey);
  2457. return 0;
  2458. }
  2459. if (preg_match('/^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|http-basic|bearer)\.(.+)/', $settingKey, $matches)) {
  2460. if ($input->getOption('unset')) {
  2461. $this->authConfigSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2462. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2463. return 0;
  2464. }
  2465. if ($matches[1] === 'bitbucket-oauth') {
  2466. if (2 !== count($values)) {
  2467. throw new \RuntimeException('Expected two arguments (consumer-key, consumer-secret), got '.count($values));
  2468. }
  2469. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2470. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('consumer-key' => $values[0], 'consumer-secret' => $values[1]));
  2471. } elseif (in_array($matches[1], array('github-oauth', 'gitlab-oauth', 'gitlab-token', 'bearer'), true)) {
  2472. if (1 !== count($values)) {
  2473. throw new \RuntimeException('Too many arguments, expected only one token');
  2474. }
  2475. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2476. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], $values[0]);
  2477. } elseif ($matches[1] === 'http-basic') {
  2478. if (2 !== count($values)) {
  2479. throw new \RuntimeException('Expected two arguments (username, password), got '.count($values));
  2480. }
  2481. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2482. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('username' => $values[0], 'password' => $values[1]));
  2483. }
  2484. return 0;
  2485. }
  2486. if (preg_match('/^scripts\.(.+)/', $settingKey, $matches)) {
  2487. if ($input->getOption('unset')) {
  2488. $this->configSource->removeProperty($settingKey);
  2489. return 0;
  2490. }
  2491. $this->configSource->addProperty($settingKey, count($values) > 1 ? $values : $values[0]);
  2492. return 0;
  2493. }
  2494. throw new \InvalidArgumentException('Setting '.$settingKey.' does not exist or is not supported by this command');
  2495. }
  2496. protected function handleSingleValue($key, array $callbacks, array $values, $method)
  2497. {
  2498. list($validator, $normalizer) = $callbacks;
  2499. if (1 !== count($values)) {
  2500. throw new \RuntimeException('You can only pass one value. Example: php composer.phar config process-timeout 300');
  2501. }
  2502. if (true !== $validation = $validator($values[0])) {
  2503. throw new \RuntimeException(sprintf(
  2504. '"%s" is an invalid value'.($validation ? ' ('.$validation.')' : ''),
  2505. $values[0]
  2506. ));
  2507. }
  2508. $normalizedValue = $normalizer($values[0]);
  2509. if ($key === 'disable-tls') {
  2510. if (!$normalizedValue && $this->config->get('disable-tls')) {
  2511. $this->getIO()->writeError('<info>You are now running Composer with SSL/TLS protection enabled.</info>');
  2512. } elseif ($normalizedValue && !$this->config->get('disable-tls')) {
  2513. $this->getIO()->writeError('<warning>You are now running Composer with SSL/TLS protection disabled.</warning>');
  2514. }
  2515. }
  2516. return call_user_func(array($this->configSource, $method), $key, $normalizedValue);
  2517. }
  2518. protected function handleMultiValue($key, array $callbacks, array $values, $method)
  2519. {
  2520. list($validator, $normalizer) = $callbacks;
  2521. if (true !== $validation = $validator($values)) {
  2522. throw new \RuntimeException(sprintf(
  2523. '%s is an invalid value'.($validation ? ' ('.$validation.')' : ''),
  2524. json_encode($values)
  2525. ));
  2526. }
  2527. return call_user_func(array($this->configSource, $method), $key, $normalizer($values));
  2528. }
  2529. protected function listConfiguration(array $contents, array $rawContents, OutputInterface $output, $k = null)
  2530. {
  2531. $origK = $k;
  2532. $io = $this->getIO();
  2533. foreach ($contents as $key => $value) {
  2534. if ($k === null && !in_array($key, array('config', 'repositories'))) {
  2535. continue;
  2536. }
  2537. $rawVal = isset($rawContents[$key]) ? $rawContents[$key] : null;
  2538. if (is_array($value) && (!is_numeric(key($value)) || ($key === 'repositories' && null === $k))) {
  2539. $k .= preg_replace('{^config\.}', '', $key . '.');
  2540. $this->listConfiguration($value, $rawVal, $output, $k);
  2541. $k = $origK;
  2542. continue;
  2543. }
  2544. if (is_array($value)) {
  2545. $value = array_map(function ($val) {
  2546. return is_array($val) ? json_encode($val) : $val;
  2547. }, $value);
  2548. $value = '['.implode(', ', $value).']';
  2549. }
  2550. if (is_bool($value)) {
  2551. $value = var_export($value, true);
  2552. }
  2553. if (is_string($rawVal) && $rawVal != $value) {
  2554. $io->write('[<comment>' . $k . $key . '</comment>] <info>' . $rawVal . ' (' . $value . ')</info>', true, IOInterface::QUIET);
  2555. } else {
  2556. $io->write('[<comment>' . $k . $key . '</comment>] <info>' . $value . '</info>', true, IOInterface::QUIET);
  2557. }
  2558. }
  2559. }
  2560. }
  2561. <?php
  2562. namespace Composer\Command;
  2563. use Composer\Config;
  2564. use Composer\Factory;
  2565. use Composer\Installer;
  2566. use Composer\Installer\ProjectInstaller;
  2567. use Composer\Installer\InstallationManager;
  2568. use Composer\Installer\SuggestedPackagesReporter;
  2569. use Composer\IO\IOInterface;
  2570. use Composer\Package\BasePackage;
  2571. use Composer\DependencyResolver\Operation\InstallOperation;
  2572. use Composer\Package\Version\VersionSelector;
  2573. use Composer\Package\AliasPackage;
  2574. use Composer\Repository\RepositoryFactory;
  2575. use Composer\Repository\CompositeRepository;
  2576. use Composer\Repository\PlatformRepository;
  2577. use Composer\Repository\InstalledFilesystemRepository;
  2578. use Composer\Repository\RepositorySet;
  2579. use Composer\Script\ScriptEvents;
  2580. use Composer\Util\Silencer;
  2581. use Symfony\Component\Console\Input\InputArgument;
  2582. use Symfony\Component\Console\Input\InputInterface;
  2583. use Symfony\Component\Console\Input\InputOption;
  2584. use Symfony\Component\Console\Output\OutputInterface;
  2585. use Symfony\Component\Finder\Finder;
  2586. use Composer\Json\JsonFile;
  2587. use Composer\Config\JsonConfigSource;
  2588. use Composer\Util\Filesystem;
  2589. use Composer\Util\ProcessExecutor;
  2590. use Composer\Util\Loop;
  2591. use Composer\Package\Version\VersionParser;
  2592. use Composer\EventDispatcher\EventDispatcher;
  2593. class CreateProjectCommand extends BaseCommand
  2594. {
  2595. protected $suggestedPackagesReporter;
  2596. protected function configure()
  2597. {
  2598. $this
  2599. ->setName('create-project')
  2600. ->setDescription('Creates new project from a package into given directory.')
  2601. ->setDefinition(array(
  2602. new InputArgument('package', InputArgument::OPTIONAL, 'Package name to be installed'),
  2603. new InputArgument('directory', InputArgument::OPTIONAL, 'Directory where the files should be created'),
  2604. new InputArgument('version', InputArgument::OPTIONAL, 'Version, will default to latest'),
  2605. new InputOption('stability', 's', InputOption::VALUE_REQUIRED, 'Minimum-stability allowed (unless a version is specified).'),
  2606. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  2607. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
  2608. 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'),
  2609. new InputOption('repository-url', null, InputOption::VALUE_REQUIRED, 'DEPRECATED: Use --repository instead.'),
  2610. 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.'),
  2611. new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of require-dev packages (enabled by default, only present for BC).'),
  2612. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  2613. new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'DEPRECATED: Use no-plugins instead.'),
  2614. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Whether to prevent execution of all defined scripts in the root package.'),
  2615. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  2616. 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.'),
  2617. new InputOption('keep-vcs', null, InputOption::VALUE_NONE, 'Whether to prevent deleting the vcs folder.'),
  2618. new InputOption('remove-vcs', null, InputOption::VALUE_NONE, 'Whether to force deletion of the vcs folder without prompting.'),
  2619. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Whether to skip installation of the package dependencies.'),
  2620. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  2621. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  2622. new InputOption('ask', null, InputOption::VALUE_NONE, 'Whether to ask for project directory.'),
  2623. ))
  2624. ->setHelp(
  2625. <<<EOT
  2626. The <info>create-project</info> command creates a new project from a given
  2627. package into a new directory. If executed without params and in a directory
  2628. with a composer.json file it installs the packages for the current project.
  2629. You can use this command to bootstrap new projects or setup a clean
  2630. version-controlled installation for developers of your project.
  2631. <info>php composer.phar create-project vendor/project target-directory [version]</info>
  2632. You can also specify the version with the package name using = or : as separator.
  2633. <info>php composer.phar create-project vendor/project:version target-directory</info>
  2634. To install unstable packages, either specify the version you want, or use the
  2635. --stability=dev (where dev can be one of RC, beta, alpha or dev).
  2636. To setup a developer workable version you should create the project using the source
  2637. controlled code by appending the <info>'--prefer-source'</info> flag.
  2638. To install a package from another repository than the default one you
  2639. can pass the <info>'--repository=https://myrepository.org'</info> flag.
  2640. Read more at https://getcomposer.org/doc/03-cli.md#create-project
  2641. EOT
  2642. )
  2643. ;
  2644. }
  2645. protected function execute(InputInterface $input, OutputInterface $output)
  2646. {
  2647. $config = Factory::createConfig();
  2648. $io = $this->getIO();
  2649. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input, true);
  2650. if ($input->getOption('dev')) {
  2651. $io->writeError('<warning>You are using the deprecated option "dev". Dev packages are installed by default now.</warning>');
  2652. }
  2653. if ($input->getOption('no-custom-installers')) {
  2654. $io->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
  2655. $input->setOption('no-plugins', true);
  2656. }
  2657. if ($input->isInteractive() && $input->getOption('ask')) {
  2658. $parts = explode("/", strtolower($input->getArgument('package')), 2);
  2659. $input->setArgument('directory', $io->ask('New project directory [<comment>'.array_pop($parts).'</comment>]: '));
  2660. }
  2661. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  2662. return $this->installProject(
  2663. $io,
  2664. $config,
  2665. $input,
  2666. $input->getArgument('package'),
  2667. $input->getArgument('directory'),
  2668. $input->getArgument('version'),
  2669. $input->getOption('stability'),
  2670. $preferSource,
  2671. $preferDist,
  2672. !$input->getOption('no-dev'),
  2673. $input->getOption('repository') ?: $input->getOption('repository-url'),
  2674. $input->getOption('no-plugins'),
  2675. $input->getOption('no-scripts'),
  2676. $input->getOption('no-progress'),
  2677. $input->getOption('no-install'),
  2678. $ignorePlatformReqs,
  2679. !$input->getOption('no-secure-http'),
  2680. $input->getOption('add-repository')
  2681. );
  2682. }
  2683. public function installProject(IOInterface $io, Config $config, InputInterface $input, $packageName, $directory = null, $packageVersion = null, $stability = 'stable', $preferSource = false, $preferDist = false, $installDevPackages = false, $repositories = null, $disablePlugins = false, $noScripts = false, $noProgress = false, $noInstall = false, $ignorePlatformReqs = false, $secureHttp = true, $addRepository = false)
  2684. {
  2685. $oldCwd = getcwd();
  2686. if ($repositories !== null && !is_array($repositories)) {
  2687. $repositories = (array) $repositories;
  2688. }
  2689. $io->loadConfiguration($config);
  2690. $this->suggestedPackagesReporter = new SuggestedPackagesReporter($io);
  2691. if ($packageName !== null) {
  2692. $installedFromVcs = $this->installRootPackage($io, $config, $packageName, $directory, $packageVersion, $stability, $preferSource, $preferDist, $installDevPackages, $repositories, $disablePlugins, $noScripts, $noProgress, $ignorePlatformReqs, $secureHttp);
  2693. } else {
  2694. $installedFromVcs = false;
  2695. }
  2696. if ($repositories !== null && $addRepository && is_file('composer.lock')) {
  2697. unlink('composer.lock');
  2698. }
  2699. $composer = Factory::create($io, null, $disablePlugins);
  2700. if ($repositories !== null && $addRepository) {
  2701. foreach ($repositories as $index => $repo) {
  2702. $repoConfig = RepositoryFactory::configFromString($io, $composer->getConfig(), $repo, true);
  2703. $composerJsonRepositoriesConfig = $composer->getConfig()->getRepositories();
  2704. $name = RepositoryFactory::generateRepositoryName($index, $repoConfig, $composerJsonRepositoriesConfig);
  2705. $configSource = new JsonConfigSource(new JsonFile('composer.json'));
  2706. if (
  2707. (isset($repoConfig['packagist']) && $repoConfig === array('packagist' => false))
  2708. || (isset($repoConfig['packagist.org']) && $repoConfig === array('packagist.org' => false))
  2709. ) {
  2710. $configSource->addRepository('packagist.org', false);
  2711. } else {
  2712. $configSource->addRepository($name, $repoConfig);
  2713. }
  2714. $composer = Factory::create($io, null, $disablePlugins);
  2715. }
  2716. }
  2717. $process = new ProcessExecutor($io);
  2718. $fs = new Filesystem($process);
  2719. if ($noScripts === false) {
  2720. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ROOT_PACKAGE_INSTALL, $installDevPackages);
  2721. }
  2722. $config = $composer->getConfig();
  2723. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  2724. if ($noInstall === false) {
  2725. $composer->getInstallationManager()->setOutputProgress(!$noProgress);
  2726. $installer = Installer::create($io, $composer);
  2727. $installer->setPreferSource($preferSource)
  2728. ->setPreferDist($preferDist)
  2729. ->setDevMode($installDevPackages)
  2730. ->setRunScripts(!$noScripts)
  2731. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  2732. ->setSuggestedPackagesReporter($this->suggestedPackagesReporter)
  2733. ->setOptimizeAutoloader($config->get('optimize-autoloader'))
  2734. ->setClassMapAuthoritative($config->get('classmap-authoritative'))
  2735. ->setApcuAutoloader($config->get('apcu-autoloader'));
  2736. if (!$composer->getLocker()->isLocked()) {
  2737. $installer->setUpdate(true);
  2738. }
  2739. if ($disablePlugins) {
  2740. $installer->disablePlugins();
  2741. }
  2742. $status = $installer->run();
  2743. if (0 !== $status) {
  2744. return $status;
  2745. }
  2746. }
  2747. $hasVcs = $installedFromVcs;
  2748. if (
  2749. !$input->getOption('keep-vcs')
  2750. && $installedFromVcs
  2751. && (
  2752. $input->getOption('remove-vcs')
  2753. || !$io->isInteractive()
  2754. || $io->askConfirmation('<info>Do you want to remove the existing VCS (.git, .svn..) history?</info> [<comment>Y,n</comment>]? ')
  2755. )
  2756. ) {
  2757. $finder = new Finder();
  2758. $finder->depth(0)->directories()->in(getcwd())->ignoreVCS(false)->ignoreDotFiles(false);
  2759. foreach (array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg', '.fslckout', '_FOSSIL_') as $vcsName) {
  2760. $finder->name($vcsName);
  2761. }
  2762. try {
  2763. $dirs = iterator_to_array($finder);
  2764. unset($finder);
  2765. foreach ($dirs as $dir) {
  2766. if (!$fs->removeDirectory($dir)) {
  2767. throw new \RuntimeException('Could not remove '.$dir);
  2768. }
  2769. }
  2770. } catch (\Exception $e) {
  2771. $io->writeError('<error>An error occurred while removing the VCS metadata: '.$e->getMessage().'</error>');
  2772. }
  2773. $hasVcs = false;
  2774. }
  2775. if (!$hasVcs) {
  2776. $package = $composer->getPackage();
  2777. $configSource = new JsonConfigSource(new JsonFile('composer.json'));
  2778. foreach (BasePackage::$supportedLinkTypes as $type => $meta) {
  2779. foreach ($package->{'get'.$meta['method']}() as $link) {
  2780. if ($link->getPrettyConstraint() === 'self.version') {
  2781. $configSource->addLink($type, $link->getTarget(), $package->getPrettyVersion());
  2782. }
  2783. }
  2784. }
  2785. }
  2786. if ($noScripts === false) {
  2787. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_CREATE_PROJECT_CMD, $installDevPackages);
  2788. }
  2789. chdir($oldCwd);
  2790. $vendorComposerDir = $config->get('vendor-dir').'/composer';
  2791. if (is_dir($vendorComposerDir) && $fs->isDirEmpty($vendorComposerDir)) {
  2792. Silencer::call('rmdir', $vendorComposerDir);
  2793. $vendorDir = $config->get('vendor-dir');
  2794. if (is_dir($vendorDir) && $fs->isDirEmpty($vendorDir)) {
  2795. Silencer::call('rmdir', $vendorDir);
  2796. }
  2797. }
  2798. return 0;
  2799. }
  2800. 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)
  2801. {
  2802. if (!$secureHttp) {
  2803. $config->merge(array('config' => array('secure-http' => false)));
  2804. }
  2805. $parser = new VersionParser();
  2806. $requirements = $parser->parseNameVersionPairs(array($packageName));
  2807. $name = strtolower($requirements[0]['name']);
  2808. if (!$packageVersion && isset($requirements[0]['version'])) {
  2809. $packageVersion = $requirements[0]['version'];
  2810. }
  2811. if (null === $directory) {
  2812. $parts = explode("/", $name, 2);
  2813. $directory = getcwd() . DIRECTORY_SEPARATOR . array_pop($parts);
  2814. }
  2815. $process = new ProcessExecutor($io);
  2816. $fs = new Filesystem($process);
  2817. if (!$fs->isAbsolutePath($directory)) {
  2818. $directory = getcwd() . DIRECTORY_SEPARATOR . $directory;
  2819. }
  2820. $io->writeError('<info>Creating a "' . $packageName . '" project at "' . $fs->findShortestPath(getcwd(), $directory, true) . '"</info>');
  2821. if (file_exists($directory)) {
  2822. if (!is_dir($directory)) {
  2823. throw new \InvalidArgumentException('Cannot create project directory at "'.$directory.'", it exists as a file.');
  2824. }
  2825. if (!$fs->isDirEmpty($directory)) {
  2826. throw new \InvalidArgumentException('Project directory "'.$directory.'" is not empty.');
  2827. }
  2828. }
  2829. if (null === $stability) {
  2830. if (preg_match('{^[^,\s]*?@('.implode('|', array_keys(BasePackage::$stabilities)).')$}i', $packageVersion, $match)) {
  2831. $stability = $match[1];
  2832. } else {
  2833. $stability = VersionParser::parseStability($packageVersion);
  2834. }
  2835. }
  2836. $stability = VersionParser::normalizeStability($stability);
  2837. if (!isset(BasePackage::$stabilities[$stability])) {
  2838. throw new \InvalidArgumentException('Invalid stability provided ('.$stability.'), must be one of: '.implode(', ', array_keys(BasePackage::$stabilities)));
  2839. }
  2840. $composer = Factory::create($io, $config->all(), $disablePlugins);
  2841. $config = $composer->getConfig();
  2842. $rm = $composer->getRepositoryManager();
  2843. $repositorySet = new RepositorySet($stability);
  2844. if (null === $repositories) {
  2845. $repositorySet->addRepository(new CompositeRepository(RepositoryFactory::defaultRepos($io, $config, $rm)));
  2846. } else {
  2847. foreach ($repositories as $repo) {
  2848. $repoConfig = RepositoryFactory::configFromString($io, $config, $repo, true);
  2849. if (
  2850. (isset($repoConfig['packagist']) && $repoConfig === array('packagist' => false))
  2851. || (isset($repoConfig['packagist.org']) && $repoConfig === array('packagist.org' => false))
  2852. ) {
  2853. continue;
  2854. }
  2855. $repositorySet->addRepository(RepositoryFactory::createRepo($io, $config, $repoConfig, $rm));
  2856. }
  2857. }
  2858. $platformOverrides = $config->get('platform') ?: array();
  2859. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  2860. $versionSelector = new VersionSelector($repositorySet, $platformRepo);
  2861. $package = $versionSelector->findBestCandidate($name, $packageVersion, $stability, $ignorePlatformReqs);
  2862. if (!$package) {
  2863. $errorMessage = "Could not find package $name with " . ($packageVersion ? "version $packageVersion" : "stability $stability");
  2864. if (true !== $ignorePlatformReqs && $versionSelector->findBestCandidate($name, $packageVersion, $stability, true)) {
  2865. throw new \InvalidArgumentException($errorMessage .' in a version installable using your PHP version, PHP extensions and Composer version.');
  2866. }
  2867. throw new \InvalidArgumentException($errorMessage .'.');
  2868. }
  2869. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  2870. @mkdir($directory, 0777, true);
  2871. if ($realDir = realpath($directory)) {
  2872. pcntl_async_signals(true);
  2873. pcntl_signal(SIGINT, function () use ($realDir) {
  2874. $fs = new Filesystem();
  2875. $fs->removeDirectory($realDir);
  2876. exit(130);
  2877. });
  2878. }
  2879. }
  2880. if (function_exists('sapi_windows_set_ctrl_handler')) {
  2881. @mkdir($directory, 0777, true);
  2882. if ($realDir = realpath($directory)) {
  2883. sapi_windows_set_ctrl_handler(function () use ($realDir) {
  2884. $fs = new Filesystem();
  2885. $fs->removeDirectory($realDir);
  2886. exit(130);
  2887. });
  2888. }
  2889. }
  2890. if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  2891. $package = $package->getAliasOf();
  2892. }
  2893. $io->writeError('<info>Installing ' . $package->getName() . ' (' . $package->getFullPrettyVersion(false) . ')</info>');
  2894. if ($disablePlugins) {
  2895. $io->writeError('<info>Plugins have been disabled.</info>');
  2896. }
  2897. if ($package instanceof AliasPackage) {
  2898. $package = $package->getAliasOf();
  2899. }
  2900. $dm = $composer->getDownloadManager();
  2901. $dm->setPreferSource($preferSource)
  2902. ->setPreferDist($preferDist);
  2903. $projectInstaller = new ProjectInstaller($directory, $dm, $fs);
  2904. $im = $composer->getInstallationManager();
  2905. $im->setOutputProgress(!$noProgress);
  2906. $im->addInstaller($projectInstaller);
  2907. $im->execute(new InstalledFilesystemRepository(new JsonFile('php://memory')), array(new InstallOperation($package)));
  2908. $im->notifyInstalls($io);
  2909. $this->suggestedPackagesReporter->addSuggestionsFromPackage($package);
  2910. $installedFromVcs = 'source' === $package->getInstallationSource();
  2911. $io->writeError('<info>Created project in ' . $directory . '</info>');
  2912. chdir($directory);
  2913. $_SERVER['COMPOSER_ROOT_VERSION'] = $package->getPrettyVersion();
  2914. putenv('COMPOSER_ROOT_VERSION='.$_SERVER['COMPOSER_ROOT_VERSION']);
  2915. return $installedFromVcs;
  2916. }
  2917. }
  2918. <?php
  2919. namespace Composer\Command;
  2920. use Symfony\Component\Console\Input\InputInterface;
  2921. use Symfony\Component\Console\Output\OutputInterface;
  2922. class DependsCommand extends BaseDependencyCommand
  2923. {
  2924. protected function configure()
  2925. {
  2926. parent::configure();
  2927. $this
  2928. ->setName('depends')
  2929. ->setAliases(array('why'))
  2930. ->setDescription('Shows which packages cause the given package to be installed.')
  2931. ->setHelp(
  2932. <<<EOT
  2933. Displays detailed information about where a package is referenced.
  2934. <info>php composer.phar depends composer/composer</info>
  2935. Read more at https://getcomposer.org/doc/03-cli.md#depends-why-
  2936. EOT
  2937. )
  2938. ;
  2939. }
  2940. protected function execute(InputInterface $input, OutputInterface $output)
  2941. {
  2942. return parent::doExecute($input, $output);
  2943. }
  2944. }
  2945. <?php
  2946. namespace Composer\Command;
  2947. use Composer\Composer;
  2948. use Composer\Factory;
  2949. use Composer\Config;
  2950. use Composer\Downloader\TransportException;
  2951. use Composer\Repository\PlatformRepository;
  2952. use Composer\Plugin\CommandEvent;
  2953. use Composer\Plugin\PluginEvents;
  2954. use Composer\Util\ConfigValidator;
  2955. use Composer\Util\IniHelper;
  2956. use Composer\Util\ProcessExecutor;
  2957. use Composer\Util\HttpDownloader;
  2958. use Composer\Util\StreamContextFactory;
  2959. use Composer\SelfUpdate\Keys;
  2960. use Composer\SelfUpdate\Versions;
  2961. use Composer\IO\NullIO;
  2962. use Symfony\Component\Console\Input\InputInterface;
  2963. use Symfony\Component\Console\Output\OutputInterface;
  2964. class DiagnoseCommand extends BaseCommand
  2965. {
  2966. protected $httpDownloader;
  2967. protected $process;
  2968. protected $exitCode = 0;
  2969. protected function configure()
  2970. {
  2971. $this
  2972. ->setName('diagnose')
  2973. ->setDescription('Diagnoses the system to identify common errors.')
  2974. ->setHelp(
  2975. <<<EOT
  2976. The <info>diagnose</info> command checks common errors to help debugging problems.
  2977. The process exit code will be 1 in case of warnings and 2 for errors.
  2978. Read more at https://getcomposer.org/doc/03-cli.md#diagnose
  2979. EOT
  2980. )
  2981. ;
  2982. }
  2983. protected function execute(InputInterface $input, OutputInterface $output)
  2984. {
  2985. $composer = $this->getComposer(false);
  2986. $io = $this->getIO();
  2987. if ($composer) {
  2988. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'diagnose', $input, $output);
  2989. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  2990. $io->write('Checking composer.json: ', false);
  2991. $this->outputResult($this->checkComposerSchema());
  2992. }
  2993. if ($composer) {
  2994. $config = $composer->getConfig();
  2995. } else {
  2996. $config = Factory::createConfig();
  2997. }
  2998. $config->merge(array('config' => array('secure-http' => false)));
  2999. $config->prohibitUrlByConfig('http://repo.packagist.org', new NullIO);
  3000. $this->httpDownloader = Factory::createHttpDownloader($io, $config);
  3001. $this->process = new ProcessExecutor($io);
  3002. $io->write('Checking platform settings: ', false);
  3003. $this->outputResult($this->checkPlatform());
  3004. $io->write('Checking git settings: ', false);
  3005. $this->outputResult($this->checkGit());
  3006. $io->write('Checking http connectivity to packagist: ', false);
  3007. $this->outputResult($this->checkHttp('http', $config));
  3008. $io->write('Checking https connectivity to packagist: ', false);
  3009. $this->outputResult($this->checkHttp('https', $config));
  3010. $opts = stream_context_get_options(StreamContextFactory::getContext('http://example.org'));
  3011. if (!empty($opts['http']['proxy'])) {
  3012. $io->write('Checking HTTP proxy: ', false);
  3013. $this->outputResult($this->checkHttpProxy());
  3014. $io->write('Checking HTTP proxy support for request_fulluri: ', false);
  3015. $this->outputResult($this->checkHttpProxyFullUriRequestParam());
  3016. $io->write('Checking HTTPS proxy support for request_fulluri: ', false);
  3017. $this->outputResult($this->checkHttpsProxyFullUriRequestParam());
  3018. }
  3019. if ($oauth = $config->get('github-oauth')) {
  3020. foreach ($oauth as $domain => $token) {
  3021. $io->write('Checking '.$domain.' oauth access: ', false);
  3022. $this->outputResult($this->checkGithubOauth($domain, $token));
  3023. }
  3024. } else {
  3025. $io->write('Checking github.com rate limit: ', false);
  3026. try {
  3027. $rate = $this->getGithubRateLimit('github.com');
  3028. if (!is_array($rate)) {
  3029. $this->outputResult($rate);
  3030. } elseif (10 > $rate['remaining']) {
  3031. $io->write('<warning>WARNING</warning>');
  3032. $io->write(sprintf(
  3033. '<comment>Github has a rate limit on their API. '
  3034. . 'You currently have <options=bold>%u</options=bold> '
  3035. . 'out of <options=bold>%u</options=bold> requests left.' . PHP_EOL
  3036. . 'See https://developer.github.com/v3/#rate-limiting and also' . PHP_EOL
  3037. . ' https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens</comment>',
  3038. $rate['remaining'],
  3039. $rate['limit']
  3040. ));
  3041. } else {
  3042. $this->outputResult(true);
  3043. }
  3044. } catch (\Exception $e) {
  3045. if ($e instanceof TransportException && $e->getCode() === 401) {
  3046. $this->outputResult('<comment>The oauth token for github.com seems invalid, run "composer config --global --unset github-oauth.github.com" to remove it</comment>');
  3047. } else {
  3048. $this->outputResult($e);
  3049. }
  3050. }
  3051. }
  3052. $io->write('Checking disk free space: ', false);
  3053. $this->outputResult($this->checkDiskSpace($config));
  3054. if (strpos(__FILE__, 'phar:') === 0) {
  3055. $io->write('Checking pubkeys: ', false);
  3056. $this->outputResult($this->checkPubKeys($config));
  3057. $io->write('Checking composer version: ', false);
  3058. $this->outputResult($this->checkVersion($config));
  3059. }
  3060. $io->write(sprintf('Composer version: <comment>%s</comment>', Composer::getVersion()));
  3061. $platformOverrides = $config->get('platform') ?: array();
  3062. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  3063. $phpPkg = $platformRepo->findPackage('php', '*');
  3064. $phpVersion = $phpPkg->getPrettyVersion();
  3065. if (false !== strpos($phpPkg->getDescription(), 'overridden')) {
  3066. $phpVersion .= ' - ' . $phpPkg->getDescription();
  3067. }
  3068. $io->write(sprintf('PHP version: <comment>%s</comment>', $phpVersion));
  3069. if (defined('PHP_BINARY')) {
  3070. $io->write(sprintf('PHP binary path: <comment>%s</comment>', PHP_BINARY));
  3071. }
  3072. $io->write('OpenSSL version: ' . (defined('OPENSSL_VERSION_TEXT') ? '<comment>'.OPENSSL_VERSION_TEXT.'</comment>' : '<error>missing</error>'));
  3073. $io->write('cURL version: ' . $this->getCurlVersion());
  3074. $io->write('zip extension: ' . (extension_loaded('zip') ? '<info>OK</info>' : '<info>not loaded</info>'));
  3075. return $this->exitCode;
  3076. }
  3077. private function checkComposerSchema()
  3078. {
  3079. $validator = new ConfigValidator($this->getIO());
  3080. list($errors, , $warnings) = $validator->validate(Factory::getComposerFile());
  3081. if ($errors || $warnings) {
  3082. $messages = array(
  3083. 'error' => $errors,
  3084. 'warning' => $warnings,
  3085. );
  3086. $output = '';
  3087. foreach ($messages as $style => $msgs) {
  3088. foreach ($msgs as $msg) {
  3089. $output .= '<' . $style . '>' . $msg . '</' . $style . '>' . PHP_EOL;
  3090. }
  3091. }
  3092. return rtrim($output);
  3093. }
  3094. return true;
  3095. }
  3096. private function checkGit()
  3097. {
  3098. $this->process->execute('git config color.ui', $output);
  3099. if (strtolower(trim($output)) === 'always') {
  3100. 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>';
  3101. }
  3102. return true;
  3103. }
  3104. private function checkHttp($proto, Config $config)
  3105. {
  3106. $result = $this->checkConnectivity();
  3107. if ($result !== true) {
  3108. return $result;
  3109. }
  3110. $disableTls = false;
  3111. $result = array();
  3112. if ($proto === 'https' && $config->get('disable-tls') === true) {
  3113. $disableTls = true;
  3114. $result[] = '<warning>Composer is configured to disable SSL/TLS protection. This will leave remote HTTPS requests vulnerable to Man-In-The-Middle attacks.</warning>';
  3115. }
  3116. if ($proto === 'https' && !extension_loaded('openssl') && !$disableTls) {
  3117. $result[] = '<error>Composer is configured to use SSL/TLS protection but the openssl extension is not available.</error>';
  3118. }
  3119. try {
  3120. $this->httpDownloader->get($proto . '://repo.packagist.org/packages.json');
  3121. } catch (TransportException $e) {
  3122. if (false !== strpos($e->getMessage(), 'cafile')) {
  3123. $result[] = '<error>[' . get_class($e) . '] ' . $e->getMessage() . '</error>';
  3124. $result[] = '<error>Unable to locate a valid CA certificate file. You must set a valid \'cafile\' option.</error>';
  3125. $result[] = '<error>You can alternatively disable this error, at your own risk, by enabling the \'disable-tls\' option.</error>';
  3126. } else {
  3127. array_unshift($result, '[' . get_class($e) . '] ' . $e->getMessage());
  3128. }
  3129. }
  3130. if (count($result) > 0) {
  3131. return $result;
  3132. }
  3133. return true;
  3134. }
  3135. private function checkHttpProxy()
  3136. {
  3137. $result = $this->checkConnectivity();
  3138. if ($result !== true) {
  3139. return $result;
  3140. }
  3141. $protocol = extension_loaded('openssl') ? 'https' : 'http';
  3142. try {
  3143. $json = $this->httpDownloader->get($protocol . '://repo.packagist.org/packages.json')->decodeJson();
  3144. $hash = reset($json['provider-includes']);
  3145. $hash = $hash['sha256'];
  3146. $path = str_replace('%hash%', $hash, key($json['provider-includes']));
  3147. $provider = $this->httpDownloader->get($protocol . '://repo.packagist.org/'.$path)->getBody();
  3148. if (hash('sha256', $provider) !== $hash) {
  3149. return 'It seems that your proxy is modifying http traffic on the fly';
  3150. }
  3151. } catch (\Exception $e) {
  3152. return $e;
  3153. }
  3154. return true;
  3155. }
  3156. private function checkHttpProxyFullUriRequestParam()
  3157. {
  3158. $result = $this->checkConnectivity();
  3159. if ($result !== true) {
  3160. return $result;
  3161. }
  3162. $url = 'http://repo.packagist.org/packages.json';
  3163. try {
  3164. $this->httpDownloader->get($url);
  3165. } catch (TransportException $e) {
  3166. try {
  3167. $this->httpDownloader->get($url, array('http' => array('request_fulluri' => false)));
  3168. } catch (TransportException $e) {
  3169. return 'Unable to assess the situation, maybe packagist.org is down ('.$e->getMessage().')';
  3170. }
  3171. return 'It seems there is a problem with your proxy server, try setting the "HTTP_PROXY_REQUEST_FULLURI" and "HTTPS_PROXY_REQUEST_FULLURI" environment variables to "false"';
  3172. }
  3173. return true;
  3174. }
  3175. private function checkHttpsProxyFullUriRequestParam()
  3176. {
  3177. $result = $this->checkConnectivity();
  3178. if ($result !== true) {
  3179. return $result;
  3180. }
  3181. if (!extension_loaded('openssl')) {
  3182. return 'You need the openssl extension installed for this check';
  3183. }
  3184. $url = 'https://api.github.com/repos/Seldaek/jsonlint/zipball/1.0.0';
  3185. try {
  3186. $this->httpDownloader->get($url);
  3187. } catch (TransportException $e) {
  3188. try {
  3189. $this->httpDownloader->get($url, array('http' => array('request_fulluri' => false)));
  3190. } catch (TransportException $e) {
  3191. return 'Unable to assess the situation, maybe github is down ('.$e->getMessage().')';
  3192. }
  3193. return 'It seems there is a problem with your proxy server, try setting the "HTTPS_PROXY_REQUEST_FULLURI" environment variable to "false"';
  3194. }
  3195. return true;
  3196. }
  3197. private function checkGithubOauth($domain, $token)
  3198. {
  3199. $result = $this->checkConnectivity();
  3200. if ($result !== true) {
  3201. return $result;
  3202. }
  3203. $this->getIO()->setAuthentication($domain, $token, 'x-oauth-basic');
  3204. try {
  3205. $url = $domain === 'github.com' ? 'https://api.'.$domain.'/' : 'https://'.$domain.'/api/v3/';
  3206. return $this->httpDownloader->get($url, array(
  3207. 'retry-auth-failure' => false,
  3208. )) ? true : 'Unexpected error';
  3209. } catch (\Exception $e) {
  3210. if ($e instanceof TransportException && $e->getCode() === 401) {
  3211. return '<comment>The oauth token for '.$domain.' seems invalid, run "composer config --global --unset github-oauth.'.$domain.'" to remove it</comment>';
  3212. }
  3213. return $e;
  3214. }
  3215. }
  3216. private function getGithubRateLimit($domain, $token = null)
  3217. {
  3218. $result = $this->checkConnectivity();
  3219. if ($result !== true) {
  3220. return $result;
  3221. }
  3222. if ($token) {
  3223. $this->getIO()->setAuthentication($domain, $token, 'x-oauth-basic');
  3224. }
  3225. $url = $domain === 'github.com' ? 'https://api.'.$domain.'/rate_limit' : 'https://'.$domain.'/api/rate_limit';
  3226. $data = $this->httpDownloader->get($url, array('retry-auth-failure' => false))->decodeJson();
  3227. return $data['resources']['core'];
  3228. }
  3229. private function checkDiskSpace($config)
  3230. {
  3231. $minSpaceFree = 1024 * 1024;
  3232. if ((($df = @disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree)
  3233. || (($df = @disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)
  3234. ) {
  3235. return '<error>The disk hosting '.$dir.' is full</error>';
  3236. }
  3237. return true;
  3238. }
  3239. private function checkPubKeys($config)
  3240. {
  3241. $home = $config->get('home');
  3242. $errors = array();
  3243. $io = $this->getIO();
  3244. if (file_exists($home.'/keys.tags.pub') && file_exists($home.'/keys.dev.pub')) {
  3245. $io->write('');
  3246. }
  3247. if (file_exists($home.'/keys.tags.pub')) {
  3248. $io->write('Tags Public Key Fingerprint: ' . Keys::fingerprint($home.'/keys.tags.pub'));
  3249. } else {
  3250. $errors[] = '<error>Missing pubkey for tags verification</error>';
  3251. }
  3252. if (file_exists($home.'/keys.dev.pub')) {
  3253. $io->write('Dev Public Key Fingerprint: ' . Keys::fingerprint($home.'/keys.dev.pub'));
  3254. } else {
  3255. $errors[] = '<error>Missing pubkey for dev verification</error>';
  3256. }
  3257. if ($errors) {
  3258. $errors[] = '<error>Run composer self-update --update-keys to set them up</error>';
  3259. }
  3260. return $errors ?: true;
  3261. }
  3262. private function checkVersion($config)
  3263. {
  3264. $result = $this->checkConnectivity();
  3265. if ($result !== true) {
  3266. return $result;
  3267. }
  3268. $versionsUtil = new Versions($config, $this->httpDownloader);
  3269. try {
  3270. $latest = $versionsUtil->getLatest();
  3271. } catch (\Exception $e) {
  3272. return $e;
  3273. }
  3274. if (Composer::VERSION !== $latest['version'] && Composer::VERSION !== '@package_version@') {
  3275. return '<comment>You are not running the latest '.$versionsUtil->getChannel().' version, run `composer self-update` to update ('.Composer::VERSION.' => '.$latest['version'].')</comment>';
  3276. }
  3277. return true;
  3278. }
  3279. private function getCurlVersion()
  3280. {
  3281. if (function_exists('curl_version')) {
  3282. $version = curl_version();
  3283. return '<comment>'.$version['version'].'</comment> '.
  3284. 'libz <comment>'.(isset($version['libz_version']) ? $version['libz_version'] : 'missing').'</comment> '.
  3285. 'ssl <comment>'.(isset($version['ssl_version']) ? $version['ssl_version'] : 'missing').'</comment>';
  3286. }
  3287. return '<error>missing, using php streams fallback, which reduces performance</error>';
  3288. }
  3289. private function outputResult($result)
  3290. {
  3291. $io = $this->getIO();
  3292. if (true === $result) {
  3293. $io->write('<info>OK</info>');
  3294. return;
  3295. }
  3296. $hadError = false;
  3297. $hadWarning = false;
  3298. if ($result instanceof \Exception) {
  3299. $result = '<error>['.get_class($result).'] '.$result->getMessage().'</error>';
  3300. }
  3301. if (!$result) {
  3302. $hadError = true;
  3303. } else {
  3304. if (!is_array($result)) {
  3305. $result = array($result);
  3306. }
  3307. foreach ($result as $message) {
  3308. if (false !== strpos($message, '<error>')) {
  3309. $hadError = true;
  3310. } elseif (false !== strpos($message, '<warning>')) {
  3311. $hadWarning = true;
  3312. }
  3313. }
  3314. }
  3315. if ($hadError) {
  3316. $io->write('<error>FAIL</error>');
  3317. $this->exitCode = max($this->exitCode, 2);
  3318. } elseif ($hadWarning) {
  3319. $io->write('<warning>WARNING</warning>');
  3320. $this->exitCode = max($this->exitCode, 1);
  3321. }
  3322. if ($result) {
  3323. foreach ($result as $message) {
  3324. $io->write($message);
  3325. }
  3326. }
  3327. }
  3328. private function checkPlatform()
  3329. {
  3330. $output = '';
  3331. $out = function ($msg, $style) use (&$output) {
  3332. $output .= '<'.$style.'>'.$msg.'</'.$style.'>'.PHP_EOL;
  3333. };
  3334. $errors = array();
  3335. $warnings = array();
  3336. $displayIniMessage = false;
  3337. $iniMessage = PHP_EOL.PHP_EOL.IniHelper::getMessage();
  3338. $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.';
  3339. if (!function_exists('json_decode')) {
  3340. $errors['json'] = true;
  3341. }
  3342. if (!extension_loaded('Phar')) {
  3343. $errors['phar'] = true;
  3344. }
  3345. if (!extension_loaded('filter')) {
  3346. $errors['filter'] = true;
  3347. }
  3348. if (!extension_loaded('hash')) {
  3349. $errors['hash'] = true;
  3350. }
  3351. if (!extension_loaded('iconv') && !extension_loaded('mbstring')) {
  3352. $errors['iconv_mbstring'] = true;
  3353. }
  3354. if (!filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN)) {
  3355. $errors['allow_url_fopen'] = true;
  3356. }
  3357. if (extension_loaded('ionCube Loader') && ioncube_loader_iversion() < 40009) {
  3358. $errors['ioncube'] = ioncube_loader_version();
  3359. }
  3360. if (PHP_VERSION_ID < 50302) {
  3361. $errors['php'] = PHP_VERSION;
  3362. }
  3363. if (!isset($errors['php']) && PHP_VERSION_ID < 50304) {
  3364. $warnings['php'] = PHP_VERSION;
  3365. }
  3366. if (!extension_loaded('openssl')) {
  3367. $errors['openssl'] = true;
  3368. }
  3369. if (extension_loaded('openssl') && OPENSSL_VERSION_NUMBER < 0x1000100f) {
  3370. $warnings['openssl_version'] = true;
  3371. }
  3372. if (!defined('HHVM_VERSION') && !extension_loaded('apcu') && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
  3373. $warnings['apc_cli'] = true;
  3374. }
  3375. if (!extension_loaded('zlib')) {
  3376. $warnings['zlib'] = true;
  3377. }
  3378. ob_start();
  3379. phpinfo(INFO_GENERAL);
  3380. $phpinfo = ob_get_clean();
  3381. if (preg_match('{Configure Command(?: *</td><td class="v">| *=> *)(.*?)(?:</td>|$)}m', $phpinfo, $match)) {
  3382. $configure = $match[1];
  3383. if (false !== strpos($configure, '--enable-sigchild')) {
  3384. $warnings['sigchild'] = true;
  3385. }
  3386. if (false !== strpos($configure, '--with-curlwrappers')) {
  3387. $warnings['curlwrappers'] = true;
  3388. }
  3389. }
  3390. if (filter_var(ini_get('xdebug.profiler_enabled'), FILTER_VALIDATE_BOOLEAN)) {
  3391. $warnings['xdebug_profile'] = true;
  3392. } elseif (extension_loaded('xdebug')) {
  3393. $warnings['xdebug_loaded'] = true;
  3394. }
  3395. if (defined('PHP_WINDOWS_VERSION_BUILD')
  3396. && (version_compare(PHP_VERSION, '7.2.23', '<')
  3397. || (version_compare(PHP_VERSION, '7.3.0', '>=')
  3398. && version_compare(PHP_VERSION, '7.3.10', '<')))) {
  3399. $warnings['onedrive'] = PHP_VERSION;
  3400. }
  3401. if (!empty($errors)) {
  3402. foreach ($errors as $error => $current) {
  3403. switch ($error) {
  3404. case 'json':
  3405. $text = PHP_EOL."The json extension is missing.".PHP_EOL;
  3406. $text .= "Install it or recompile php without --disable-json";
  3407. break;
  3408. case 'phar':
  3409. $text = PHP_EOL."The phar extension is missing.".PHP_EOL;
  3410. $text .= "Install it or recompile php without --disable-phar";
  3411. break;
  3412. case 'filter':
  3413. $text = PHP_EOL."The filter extension is missing.".PHP_EOL;
  3414. $text .= "Install it or recompile php without --disable-filter";
  3415. break;
  3416. case 'hash':
  3417. $text = PHP_EOL."The hash extension is missing.".PHP_EOL;
  3418. $text .= "Install it or recompile php without --disable-hash";
  3419. break;
  3420. case 'iconv_mbstring':
  3421. $text = PHP_EOL."The iconv OR mbstring extension is required and both are missing.".PHP_EOL;
  3422. $text .= "Install either of them or recompile php without --disable-iconv";
  3423. break;
  3424. case 'php':
  3425. $text = PHP_EOL."Your PHP ({$current}) is too old, you must upgrade to PHP 5.3.2 or higher.";
  3426. break;
  3427. case 'allow_url_fopen':
  3428. $text = PHP_EOL."The allow_url_fopen setting is incorrect.".PHP_EOL;
  3429. $text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
  3430. $text .= " allow_url_fopen = On";
  3431. $displayIniMessage = true;
  3432. break;
  3433. case 'ioncube':
  3434. $text = PHP_EOL."Your ionCube Loader extension ($current) is incompatible with Phar files.".PHP_EOL;
  3435. $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;
  3436. $text .= " zend_extension = /usr/lib/php5/20090626+lfs/ioncube_loader_lin_5.3.so";
  3437. $displayIniMessage = true;
  3438. break;
  3439. case 'openssl':
  3440. $text = PHP_EOL."The openssl extension is missing, which means that secure HTTPS transfers are impossible.".PHP_EOL;
  3441. $text .= "If possible you should enable it or recompile php with --with-openssl";
  3442. break;
  3443. default:
  3444. throw new \InvalidArgumentException(sprintf("DiagnoseCommand: Unknown error type \"%s\". Please report at https://github.com/composer/composer/issues/new.", $error));
  3445. }
  3446. $out($text, 'error');
  3447. }
  3448. $output .= PHP_EOL;
  3449. }
  3450. if (!empty($warnings)) {
  3451. foreach ($warnings as $warning => $current) {
  3452. switch ($warning) {
  3453. case 'apc_cli':
  3454. $text = "The apc.enable_cli setting is incorrect.".PHP_EOL;
  3455. $text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
  3456. $text .= " apc.enable_cli = Off";
  3457. $displayIniMessage = true;
  3458. break;
  3459. case 'zlib':
  3460. $text = 'The zlib extension is not loaded, this can slow down Composer a lot.'.PHP_EOL;
  3461. $text .= 'If possible, enable it or recompile php with --with-zlib'.PHP_EOL;
  3462. $displayIniMessage = true;
  3463. break;
  3464. case 'sigchild':
  3465. $text = "PHP was compiled with --enable-sigchild which can cause issues on some platforms.".PHP_EOL;
  3466. $text .= "Recompile it without this flag if possible, see also:".PHP_EOL;
  3467. $text .= " https://bugs.php.net/bug.php?id=22999";
  3468. break;
  3469. case 'curlwrappers':
  3470. $text = "PHP was compiled with --with-curlwrappers which will cause issues with HTTP authentication and GitHub.".PHP_EOL;
  3471. $text .= " Recompile it without this flag if possible";
  3472. break;
  3473. case 'php':
  3474. $text = "Your PHP ({$current}) is quite old, upgrading to PHP 5.3.4 or higher is recommended.".PHP_EOL;
  3475. $text .= " Composer works with 5.3.2+ for most people, but there might be edge case issues.";
  3476. break;
  3477. case 'openssl_version':
  3478. $opensslVersion = strstr(trim(strstr(OPENSSL_VERSION_TEXT, ' ')), ' ', true);
  3479. $opensslVersion = $opensslVersion ?: OPENSSL_VERSION_TEXT;
  3480. $text = "The OpenSSL library ({$opensslVersion}) used by PHP does not support TLSv1.2 or TLSv1.1.".PHP_EOL;
  3481. $text .= "If possible you should upgrade OpenSSL to version 1.0.1 or above.";
  3482. break;
  3483. case 'xdebug_loaded':
  3484. $text = "The xdebug extension is loaded, this can slow down Composer a little.".PHP_EOL;
  3485. $text .= " Disabling it when using Composer is recommended.";
  3486. break;
  3487. case 'xdebug_profile':
  3488. $text = "The xdebug.profiler_enabled setting is enabled, this can slow down Composer a lot.".PHP_EOL;
  3489. $text .= "Add the following to the end of your `php.ini` to disable it:".PHP_EOL;
  3490. $text .= " xdebug.profiler_enabled = 0";
  3491. $displayIniMessage = true;
  3492. break;
  3493. case 'onedrive':
  3494. $text = "The Windows OneDrive folder is not supported on PHP versions below 7.2.23 and 7.3.10.".PHP_EOL;
  3495. $text .= "Upgrade your PHP ({$current}) to use this location with Composer.".PHP_EOL;
  3496. break;
  3497. default:
  3498. throw new \InvalidArgumentException(sprintf("DiagnoseCommand: Unknown warning type \"%s\". Please report at https://github.com/composer/composer/issues/new.", $warning));
  3499. }
  3500. $out($text, 'comment');
  3501. }
  3502. }
  3503. if ($displayIniMessage) {
  3504. $out($iniMessage, 'comment');
  3505. }
  3506. return !$warnings && !$errors ? true : $output;
  3507. }
  3508. private function checkConnectivity()
  3509. {
  3510. if (!ini_get('allow_url_fopen')) {
  3511. return '<info>Skipped because allow_url_fopen is missing.</info>';
  3512. }
  3513. return true;
  3514. }
  3515. }
  3516. <?php
  3517. namespace Composer\Command;
  3518. use Composer\Plugin\CommandEvent;
  3519. use Composer\Plugin\PluginEvents;
  3520. use Symfony\Component\Console\Input\InputInterface;
  3521. use Symfony\Component\Console\Input\InputOption;
  3522. use Symfony\Component\Console\Output\OutputInterface;
  3523. class DumpAutoloadCommand extends BaseCommand
  3524. {
  3525. protected function configure()
  3526. {
  3527. $this
  3528. ->setName('dump-autoload')
  3529. ->setAliases(array('dumpautoload'))
  3530. ->setDescription('Dumps the autoloader.')
  3531. ->setDefinition(array(
  3532. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  3533. new InputOption('optimize', 'o', InputOption::VALUE_NONE, 'Optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production.'),
  3534. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize`.'),
  3535. new InputOption('apcu', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  3536. new InputOption('apcu-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu'),
  3537. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables autoload-dev rules.'),
  3538. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  3539. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  3540. ))
  3541. ->setHelp(
  3542. <<<EOT
  3543. <info>php composer.phar dump-autoload</info>
  3544. Read more at https://getcomposer.org/doc/03-cli.md#dump-autoload-dumpautoload-
  3545. EOT
  3546. )
  3547. ;
  3548. }
  3549. protected function execute(InputInterface $input, OutputInterface $output)
  3550. {
  3551. $composer = $this->getComposer();
  3552. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'dump-autoload', $input, $output);
  3553. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  3554. $installationManager = $composer->getInstallationManager();
  3555. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  3556. $package = $composer->getPackage();
  3557. $config = $composer->getConfig();
  3558. $optimize = $input->getOption('optimize') || $config->get('optimize-autoloader');
  3559. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  3560. $apcuPrefix = $input->getOption('apcu-prefix');
  3561. $apcu = $apcuPrefix !== null || $input->getOption('apcu') || $config->get('apcu-autoloader');
  3562. if ($authoritative) {
  3563. $this->getIO()->write('<info>Generating optimized autoload files (authoritative)</info>');
  3564. } elseif ($optimize) {
  3565. $this->getIO()->write('<info>Generating optimized autoload files</info>');
  3566. } else {
  3567. $this->getIO()->write('<info>Generating autoload files</info>');
  3568. }
  3569. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  3570. $generator = $composer->getAutoloadGenerator();
  3571. $generator->setDevMode(!$input->getOption('no-dev'));
  3572. $generator->setClassMapAuthoritative($authoritative);
  3573. $generator->setApcu($apcu, $apcuPrefix);
  3574. $generator->setRunScripts(!$input->getOption('no-scripts'));
  3575. $generator->setIgnorePlatformRequirements($ignorePlatformReqs);
  3576. $numberOfClasses = $generator->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize);
  3577. if ($authoritative) {
  3578. $this->getIO()->write('<info>Generated optimized autoload files (authoritative) containing '. $numberOfClasses .' classes</info>');
  3579. } elseif ($optimize) {
  3580. $this->getIO()->write('<info>Generated optimized autoload files containing '. $numberOfClasses .' classes</info>');
  3581. } else {
  3582. $this->getIO()->write('<info>Generated autoload files</info>');
  3583. }
  3584. return 0;
  3585. }
  3586. }
  3587. <?php
  3588. namespace Composer\Command;
  3589. use Symfony\Component\Console\Input\InputInterface;
  3590. use Symfony\Component\Console\Input\InputOption;
  3591. use Symfony\Component\Console\Output\OutputInterface;
  3592. use Symfony\Component\Console\Input\InputArgument;
  3593. class ExecCommand extends BaseCommand
  3594. {
  3595. protected function configure()
  3596. {
  3597. $this
  3598. ->setName('exec')
  3599. ->setDescription('Executes a vendored binary/script.')
  3600. ->setDefinition(array(
  3601. new InputOption('list', 'l', InputOption::VALUE_NONE),
  3602. new InputArgument('binary', InputArgument::OPTIONAL, 'The binary to run, e.g. phpunit'),
  3603. new InputArgument(
  3604. 'args',
  3605. InputArgument::IS_ARRAY | InputArgument::OPTIONAL,
  3606. 'Arguments to pass to the binary. Use <info>--</info> to separate from composer arguments'
  3607. ),
  3608. ))
  3609. ->setHelp(
  3610. <<<EOT
  3611. Executes a vendored binary/script.
  3612. Read more at https://getcomposer.org/doc/03-cli.md#exec
  3613. EOT
  3614. )
  3615. ;
  3616. }
  3617. protected function execute(InputInterface $input, OutputInterface $output)
  3618. {
  3619. $composer = $this->getComposer();
  3620. $binDir = $composer->getConfig()->get('bin-dir');
  3621. if ($input->getOption('list') || !$input->getArgument('binary')) {
  3622. $bins = glob($binDir . '/*');
  3623. $bins = array_merge($bins, array_map(function ($e) {
  3624. return "$e (local)";
  3625. }, $composer->getPackage()->getBinaries()));
  3626. if (!$bins) {
  3627. throw new \RuntimeException("No binaries found in composer.json or in bin-dir ($binDir)");
  3628. }
  3629. $this->getIO()->write(
  3630. <<<EOT
  3631. <comment>Available binaries:</comment>
  3632. EOT
  3633. );
  3634. foreach ($bins as $bin) {
  3635. if (isset($previousBin) && $bin === $previousBin.'.bat') {
  3636. continue;
  3637. }
  3638. $previousBin = $bin;
  3639. $bin = basename($bin);
  3640. $this->getIO()->write(
  3641. <<<EOT
  3642. <info>- $bin</info>
  3643. EOT
  3644. );
  3645. }
  3646. return 0;
  3647. }
  3648. $binary = $input->getArgument('binary');
  3649. $dispatcher = $composer->getEventDispatcher();
  3650. $dispatcher->addListener('__exec_command', $binary);
  3651. if ($output->getVerbosity() === OutputInterface::VERBOSITY_NORMAL) {
  3652. $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
  3653. }
  3654. if (getcwd() !== $this->getApplication()->getInitialWorkingDirectory()) {
  3655. try {
  3656. chdir($this->getApplication()->getInitialWorkingDirectory());
  3657. } catch (\Exception $e) {
  3658. throw new \RuntimeException('Could not switch back to working directory "'.$this->getApplication()->getInitialWorkingDirectory().'"', 0, $e);
  3659. }
  3660. }
  3661. return $dispatcher->dispatchScript('__exec_command', true, $input->getArgument('args'));
  3662. }
  3663. }
  3664. <?php
  3665. namespace Composer\Command;
  3666. use Composer\Package\CompletePackageInterface;
  3667. use Composer\Package\AliasPackage;
  3668. use Composer\Package\BasePackage;
  3669. use Composer\Semver\Constraint\MatchAllConstraint;
  3670. use Composer\Repository\CompositeRepository;
  3671. use Symfony\Component\Console\Input\InputInterface;
  3672. use Symfony\Component\Console\Input\InputOption;
  3673. use Symfony\Component\Console\Output\OutputInterface;
  3674. class FundCommand extends BaseCommand
  3675. {
  3676. protected function configure()
  3677. {
  3678. $this->setName('fund')
  3679. ->setDescription('Discover how to help fund the maintenance of your dependencies.')
  3680. ;
  3681. }
  3682. protected function execute(InputInterface $input, OutputInterface $output)
  3683. {
  3684. $composer = $this->getComposer();
  3685. $repo = $composer->getRepositoryManager()->getLocalRepository();
  3686. $remoteRepos = new CompositeRepository($composer->getRepositoryManager()->getRepositories());
  3687. $fundings = array();
  3688. $packagesToLoad = array();
  3689. foreach ($repo->getPackages() as $package) {
  3690. if ($package instanceof AliasPackage) {
  3691. continue;
  3692. }
  3693. $packagesToLoad[$package->getName()] = new MatchAllConstraint();
  3694. }
  3695. $result = $remoteRepos->loadPackages($packagesToLoad, array('dev' => BasePackage::STABILITY_DEV), array());
  3696. foreach ($result['packages'] as $package) {
  3697. if (
  3698. !$package instanceof AliasPackage
  3699. && $package instanceof CompletePackageInterface
  3700. && $package->isDefaultBranch()
  3701. && $package->getFunding()
  3702. && isset($packagesToLoad[$package->getName()])
  3703. ) {
  3704. $fundings = $this->insertFundingData($fundings, $package);
  3705. unset($packagesToLoad[$package->getName()]);
  3706. }
  3707. }
  3708. foreach ($repo->getPackages() as $package) {
  3709. if ($package instanceof AliasPackage || !isset($packagesToLoad[$package->getName()])) {
  3710. continue;
  3711. }
  3712. if ($package instanceof CompletePackageInterface && $package->getFunding()) {
  3713. $fundings = $this->insertFundingData($fundings, $package);
  3714. }
  3715. }
  3716. ksort($fundings);
  3717. $io = $this->getIO();
  3718. if ($fundings) {
  3719. $prev = null;
  3720. $io->write('The following packages were found in your dependencies which publish funding information:');
  3721. foreach ($fundings as $vendor => $links) {
  3722. $io->write('');
  3723. $io->write(sprintf("<comment>%s</comment>", $vendor));
  3724. foreach ($links as $url => $packages) {
  3725. $line = sprintf(' <info>%s</info>', implode(', ', $packages));
  3726. if ($prev !== $line) {
  3727. $io->write($line);
  3728. $prev = $line;
  3729. }
  3730. $io->write(sprintf(' %s', $url));
  3731. }
  3732. }
  3733. $io->write("");
  3734. $io->write("Please consider following these links and sponsoring the work of package authors!");
  3735. $io->write("Thank you!");
  3736. } else {
  3737. $io->write("No funding links were found in your package dependencies. This doesn't mean they don't need your support!");
  3738. }
  3739. return 0;
  3740. }
  3741. private function insertFundingData(array $fundings, CompletePackageInterface $package)
  3742. {
  3743. foreach ($package->getFunding() as $fundingOption) {
  3744. list($vendor, $packageName) = explode('/', $package->getPrettyName());
  3745. if (empty($fundingOption['url'])) {
  3746. continue;
  3747. }
  3748. $url = $fundingOption['url'];
  3749. if (!empty($fundingOption['type']) && $fundingOption['type'] === 'github' && preg_match('{^https://github.com/([^/]+)$}', $url, $match)) {
  3750. $url = 'https://github.com/sponsors/'.$match[1];
  3751. }
  3752. $fundings[$vendor][$url][] = $packageName;
  3753. }
  3754. return $fundings;
  3755. }
  3756. }
  3757. <?php
  3758. namespace Composer\Command;
  3759. use Composer\Factory;
  3760. use Composer\Util\Filesystem;
  3761. use Symfony\Component\Console\Input\InputInterface;
  3762. use Symfony\Component\Console\Input\InputArgument;
  3763. use Symfony\Component\Console\Input\StringInput;
  3764. use Symfony\Component\Console\Output\OutputInterface;
  3765. class GlobalCommand extends BaseCommand
  3766. {
  3767. protected function configure()
  3768. {
  3769. $this
  3770. ->setName('global')
  3771. ->setDescription('Allows running commands in the global composer dir ($COMPOSER_HOME).')
  3772. ->setDefinition(array(
  3773. new InputArgument('command-name', InputArgument::REQUIRED, ''),
  3774. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  3775. ))
  3776. ->setHelp(
  3777. <<<EOT
  3778. Use this command as a wrapper to run other Composer commands
  3779. within the global context of COMPOSER_HOME.
  3780. You can use this to install CLI utilities globally, all you need
  3781. is to add the COMPOSER_HOME/vendor/bin dir to your PATH env var.
  3782. COMPOSER_HOME is c:\Users\<user>\AppData\Roaming\Composer on Windows
  3783. and /home/<user>/.composer on unix systems.
  3784. If your system uses freedesktop.org standards, then it will first check
  3785. XDG_CONFIG_HOME or default to /home/<user>/.config/composer
  3786. Note: This path may vary depending on customizations to bin-dir in
  3787. composer.json or the environmental variable COMPOSER_BIN_DIR.
  3788. Read more at https://getcomposer.org/doc/03-cli.md#global
  3789. EOT
  3790. )
  3791. ;
  3792. }
  3793. public function run(InputInterface $input, OutputInterface $output)
  3794. {
  3795. $tokens = preg_split('{\s+}', $input->__toString());
  3796. $args = array();
  3797. foreach ($tokens as $token) {
  3798. if ($token && $token[0] !== '-') {
  3799. $args[] = $token;
  3800. if (count($args) >= 2) {
  3801. break;
  3802. }
  3803. }
  3804. }
  3805. if (count($args) < 2) {
  3806. return parent::run($input, $output);
  3807. }
  3808. if (getenv('COMPOSER')) {
  3809. putenv('COMPOSER');
  3810. unset($_SERVER['COMPOSER']);
  3811. }
  3812. $config = Factory::createConfig();
  3813. $home = $config->get('home');
  3814. if (!is_dir($home)) {
  3815. $fs = new Filesystem();
  3816. $fs->ensureDirectoryExists($home);
  3817. if (!is_dir($home)) {
  3818. throw new \RuntimeException('Could not create home directory');
  3819. }
  3820. }
  3821. try {
  3822. chdir($home);
  3823. } catch (\Exception $e) {
  3824. throw new \RuntimeException('Could not switch to home directory "'.$home.'"', 0, $e);
  3825. }
  3826. $this->getIO()->writeError('<info>Changed current directory to '.$home.'</info>');
  3827. $input = new StringInput(preg_replace('{\bg(?:l(?:o(?:b(?:a(?:l)?)?)?)?)?\b}', '', $input->__toString(), 1));
  3828. $this->getApplication()->resetComposer();
  3829. return $this->getApplication()->run($input, $output);
  3830. }
  3831. public function isProxyCommand()
  3832. {
  3833. return true;
  3834. }
  3835. }
  3836. <?php
  3837. namespace Composer\Command;
  3838. use Composer\Package\CompletePackageInterface;
  3839. use Composer\Repository\RepositoryInterface;
  3840. use Composer\Repository\RootPackageRepository;
  3841. use Composer\Repository\RepositoryFactory;
  3842. use Composer\Util\Platform;
  3843. use Composer\Util\ProcessExecutor;
  3844. use Symfony\Component\Console\Input\InputArgument;
  3845. use Symfony\Component\Console\Input\InputOption;
  3846. use Symfony\Component\Console\Input\InputInterface;
  3847. use Symfony\Component\Console\Output\OutputInterface;
  3848. class HomeCommand extends BaseCommand
  3849. {
  3850. protected function configure()
  3851. {
  3852. $this
  3853. ->setName('browse')
  3854. ->setAliases(array('home'))
  3855. ->setDescription('Opens the package\'s repository URL or homepage in your browser.')
  3856. ->setDefinition(array(
  3857. new InputArgument('packages', InputArgument::IS_ARRAY, 'Package(s) to browse to.'),
  3858. new InputOption('homepage', 'H', InputOption::VALUE_NONE, 'Open the homepage instead of the repository URL.'),
  3859. new InputOption('show', 's', InputOption::VALUE_NONE, 'Only show the homepage or repository URL.'),
  3860. ))
  3861. ->setHelp(
  3862. <<<EOT
  3863. The home command opens or shows a package's repository URL or
  3864. homepage in your default browser.
  3865. To open the homepage by default, use -H or --homepage.
  3866. To show instead of open the repository or homepage URL, use -s or --show.
  3867. Read more at https://getcomposer.org/doc/03-cli.md#browse-home
  3868. EOT
  3869. );
  3870. }
  3871. protected function execute(InputInterface $input, OutputInterface $output)
  3872. {
  3873. $repos = $this->initializeRepos();
  3874. $io = $this->getIO();
  3875. $return = 0;
  3876. $packages = $input->getArgument('packages');
  3877. if (!$packages) {
  3878. $io->writeError('No package specified, opening homepage for the root package');
  3879. $packages = array($this->getComposer()->getPackage()->getName());
  3880. }
  3881. foreach ($packages as $packageName) {
  3882. $handled = false;
  3883. $packageExists = false;
  3884. foreach ($repos as $repo) {
  3885. foreach ($repo->findPackages($packageName) as $package) {
  3886. $packageExists = true;
  3887. if ($package instanceof CompletePackageInterface && $this->handlePackage($package, $input->getOption('homepage'), $input->getOption('show'))) {
  3888. $handled = true;
  3889. break 2;
  3890. }
  3891. }
  3892. }
  3893. if (!$packageExists) {
  3894. $return = 1;
  3895. $io->writeError('<warning>Package '.$packageName.' not found</warning>');
  3896. }
  3897. if (!$handled) {
  3898. $return = 1;
  3899. $io->writeError('<warning>'.($input->getOption('homepage') ? 'Invalid or missing homepage' : 'Invalid or missing repository URL').' for '.$packageName.'</warning>');
  3900. }
  3901. }
  3902. return $return;
  3903. }
  3904. private function handlePackage(CompletePackageInterface $package, $showHomepage, $showOnly)
  3905. {
  3906. $support = $package->getSupport();
  3907. $url = isset($support['source']) ? $support['source'] : $package->getSourceUrl();
  3908. if (!$url || $showHomepage) {
  3909. $url = $package->getHomepage();
  3910. }
  3911. if (!$url || !filter_var($url, FILTER_VALIDATE_URL)) {
  3912. return false;
  3913. }
  3914. if ($showOnly) {
  3915. $this->getIO()->write(sprintf('<info>%s</info>', $url));
  3916. } else {
  3917. $this->openBrowser($url);
  3918. }
  3919. return true;
  3920. }
  3921. private function openBrowser($url)
  3922. {
  3923. $url = ProcessExecutor::escape($url);
  3924. $process = new ProcessExecutor($this->getIO());
  3925. if (Platform::isWindows()) {
  3926. return $process->execute('start "web" explorer "' . $url . '"', $output);
  3927. }
  3928. $linux = $process->execute('which xdg-open', $output);
  3929. $osx = $process->execute('which open', $output);
  3930. if (0 === $linux) {
  3931. $process->execute('xdg-open ' . $url, $output);
  3932. } elseif (0 === $osx) {
  3933. $process->execute('open ' . $url, $output);
  3934. } else {
  3935. $this->getIO()->writeError('No suitable browser opening command found, open yourself: ' . $url);
  3936. }
  3937. }
  3938. private function initializeRepos()
  3939. {
  3940. $composer = $this->getComposer(false);
  3941. if ($composer) {
  3942. return array_merge(
  3943. array(new RootPackageRepository($composer->getPackage())),
  3944. array($composer->getRepositoryManager()->getLocalRepository()),
  3945. $composer->getRepositoryManager()->getRepositories()
  3946. );
  3947. }
  3948. return RepositoryFactory::defaultRepos($this->getIO());
  3949. }
  3950. }
  3951. <?php
  3952. namespace Composer\Command;
  3953. use Composer\Factory;
  3954. use Composer\Json\JsonFile;
  3955. use Composer\Package\BasePackage;
  3956. use Composer\Package\Package;
  3957. use Composer\Package\Version\VersionParser;
  3958. use Composer\Package\Version\VersionSelector;
  3959. use Composer\Repository\CompositeRepository;
  3960. use Composer\Repository\PlatformRepository;
  3961. use Composer\Repository\RepositoryFactory;
  3962. use Composer\Repository\RepositorySet;
  3963. use Composer\Util\ProcessExecutor;
  3964. use Symfony\Component\Console\Input\ArrayInput;
  3965. use Symfony\Component\Console\Input\InputInterface;
  3966. use Symfony\Component\Console\Input\InputOption;
  3967. use Symfony\Component\Console\Output\OutputInterface;
  3968. use Symfony\Component\Process\ExecutableFinder;
  3969. use Symfony\Component\Process\Process;
  3970. class InitCommand extends BaseCommand
  3971. {
  3972. protected $repos;
  3973. private $gitConfig;
  3974. private $repositorySets;
  3975. protected function configure()
  3976. {
  3977. $this
  3978. ->setName('init')
  3979. ->setDescription('Creates a basic composer.json file in current directory.')
  3980. ->setDefinition(array(
  3981. new InputOption('name', null, InputOption::VALUE_REQUIRED, 'Name of the package'),
  3982. new InputOption('description', null, InputOption::VALUE_REQUIRED, 'Description of package'),
  3983. new InputOption('author', null, InputOption::VALUE_REQUIRED, 'Author name of package'),
  3984. new InputOption('type', null, InputOption::VALUE_OPTIONAL, 'Type of package (e.g. library, project, metapackage, composer-plugin)'),
  3985. new InputOption('homepage', null, InputOption::VALUE_REQUIRED, 'Homepage of package'),
  3986. 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"'),
  3987. 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"'),
  3988. new InputOption('stability', 's', InputOption::VALUE_REQUIRED, 'Minimum stability (empty or one of: '.implode(', ', array_keys(BasePackage::$stabilities)).')'),
  3989. new InputOption('license', 'l', InputOption::VALUE_REQUIRED, 'License of package'),
  3990. new InputOption('repository', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Add custom repositories, either by URL or using JSON arrays'),
  3991. ))
  3992. ->setHelp(
  3993. <<<EOT
  3994. The <info>init</info> command creates a basic composer.json file
  3995. in the current directory.
  3996. <info>php composer.phar init</info>
  3997. Read more at https://getcomposer.org/doc/03-cli.md#init
  3998. EOT
  3999. )
  4000. ;
  4001. }
  4002. protected function execute(InputInterface $input, OutputInterface $output)
  4003. {
  4004. $io = $this->getIO();
  4005. $allowlist = array('name', 'description', 'author', 'type', 'homepage', 'require', 'require-dev', 'stability', 'license');
  4006. $options = array_filter(array_intersect_key($input->getOptions(), array_flip($allowlist)));
  4007. if (isset($options['author'])) {
  4008. $options['authors'] = $this->formatAuthors($options['author']);
  4009. unset($options['author']);
  4010. }
  4011. $repositories = $input->getOption('repository');
  4012. if ($repositories) {
  4013. $config = Factory::createConfig($io);
  4014. foreach ($repositories as $repo) {
  4015. $options['repositories'][] = RepositoryFactory::configFromString($io, $config, $repo, true);
  4016. }
  4017. }
  4018. if (isset($options['stability'])) {
  4019. $options['minimum-stability'] = $options['stability'];
  4020. unset($options['stability']);
  4021. }
  4022. $options['require'] = isset($options['require']) ? $this->formatRequirements($options['require']) : new \stdClass;
  4023. if (array() === $options['require']) {
  4024. $options['require'] = new \stdClass;
  4025. }
  4026. if (isset($options['require-dev'])) {
  4027. $options['require-dev'] = $this->formatRequirements($options['require-dev']);
  4028. if (array() === $options['require-dev']) {
  4029. $options['require-dev'] = new \stdClass;
  4030. }
  4031. }
  4032. $file = new JsonFile(Factory::getComposerFile());
  4033. $json = JsonFile::encode($options);
  4034. if ($input->isInteractive()) {
  4035. $io->writeError(array('', $json, ''));
  4036. if (!$io->askConfirmation('Do you confirm generation [<comment>yes</comment>]? ')) {
  4037. $io->writeError('<error>Command aborted</error>');
  4038. return 1;
  4039. }
  4040. }
  4041. $file->write($options);
  4042. if ($input->isInteractive() && is_dir('.git')) {
  4043. $ignoreFile = realpath('.gitignore');
  4044. if (false === $ignoreFile) {
  4045. $ignoreFile = realpath('.') . '/.gitignore';
  4046. }
  4047. if (!$this->hasVendorIgnore($ignoreFile)) {
  4048. $question = 'Would you like the <info>vendor</info> directory added to your <info>.gitignore</info> [<comment>yes</comment>]? ';
  4049. if ($io->askConfirmation($question)) {
  4050. $this->addVendorIgnore($ignoreFile);
  4051. }
  4052. }
  4053. }
  4054. $question = 'Would you like to install dependencies now [<comment>yes</comment>]? ';
  4055. if ($input->isInteractive() && $this->hasDependencies($options) && $io->askConfirmation($question)) {
  4056. $this->installDependencies($output);
  4057. }
  4058. return 0;
  4059. }
  4060. protected function interact(InputInterface $input, OutputInterface $output)
  4061. {
  4062. $git = $this->getGitConfig();
  4063. $io = $this->getIO();
  4064. $formatter = $this->getHelperSet()->get('formatter');
  4065. $repositories = $input->getOption('repository');
  4066. if ($repositories) {
  4067. $config = Factory::createConfig($io);
  4068. $repos = array(new PlatformRepository);
  4069. $createDefaultPackagistRepo = true;
  4070. foreach ($repositories as $repo) {
  4071. $repoConfig = RepositoryFactory::configFromString($io, $config, $repo, true);
  4072. if (
  4073. (isset($repoConfig['packagist']) && $repoConfig === array('packagist' => false))
  4074. || (isset($repoConfig['packagist.org']) && $repoConfig === array('packagist.org' => false))
  4075. ) {
  4076. $createDefaultPackagistRepo = false;
  4077. continue;
  4078. }
  4079. $repos[] = RepositoryFactory::createRepo($io, $config, $repoConfig);
  4080. }
  4081. if ($createDefaultPackagistRepo) {
  4082. $repos[] = RepositoryFactory::createRepo($io, $config, array(
  4083. 'type' => 'composer',
  4084. 'url' => 'https://repo.packagist.org',
  4085. ));
  4086. }
  4087. $this->repos = new CompositeRepository($repos);
  4088. unset($repos, $config, $repositories);
  4089. }
  4090. $io->writeError(array(
  4091. '',
  4092. $formatter->formatBlock('Welcome to the Composer config generator', 'bg=blue;fg=white', true),
  4093. '',
  4094. ));
  4095. $io->writeError(array(
  4096. '',
  4097. 'This command will guide you through creating your composer.json config.',
  4098. '',
  4099. ));
  4100. $cwd = realpath(".");
  4101. if (!$name = $input->getOption('name')) {
  4102. $name = basename($cwd);
  4103. $name = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
  4104. $name = strtolower($name);
  4105. if (!empty($_SERVER['COMPOSER_DEFAULT_VENDOR'])) {
  4106. $name = $_SERVER['COMPOSER_DEFAULT_VENDOR'] . '/' . $name;
  4107. } elseif (isset($git['github.user'])) {
  4108. $name = $git['github.user'] . '/' . $name;
  4109. } elseif (!empty($_SERVER['USERNAME'])) {
  4110. $name = $_SERVER['USERNAME'] . '/' . $name;
  4111. } elseif (!empty($_SERVER['USER'])) {
  4112. $name = $_SERVER['USER'] . '/' . $name;
  4113. } elseif (get_current_user()) {
  4114. $name = get_current_user() . '/' . $name;
  4115. } else {
  4116. $name .= '/' . $name;
  4117. }
  4118. $name = strtolower($name);
  4119. } else {
  4120. if (!preg_match('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}D', $name)) {
  4121. throw new \InvalidArgumentException(
  4122. 'The package name '.$name.' is invalid, it should be lowercase and have a vendor name, a forward slash, and a package name, matching: [a-z0-9_.-]+/[a-z0-9_.-]+'
  4123. );
  4124. }
  4125. }
  4126. $name = $io->askAndValidate(
  4127. 'Package name (<vendor>/<name>) [<comment>'.$name.'</comment>]: ',
  4128. function ($value) use ($name) {
  4129. if (null === $value) {
  4130. return $name;
  4131. }
  4132. if (!preg_match('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}D', $value)) {
  4133. throw new \InvalidArgumentException(
  4134. '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_.-]+'
  4135. );
  4136. }
  4137. return $value;
  4138. },
  4139. null,
  4140. $name
  4141. );
  4142. $input->setOption('name', $name);
  4143. $description = $input->getOption('description') ?: false;
  4144. $description = $io->ask(
  4145. 'Description [<comment>'.$description.'</comment>]: ',
  4146. $description
  4147. );
  4148. $input->setOption('description', $description);
  4149. if (null === $author = $input->getOption('author')) {
  4150. if (!empty($_SERVER['COMPOSER_DEFAULT_AUTHOR'])) {
  4151. $author_name = $_SERVER['COMPOSER_DEFAULT_AUTHOR'];
  4152. } elseif (isset($git['user.name'])) {
  4153. $author_name = $git['user.name'];
  4154. }
  4155. if (!empty($_SERVER['COMPOSER_DEFAULT_EMAIL'])) {
  4156. $author_email = $_SERVER['COMPOSER_DEFAULT_EMAIL'];
  4157. } elseif (isset($git['user.email'])) {
  4158. $author_email = $git['user.email'];
  4159. }
  4160. if (isset($author_name, $author_email)) {
  4161. $author = sprintf('%s <%s>', $author_name, $author_email);
  4162. }
  4163. }
  4164. $self = $this;
  4165. $author = $io->askAndValidate(
  4166. 'Author [<comment>'.$author.'</comment>, n to skip]: ',
  4167. function ($value) use ($self, $author) {
  4168. if ($value === 'n' || $value === 'no') {
  4169. return;
  4170. }
  4171. $value = $value ?: $author;
  4172. $author = $self->parseAuthorString($value);
  4173. return sprintf('%s <%s>', $author['name'], $author['email']);
  4174. },
  4175. null,
  4176. $author
  4177. );
  4178. $input->setOption('author', $author);
  4179. $minimumStability = $input->getOption('stability') ?: null;
  4180. $minimumStability = $io->askAndValidate(
  4181. 'Minimum Stability [<comment>'.$minimumStability.'</comment>]: ',
  4182. function ($value) use ($minimumStability) {
  4183. if (null === $value) {
  4184. return $minimumStability;
  4185. }
  4186. if (!isset(BasePackage::$stabilities[$value])) {
  4187. throw new \InvalidArgumentException(
  4188. 'Invalid minimum stability "'.$value.'". Must be empty or one of: '.
  4189. implode(', ', array_keys(BasePackage::$stabilities))
  4190. );
  4191. }
  4192. return $value;
  4193. },
  4194. null,
  4195. $minimumStability
  4196. );
  4197. $input->setOption('stability', $minimumStability);
  4198. $type = $input->getOption('type') ?: false;
  4199. $type = $io->ask(
  4200. 'Package Type (e.g. library, project, metapackage, composer-plugin) [<comment>'.$type.'</comment>]: ',
  4201. $type
  4202. );
  4203. $input->setOption('type', $type);
  4204. if (null === $license = $input->getOption('license')) {
  4205. if (!empty($_SERVER['COMPOSER_DEFAULT_LICENSE'])) {
  4206. $license = $_SERVER['COMPOSER_DEFAULT_LICENSE'];
  4207. }
  4208. }
  4209. $license = $io->ask(
  4210. 'License [<comment>'.$license.'</comment>]: ',
  4211. $license
  4212. );
  4213. $input->setOption('license', $license);
  4214. $io->writeError(array('', 'Define your dependencies.', ''));
  4215. $repos = $this->getRepos();
  4216. $preferredStability = $minimumStability ?: 'stable';
  4217. $platformRepo = null;
  4218. if ($repos instanceof CompositeRepository) {
  4219. foreach ($repos->getRepositories() as $candidateRepo) {
  4220. if ($candidateRepo instanceof PlatformRepository) {
  4221. $platformRepo = $candidateRepo;
  4222. break;
  4223. }
  4224. }
  4225. }
  4226. $question = 'Would you like to define your dependencies (require) interactively [<comment>yes</comment>]? ';
  4227. $require = $input->getOption('require');
  4228. $requirements = array();
  4229. if ($require || $io->askConfirmation($question)) {
  4230. $requirements = $this->determineRequirements($input, $output, $require, $platformRepo, $preferredStability);
  4231. }
  4232. $input->setOption('require', $requirements);
  4233. $question = 'Would you like to define your dev dependencies (require-dev) interactively [<comment>yes</comment>]? ';
  4234. $requireDev = $input->getOption('require-dev');
  4235. $devRequirements = array();
  4236. if ($requireDev || $io->askConfirmation($question)) {
  4237. $devRequirements = $this->determineRequirements($input, $output, $requireDev, $platformRepo, $preferredStability);
  4238. }
  4239. $input->setOption('require-dev', $devRequirements);
  4240. }
  4241. public function parseAuthorString($author)
  4242. {
  4243. if (preg_match('/^(?P<name>[- .,\p{L}\p{N}\p{Mn}\'’"()]+) <(?P<email>.+?)>$/u', $author, $match)) {
  4244. if ($this->isValidEmail($match['email'])) {
  4245. return array(
  4246. 'name' => trim($match['name']),
  4247. 'email' => $match['email'],
  4248. );
  4249. }
  4250. }
  4251. throw new \InvalidArgumentException(
  4252. 'Invalid author string. Must be in the format: '.
  4253. 'John Smith <john@example.com>'
  4254. );
  4255. }
  4256. protected function findPackages($name)
  4257. {
  4258. return $this->getRepos()->search($name);
  4259. }
  4260. protected function getRepos()
  4261. {
  4262. if (!$this->repos) {
  4263. $this->repos = new CompositeRepository(array_merge(
  4264. array(new PlatformRepository),
  4265. RepositoryFactory::defaultRepos($this->getIO())
  4266. ));
  4267. }
  4268. return $this->repos;
  4269. }
  4270. final protected function determineRequirements(InputInterface $input, OutputInterface $output, $requires = array(), PlatformRepository $platformRepo = null, $preferredStability = 'stable', $checkProvidedVersions = true, $fixed = false)
  4271. {
  4272. if ($requires) {
  4273. $requires = $this->normalizeRequirements($requires);
  4274. $result = array();
  4275. $io = $this->getIO();
  4276. foreach ($requires as $requirement) {
  4277. if (!isset($requirement['version'])) {
  4278. list($name, $version) = $this->findBestVersionAndNameForPackage($input, $requirement['name'], $platformRepo, $preferredStability, null, null, $fixed);
  4279. $requirement['version'] = $version;
  4280. $requirement['name'] = $name;
  4281. $io->writeError(sprintf(
  4282. 'Using version <info>%s</info> for <info>%s</info>',
  4283. $requirement['version'],
  4284. $requirement['name']
  4285. ));
  4286. } else {
  4287. list($name) = $this->findBestVersionAndNameForPackage($input, $requirement['name'], $platformRepo, $preferredStability, $checkProvidedVersions ? $requirement['version'] : null, 'dev', $fixed);
  4288. $requirement['name'] = $name;
  4289. }
  4290. $result[] = $requirement['name'] . ' ' . $requirement['version'];
  4291. }
  4292. return $result;
  4293. }
  4294. $versionParser = new VersionParser();
  4295. $composer = $this->getComposer(false);
  4296. $installedRepo = $composer ? $composer->getRepositoryManager()->getLocalRepository() : null;
  4297. $existingPackages = array();
  4298. if ($installedRepo) {
  4299. foreach ($installedRepo->getPackages() as $package) {
  4300. $existingPackages[] = $package->getName();
  4301. }
  4302. }
  4303. unset($composer, $installedRepo);
  4304. $io = $this->getIO();
  4305. while (null !== $package = $io->ask('Search for a package: ')) {
  4306. $matches = $this->findPackages($package);
  4307. if (count($matches)) {
  4308. foreach ($matches as $position => $foundPackage) {
  4309. if (in_array($foundPackage['name'], $existingPackages, true)) {
  4310. unset($matches[$position]);
  4311. }
  4312. }
  4313. $matches = array_values($matches);
  4314. $exactMatch = null;
  4315. $choices = array();
  4316. foreach ($matches as $position => $foundPackage) {
  4317. $abandoned = '';
  4318. if (isset($foundPackage['abandoned'])) {
  4319. if (is_string($foundPackage['abandoned'])) {
  4320. $replacement = sprintf('Use %s instead', $foundPackage['abandoned']);
  4321. } else {
  4322. $replacement = 'No replacement was suggested';
  4323. }
  4324. $abandoned = sprintf('<warning>Abandoned. %s.</warning>', $replacement);
  4325. }
  4326. $choices[] = sprintf(' <info>%5s</info> %s %s', "[$position]", $foundPackage['name'], $abandoned);
  4327. if ($foundPackage['name'] === $package) {
  4328. $exactMatch = true;
  4329. break;
  4330. }
  4331. }
  4332. if (!$exactMatch) {
  4333. $io->writeError(array(
  4334. '',
  4335. sprintf('Found <info>%s</info> packages matching <info>%s</info>', count($matches), $package),
  4336. '',
  4337. ));
  4338. $io->writeError($choices);
  4339. $io->writeError('');
  4340. $validator = function ($selection) use ($matches, $versionParser) {
  4341. if ('' === $selection) {
  4342. return false;
  4343. }
  4344. if (is_numeric($selection) && isset($matches[(int) $selection])) {
  4345. $package = $matches[(int) $selection];
  4346. return $package['name'];
  4347. }
  4348. if (preg_match('{^\s*(?P<name>[\S/]+)(?:\s+(?P<version>\S+))?\s*$}', $selection, $packageMatches)) {
  4349. if (isset($packageMatches['version'])) {
  4350. $versionParser->parseConstraints($packageMatches['version']);
  4351. return $packageMatches['name'].' '.$packageMatches['version'];
  4352. }
  4353. return $packageMatches['name'];
  4354. }
  4355. throw new \Exception('Not a valid selection');
  4356. };
  4357. $package = $io->askAndValidate(
  4358. 'Enter package # to add, or the complete package name if it is not listed: ',
  4359. $validator,
  4360. 3,
  4361. false
  4362. );
  4363. }
  4364. if (false !== $package && false === strpos($package, ' ')) {
  4365. $validator = function ($input) {
  4366. $input = trim($input);
  4367. return $input ?: false;
  4368. };
  4369. $constraint = $io->askAndValidate(
  4370. 'Enter the version constraint to require (or leave blank to use the latest version): ',
  4371. $validator,
  4372. 3,
  4373. false
  4374. );
  4375. if (false === $constraint) {
  4376. list(, $constraint) = $this->findBestVersionAndNameForPackage($input, $package, $platformRepo, $preferredStability);
  4377. $io->writeError(sprintf(
  4378. 'Using version <info>%s</info> for <info>%s</info>',
  4379. $constraint,
  4380. $package
  4381. ));
  4382. }
  4383. $package .= ' '.$constraint;
  4384. }
  4385. if (false !== $package) {
  4386. $requires[] = $package;
  4387. $existingPackages[] = substr($package, 0, strpos($package, ' '));
  4388. }
  4389. }
  4390. }
  4391. return $requires;
  4392. }
  4393. protected function formatAuthors($author)
  4394. {
  4395. return array($this->parseAuthorString($author));
  4396. }
  4397. protected function getGitConfig()
  4398. {
  4399. if (null !== $this->gitConfig) {
  4400. return $this->gitConfig;
  4401. }
  4402. $finder = new ExecutableFinder();
  4403. $gitBin = $finder->find('git');
  4404. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  4405. $cmd = new Process(array($gitBin, 'config', '-l'));
  4406. } else {
  4407. $cmd = new Process(sprintf('%s config -l', ProcessExecutor::escape($gitBin)));
  4408. }
  4409. $cmd->run();
  4410. if ($cmd->isSuccessful()) {
  4411. $this->gitConfig = array();
  4412. preg_match_all('{^([^=]+)=(.*)$}m', $cmd->getOutput(), $matches, PREG_SET_ORDER);
  4413. foreach ($matches as $match) {
  4414. $this->gitConfig[$match[1]] = $match[2];
  4415. }
  4416. return $this->gitConfig;
  4417. }
  4418. return $this->gitConfig = array();
  4419. }
  4420. protected function hasVendorIgnore($ignoreFile, $vendor = 'vendor')
  4421. {
  4422. if (!file_exists($ignoreFile)) {
  4423. return false;
  4424. }
  4425. $pattern = sprintf('{^/?%s(/\*?)?$}', preg_quote($vendor));
  4426. $lines = file($ignoreFile, FILE_IGNORE_NEW_LINES);
  4427. foreach ($lines as $line) {
  4428. if (preg_match($pattern, $line)) {
  4429. return true;
  4430. }
  4431. }
  4432. return false;
  4433. }
  4434. protected function addVendorIgnore($ignoreFile, $vendor = '/vendor/')
  4435. {
  4436. $contents = "";
  4437. if (file_exists($ignoreFile)) {
  4438. $contents = file_get_contents($ignoreFile);
  4439. if (strpos($contents, "\n") !== 0) {
  4440. $contents .= "\n";
  4441. }
  4442. }
  4443. file_put_contents($ignoreFile, $contents . $vendor. "\n");
  4444. }
  4445. protected function isValidEmail($email)
  4446. {
  4447. if (!function_exists('filter_var')) {
  4448. return true;
  4449. }
  4450. if (PHP_VERSION_ID < 50303) {
  4451. return true;
  4452. }
  4453. return false !== filter_var($email, FILTER_VALIDATE_EMAIL);
  4454. }
  4455. private function getRepositorySet(InputInterface $input, $minimumStability = null)
  4456. {
  4457. $key = $minimumStability ?: 'default';
  4458. if (!isset($this->repositorySets[$key])) {
  4459. $this->repositorySets[$key] = $repositorySet = new RepositorySet($minimumStability ?: $this->getMinimumStability($input));
  4460. $repositorySet->addRepository($this->getRepos());
  4461. }
  4462. return $this->repositorySets[$key];
  4463. }
  4464. private function getMinimumStability(InputInterface $input)
  4465. {
  4466. if ($input->hasOption('stability')) {
  4467. return VersionParser::normalizeStability($input->getOption('stability') ?: 'stable');
  4468. }
  4469. $file = Factory::getComposerFile();
  4470. if (is_file($file) && is_readable($file) && is_array($composer = json_decode(file_get_contents($file), true))) {
  4471. if (!empty($composer['minimum-stability'])) {
  4472. return VersionParser::normalizeStability($composer['minimum-stability']);
  4473. }
  4474. }
  4475. return 'stable';
  4476. }
  4477. private function findBestVersionAndNameForPackage(InputInterface $input, $name, PlatformRepository $platformRepo = null, $preferredStability = 'stable', $requiredVersion = null, $minimumStability = null, $fixed = null)
  4478. {
  4479. $ignorePlatformReqs = false;
  4480. if ($input->hasOption('ignore-platform-reqs') && $input->hasOption('ignore-platform-req')) {
  4481. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  4482. }
  4483. $versionSelector = new VersionSelector($this->getRepositorySet($input, $minimumStability), $platformRepo);
  4484. $package = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, $ignorePlatformReqs);
  4485. if (!$package) {
  4486. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($name, $ignorePlatformReqs))) && PlatformRepository::isPlatformPackage($name)) {
  4487. return array($name, $requiredVersion ?: '*');
  4488. }
  4489. if (true !== $ignorePlatformReqs && $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, true)) {
  4490. throw new \InvalidArgumentException(sprintf(
  4491. 'Package %s at version %s has a PHP requirement incompatible with your PHP version, PHP extensions and Composer version',
  4492. $name,
  4493. $requiredVersion
  4494. ));
  4495. }
  4496. if ($requiredVersion && $versionSelector->findBestCandidate($name, null, $preferredStability, $ignorePlatformReqs)) {
  4497. throw new \InvalidArgumentException(sprintf(
  4498. 'Could not find package %s in a version matching %s',
  4499. $name,
  4500. $requiredVersion
  4501. ));
  4502. }
  4503. if (true !== $ignorePlatformReqs && $versionSelector->findBestCandidate($name, null, $preferredStability, true)) {
  4504. throw new \InvalidArgumentException(sprintf(
  4505. 'Could not find package %s in any version matching your PHP version, PHP extensions and Composer version',
  4506. $name
  4507. ));
  4508. }
  4509. $similar = $this->findSimilar($name);
  4510. if ($similar) {
  4511. if ($requiredVersion === null && in_array($name, $similar, true)) {
  4512. throw new \InvalidArgumentException(sprintf(
  4513. 'Could not find a version of package %s matching your minimum-stability (%s). Require it with an explicit version constraint allowing its desired stability.',
  4514. $name,
  4515. $this->getMinimumStability($input)
  4516. ));
  4517. }
  4518. throw new \InvalidArgumentException(sprintf(
  4519. "Could not find package %s.\n\nDid you mean " . (count($similar) > 1 ? 'one of these' : 'this') . "?\n %s",
  4520. $name,
  4521. implode("\n ", $similar)
  4522. ));
  4523. }
  4524. throw new \InvalidArgumentException(sprintf(
  4525. '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).',
  4526. $name,
  4527. $this->getMinimumStability($input)
  4528. ));
  4529. }
  4530. return array(
  4531. $package->getPrettyName(),
  4532. $fixed ? $package->getPrettyVersion() : $versionSelector->findRecommendedRequireVersion($package),
  4533. );
  4534. }
  4535. private function findSimilar($package)
  4536. {
  4537. try {
  4538. $results = $this->repos->search($package);
  4539. } catch (\Exception $e) {
  4540. return array();
  4541. }
  4542. $similarPackages = array();
  4543. $installedRepo = $this->getComposer()->getRepositoryManager()->getLocalRepository();
  4544. foreach ($results as $result) {
  4545. if ($installedRepo->findPackage($result['name'], '*')) {
  4546. continue;
  4547. }
  4548. $similarPackages[$result['name']] = levenshtein($package, $result['name']);
  4549. }
  4550. asort($similarPackages);
  4551. return array_keys(array_slice($similarPackages, 0, 5));
  4552. }
  4553. private function installDependencies($output)
  4554. {
  4555. try {
  4556. $installCommand = $this->getApplication()->find('install');
  4557. $installCommand->run(new ArrayInput(array()), $output);
  4558. } catch (\Exception $e) {
  4559. $this->getIO()->writeError('Could not install dependencies. Run `composer install` to see more information.');
  4560. }
  4561. }
  4562. private function hasDependencies($options)
  4563. {
  4564. $requires = (array) $options['require'];
  4565. $devRequires = isset($options['require-dev']) ? (array) $options['require-dev'] : array();
  4566. return !empty($requires) || !empty($devRequires);
  4567. }
  4568. }
  4569. <?php
  4570. namespace Composer\Command;
  4571. use Composer\Installer;
  4572. use Composer\Plugin\CommandEvent;
  4573. use Composer\Plugin\PluginEvents;
  4574. use Symfony\Component\Console\Input\InputInterface;
  4575. use Symfony\Component\Console\Input\InputOption;
  4576. use Symfony\Component\Console\Input\InputArgument;
  4577. use Symfony\Component\Console\Output\OutputInterface;
  4578. class InstallCommand extends BaseCommand
  4579. {
  4580. protected function configure()
  4581. {
  4582. $this
  4583. ->setName('install')
  4584. ->setAliases(array('i'))
  4585. ->setDescription('Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json.')
  4586. ->setDefinition(array(
  4587. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  4588. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
  4589. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  4590. new InputOption('dev', null, InputOption::VALUE_NONE, 'DEPRECATED: Enables installation of require-dev packages (enabled by default, only present for BC).'),
  4591. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  4592. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  4593. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  4594. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  4595. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  4596. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Do not use, only defined here to catch misuse of the install command.'),
  4597. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
  4598. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  4599. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  4600. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  4601. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  4602. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  4603. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  4604. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Should not be provided, use composer require instead to add a given package to composer.json.'),
  4605. ))
  4606. ->setHelp(
  4607. <<<EOT
  4608. The <info>install</info> command reads the composer.lock file from
  4609. the current directory, processes it, and downloads and installs all the
  4610. libraries and dependencies outlined in that file. If the file does not
  4611. exist it will look for composer.json and do the same.
  4612. <info>php composer.phar install</info>
  4613. Read more at https://getcomposer.org/doc/03-cli.md#install-i
  4614. EOT
  4615. )
  4616. ;
  4617. }
  4618. protected function execute(InputInterface $input, OutputInterface $output)
  4619. {
  4620. $io = $this->getIO();
  4621. if ($input->getOption('dev')) {
  4622. $io->writeError('<warning>You are using the deprecated option "--dev". It has no effect and will break in Composer 3.</warning>');
  4623. }
  4624. if ($input->getOption('no-suggest')) {
  4625. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  4626. }
  4627. if ($args = $input->getArgument('packages')) {
  4628. $io->writeError('<error>Invalid argument '.implode(' ', $args).'. Use "composer require '.implode(' ', $args).'" instead to add packages to your composer.json.</error>');
  4629. return 1;
  4630. }
  4631. if ($input->getOption('no-install')) {
  4632. $io->writeError('<error>Invalid option "--no-install". Use "composer update --no-install" instead if you are trying to update the composer.lock file.</error>');
  4633. return 1;
  4634. }
  4635. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  4636. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'install', $input, $output);
  4637. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  4638. $install = Installer::create($io, $composer);
  4639. $config = $composer->getConfig();
  4640. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  4641. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  4642. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  4643. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  4644. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  4645. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  4646. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  4647. $install
  4648. ->setDryRun($input->getOption('dry-run'))
  4649. ->setVerbose($input->getOption('verbose'))
  4650. ->setPreferSource($preferSource)
  4651. ->setPreferDist($preferDist)
  4652. ->setDevMode(!$input->getOption('no-dev'))
  4653. ->setDumpAutoloader(!$input->getOption('no-autoloader'))
  4654. ->setRunScripts(!$input->getOption('no-scripts'))
  4655. ->setOptimizeAutoloader($optimize)
  4656. ->setClassMapAuthoritative($authoritative)
  4657. ->setApcuAutoloader($apcu, $apcuPrefix)
  4658. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  4659. ;
  4660. if ($input->getOption('no-plugins')) {
  4661. $install->disablePlugins();
  4662. }
  4663. return $install->run();
  4664. }
  4665. }
  4666. <?php
  4667. namespace Composer\Command;
  4668. use Composer\Json\JsonFile;
  4669. use Composer\Plugin\CommandEvent;
  4670. use Composer\Plugin\PluginEvents;
  4671. use Composer\Package\PackageInterface;
  4672. use Composer\Repository\RepositoryInterface;
  4673. use Symfony\Component\Console\Helper\Table;
  4674. use Symfony\Component\Console\Input\InputInterface;
  4675. use Symfony\Component\Console\Input\InputOption;
  4676. use Symfony\Component\Console\Output\OutputInterface;
  4677. use Symfony\Component\Console\Style\SymfonyStyle;
  4678. class LicensesCommand extends BaseCommand
  4679. {
  4680. protected function configure()
  4681. {
  4682. $this
  4683. ->setName('licenses')
  4684. ->setDescription('Shows information about licenses of dependencies.')
  4685. ->setDefinition(array(
  4686. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text, json or summary', 'text'),
  4687. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  4688. ))
  4689. ->setHelp(
  4690. <<<EOT
  4691. The license command displays detailed information about the licenses of
  4692. the installed dependencies.
  4693. Read more at https://getcomposer.org/doc/03-cli.md#licenses
  4694. EOT
  4695. )
  4696. ;
  4697. }
  4698. protected function execute(InputInterface $input, OutputInterface $output)
  4699. {
  4700. $composer = $this->getComposer();
  4701. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'licenses', $input, $output);
  4702. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  4703. $root = $composer->getPackage();
  4704. $repo = $composer->getRepositoryManager()->getLocalRepository();
  4705. if ($input->getOption('no-dev')) {
  4706. $packages = $this->filterRequiredPackages($repo, $root);
  4707. } else {
  4708. $packages = $this->appendPackages($repo->getPackages(), array());
  4709. }
  4710. ksort($packages);
  4711. $io = $this->getIO();
  4712. switch ($format = $input->getOption('format')) {
  4713. case 'text':
  4714. $io->write('Name: <comment>'.$root->getPrettyName().'</comment>');
  4715. $io->write('Version: <comment>'.$root->getFullPrettyVersion().'</comment>');
  4716. $io->write('Licenses: <comment>'.(implode(', ', $root->getLicense()) ?: 'none').'</comment>');
  4717. $io->write('Dependencies:');
  4718. $io->write('');
  4719. $table = new Table($output);
  4720. $table->setStyle('compact');
  4721. $tableStyle = $table->getStyle();
  4722. if (method_exists($tableStyle, 'setVerticalBorderChars')) {
  4723. $tableStyle->setVerticalBorderChars('');
  4724. } else {
  4725. $tableStyle->setVerticalBorderChar('');
  4726. }
  4727. $tableStyle->setCellRowContentFormat('%s ');
  4728. $table->setHeaders(array('Name', 'Version', 'License'));
  4729. foreach ($packages as $package) {
  4730. $table->addRow(array(
  4731. $package->getPrettyName(),
  4732. $package->getFullPrettyVersion(),
  4733. implode(', ', $package->getLicense()) ?: 'none',
  4734. ));
  4735. }
  4736. $table->render();
  4737. break;
  4738. case 'json':
  4739. $dependencies = array();
  4740. foreach ($packages as $package) {
  4741. $dependencies[$package->getPrettyName()] = array(
  4742. 'version' => $package->getFullPrettyVersion(),
  4743. 'license' => $package->getLicense(),
  4744. );
  4745. }
  4746. $io->write(JsonFile::encode(array(
  4747. 'name' => $root->getPrettyName(),
  4748. 'version' => $root->getFullPrettyVersion(),
  4749. 'license' => $root->getLicense(),
  4750. 'dependencies' => $dependencies,
  4751. )));
  4752. break;
  4753. case 'summary':
  4754. $usedLicenses = array();
  4755. foreach ($packages as $package) {
  4756. $license = $package->getLicense();
  4757. $licenseName = $license[0];
  4758. if (!isset($usedLicenses[$licenseName])) {
  4759. $usedLicenses[$licenseName] = 0;
  4760. }
  4761. $usedLicenses[$licenseName]++;
  4762. }
  4763. arsort($usedLicenses, SORT_NUMERIC);
  4764. $rows = array();
  4765. foreach ($usedLicenses as $usedLicense => $numberOfDependencies) {
  4766. $rows[] = array($usedLicense, $numberOfDependencies);
  4767. }
  4768. $symfonyIo = new SymfonyStyle($input, $output);
  4769. $symfonyIo->table(
  4770. array('License', 'Number of dependencies'),
  4771. $rows
  4772. );
  4773. break;
  4774. default:
  4775. throw new \RuntimeException(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  4776. }
  4777. return 0;
  4778. }
  4779. private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, $bucket = array())
  4780. {
  4781. $requires = array_keys($package->getRequires());
  4782. $packageListNames = array_keys($bucket);
  4783. $packages = array_filter(
  4784. $repo->getPackages(),
  4785. function ($package) use ($requires, $packageListNames) {
  4786. return in_array($package->getName(), $requires) && !in_array($package->getName(), $packageListNames);
  4787. }
  4788. );
  4789. $bucket = $this->appendPackages($packages, $bucket);
  4790. foreach ($packages as $package) {
  4791. $bucket = $this->filterRequiredPackages($repo, $package, $bucket);
  4792. }
  4793. return $bucket;
  4794. }
  4795. public function appendPackages(array $packages, array $bucket)
  4796. {
  4797. foreach ($packages as $package) {
  4798. $bucket[$package->getName()] = $package;
  4799. }
  4800. return $bucket;
  4801. }
  4802. }
  4803. <?php
  4804. namespace Composer\Command;
  4805. use Symfony\Component\Console\Input\InputInterface;
  4806. use Symfony\Component\Console\Input\InputArgument;
  4807. use Symfony\Component\Console\Input\ArrayInput;
  4808. use Symfony\Component\Console\Input\InputOption;
  4809. use Symfony\Component\Console\Output\OutputInterface;
  4810. class OutdatedCommand extends ShowCommand
  4811. {
  4812. protected function configure()
  4813. {
  4814. $this
  4815. ->setName('outdated')
  4816. ->setDescription('Shows a list of installed packages that have updates available, including their latest version.')
  4817. ->setDefinition(array(
  4818. new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.'),
  4819. new InputOption('outdated', 'o', InputOption::VALUE_NONE, 'Show only packages that are outdated (this is the default, but present here for compat with `show`'),
  4820. new InputOption('all', 'a', InputOption::VALUE_NONE, 'Show all installed packages with their latest versions'),
  4821. new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'),
  4822. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code when there are outdated packages'),
  4823. new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages that have minor SemVer-compatible updates. Use with the --outdated option.'),
  4824. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  4825. 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.'),
  4826. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  4827. ))
  4828. ->setHelp(
  4829. <<<EOT
  4830. The outdated command is just a proxy for `composer show -l`
  4831. The color coding (or signage if you have ANSI colors disabled) for dependency versions is as such:
  4832. - <info>green</info> (=): Dependency is in the latest version and is up to date.
  4833. - <comment>yellow</comment> (~): Dependency has a new version available that includes backwards
  4834. compatibility breaks according to semver, so upgrade when you can but it
  4835. may involve work.
  4836. - <highlight>red</highlight> (!): Dependency has a new version that is semver-compatible and you should upgrade it.
  4837. Read more at https://getcomposer.org/doc/03-cli.md#outdated
  4838. EOT
  4839. )
  4840. ;
  4841. }
  4842. protected function execute(InputInterface $input, OutputInterface $output)
  4843. {
  4844. $args = array(
  4845. 'command' => 'show',
  4846. '--latest' => true,
  4847. );
  4848. if (!$input->getOption('all')) {
  4849. $args['--outdated'] = true;
  4850. }
  4851. if ($input->getOption('direct')) {
  4852. $args['--direct'] = true;
  4853. }
  4854. if ($input->getArgument('package')) {
  4855. $args['package'] = $input->getArgument('package');
  4856. }
  4857. if ($input->getOption('strict')) {
  4858. $args['--strict'] = true;
  4859. }
  4860. if ($input->getOption('minor-only')) {
  4861. $args['--minor-only'] = true;
  4862. }
  4863. if ($input->getOption('no-dev')) {
  4864. $args['--no-dev'] = true;
  4865. }
  4866. $args['--format'] = $input->getOption('format');
  4867. $args['--ignore'] = $input->getOption('ignore');
  4868. $input = new ArrayInput($args);
  4869. return $this->getApplication()->run($input, $output);
  4870. }
  4871. public function isProxyCommand()
  4872. {
  4873. return true;
  4874. }
  4875. }
  4876. <?php
  4877. namespace Composer\Command;
  4878. use Symfony\Component\Console\Input\InputInterface;
  4879. use Symfony\Component\Console\Output\OutputInterface;
  4880. class ProhibitsCommand extends BaseDependencyCommand
  4881. {
  4882. protected function configure()
  4883. {
  4884. parent::configure();
  4885. $this
  4886. ->setName('prohibits')
  4887. ->setAliases(array('why-not'))
  4888. ->setDescription('Shows which packages prevent the given package from being installed.')
  4889. ->setHelp(
  4890. <<<EOT
  4891. Displays detailed information about why a package cannot be installed.
  4892. <info>php composer.phar prohibits composer/composer</info>
  4893. Read more at https://getcomposer.org/doc/03-cli.md#prohibits-why-not-
  4894. EOT
  4895. )
  4896. ;
  4897. }
  4898. protected function execute(InputInterface $input, OutputInterface $output)
  4899. {
  4900. return parent::doExecute($input, $output, true);
  4901. }
  4902. }
  4903. <?php
  4904. namespace Composer\Command;
  4905. use Composer\Config\JsonConfigSource;
  4906. use Composer\DependencyResolver\Request;
  4907. use Composer\Installer;
  4908. use Composer\Plugin\CommandEvent;
  4909. use Composer\Plugin\PluginEvents;
  4910. use Composer\Json\JsonFile;
  4911. use Composer\Factory;
  4912. use Symfony\Component\Console\Input\InputInterface;
  4913. use Symfony\Component\Console\Input\InputOption;
  4914. use Symfony\Component\Console\Input\InputArgument;
  4915. use Symfony\Component\Console\Output\OutputInterface;
  4916. use Composer\Package\BasePackage;
  4917. class RemoveCommand extends BaseCommand
  4918. {
  4919. protected function configure()
  4920. {
  4921. $this
  4922. ->setName('remove')
  4923. ->setDescription('Removes a package from the require or require-dev.')
  4924. ->setDefinition(array(
  4925. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'Packages that should be removed.'),
  4926. new InputOption('dev', null, InputOption::VALUE_NONE, 'Removes a package from the require-dev section.'),
  4927. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  4928. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  4929. new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies (implies --no-install).'),
  4930. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  4931. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  4932. new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'),
  4933. new InputOption('update-with-dependencies', 'w', InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated with explicit dependencies. (Deprecrated, is now default behavior)'),
  4934. new InputOption('update-with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Allows all inherited dependencies to be updated, including those that are root requirements.'),
  4935. new InputOption('with-all-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-all-dependencies'),
  4936. new InputOption('no-update-with-dependencies', null, InputOption::VALUE_NONE, 'Does not allow inherited dependencies to be updated with explicit dependencies.'),
  4937. new InputOption('unused', null, InputOption::VALUE_NONE, 'Remove all packages which are locked but not required by any other package.'),
  4938. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  4939. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  4940. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  4941. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  4942. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  4943. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  4944. ))
  4945. ->setHelp(
  4946. <<<EOT
  4947. The <info>remove</info> command removes a package from the current
  4948. list of installed packages
  4949. <info>php composer.phar remove</info>
  4950. Read more at https://getcomposer.org/doc/03-cli.md#remove
  4951. EOT
  4952. )
  4953. ;
  4954. }
  4955. protected function interact(InputInterface $input, OutputInterface $output)
  4956. {
  4957. if ($input->getOption('unused')) {
  4958. $composer = $this->getComposer();
  4959. $locker = $composer->getLocker();
  4960. if (!$locker->isLocked()) {
  4961. throw new \UnexpectedValueException('A valid composer.lock file is required to run this command with --unused');
  4962. }
  4963. $lockedPackages = $locker->getLockedRepository()->getPackages();
  4964. $required = array();
  4965. foreach (array_merge($composer->getPackage()->getRequires(), $composer->getPackage()->getDevRequires()) as $link) {
  4966. $required[$link->getTarget()] = true;
  4967. }
  4968. do {
  4969. $found = false;
  4970. foreach ($lockedPackages as $index => $package) {
  4971. foreach ($package->getNames() as $name) {
  4972. if (isset($required[$name])) {
  4973. foreach ($package->getRequires() as $link) {
  4974. $required[$link->getTarget()] = true;
  4975. }
  4976. $found = true;
  4977. unset($lockedPackages[$index]);
  4978. break;
  4979. }
  4980. }
  4981. }
  4982. } while ($found);
  4983. $unused = array();
  4984. foreach ($lockedPackages as $package) {
  4985. $unused[] = $package->getName();
  4986. }
  4987. $input->setArgument('packages', array_merge($input->getArgument('packages'), $unused));
  4988. if (!$input->getArgument('packages')) {
  4989. $this->getIO()->writeError('<info>No unused packages to remove</info>');
  4990. $this->setCode(function () {
  4991. return 0;
  4992. });
  4993. }
  4994. }
  4995. }
  4996. protected function execute(InputInterface $input, OutputInterface $output)
  4997. {
  4998. $packages = $input->getArgument('packages');
  4999. $packages = array_map('strtolower', $packages);
  5000. $file = Factory::getComposerFile();
  5001. $jsonFile = new JsonFile($file);
  5002. $composer = $jsonFile->read();
  5003. $composerBackup = file_get_contents($jsonFile->getPath());
  5004. $json = new JsonConfigSource($jsonFile);
  5005. $type = $input->getOption('dev') ? 'require-dev' : 'require';
  5006. $altType = !$input->getOption('dev') ? 'require-dev' : 'require';
  5007. $io = $this->getIO();
  5008. if ($input->getOption('update-with-dependencies')) {
  5009. $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>');
  5010. }
  5011. foreach (array('require', 'require-dev') as $linkType) {
  5012. if (isset($composer[$linkType])) {
  5013. foreach ($composer[$linkType] as $name => $version) {
  5014. $composer[$linkType][strtolower($name)] = $name;
  5015. }
  5016. }
  5017. }
  5018. $dryRun = $input->getOption('dry-run');
  5019. $toRemove = array();
  5020. foreach ($packages as $package) {
  5021. if (isset($composer[$type][$package])) {
  5022. if ($dryRun) {
  5023. $toRemove[$type][] = $composer[$type][$package];
  5024. } else {
  5025. $json->removeLink($type, $composer[$type][$package]);
  5026. }
  5027. } elseif (isset($composer[$altType][$package])) {
  5028. $io->writeError('<warning>' . $composer[$altType][$package] . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
  5029. if ($io->isInteractive()) {
  5030. if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [<comment>yes</comment>]? ')) {
  5031. if ($dryRun) {
  5032. $toRemove[$altType][] = $composer[$altType][$package];
  5033. } else {
  5034. $json->removeLink($altType, $composer[$altType][$package]);
  5035. }
  5036. }
  5037. }
  5038. } elseif (isset($composer[$type]) && $matches = preg_grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$type]))) {
  5039. foreach ($matches as $matchedPackage) {
  5040. if ($dryRun) {
  5041. $toRemove[$type][] = $matchedPackage;
  5042. } else {
  5043. $json->removeLink($type, $matchedPackage);
  5044. }
  5045. }
  5046. } elseif (isset($composer[$altType]) && $matches = preg_grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$altType]))) {
  5047. foreach ($matches as $matchedPackage) {
  5048. $io->writeError('<warning>' . $matchedPackage . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
  5049. if ($io->isInteractive()) {
  5050. if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [<comment>yes</comment>]? ')) {
  5051. if ($dryRun) {
  5052. $toRemove[$altType][] = $matchedPackage;
  5053. } else {
  5054. $json->removeLink($altType, $matchedPackage);
  5055. }
  5056. }
  5057. }
  5058. }
  5059. } else {
  5060. $io->writeError('<warning>'.$package.' is not required in your composer.json and has not been removed</warning>');
  5061. }
  5062. }
  5063. $io->writeError('<info>'.$file.' has been updated</info>');
  5064. if ($input->getOption('no-update')) {
  5065. return 0;
  5066. }
  5067. $this->resetComposer();
  5068. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  5069. if ($dryRun) {
  5070. $rootPackage = $composer->getPackage();
  5071. $links = array(
  5072. 'require' => $rootPackage->getRequires(),
  5073. 'require-dev' => $rootPackage->getDevRequires(),
  5074. );
  5075. foreach ($toRemove as $type => $names) {
  5076. foreach ($names as $name) {
  5077. unset($links[$type][$name]);
  5078. }
  5079. }
  5080. $rootPackage->setRequires($links['require']);
  5081. $rootPackage->setDevRequires($links['require-dev']);
  5082. }
  5083. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'remove', $input, $output);
  5084. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5085. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  5086. $install = Installer::create($io, $composer);
  5087. $updateDevMode = !$input->getOption('update-no-dev');
  5088. $optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader');
  5089. $authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative');
  5090. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  5091. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $composer->getConfig()->get('apcu-autoloader');
  5092. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  5093. $flags = '';
  5094. if ($input->getOption('update-with-all-dependencies') || $input->getOption('with-all-dependencies')) {
  5095. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  5096. $flags .= ' --with-all-dependencies';
  5097. } elseif ($input->getOption('no-update-with-dependencies')) {
  5098. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  5099. $flags .= ' --with-dependencies';
  5100. }
  5101. $io->writeError('<info>Running composer update '.implode(' ', $packages).$flags.'</info>');
  5102. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  5103. $install
  5104. ->setVerbose($input->getOption('verbose'))
  5105. ->setDevMode($updateDevMode)
  5106. ->setOptimizeAutoloader($optimize)
  5107. ->setClassMapAuthoritative($authoritative)
  5108. ->setApcuAutoloader($apcu, $apcuPrefix)
  5109. ->setUpdate(true)
  5110. ->setInstall(!$input->getOption('no-install'))
  5111. ->setUpdateAllowList($packages)
  5112. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  5113. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  5114. ->setRunScripts(!$input->getOption('no-scripts'))
  5115. ->setDryRun($dryRun)
  5116. ;
  5117. $status = $install->run();
  5118. if ($status !== 0) {
  5119. $io->writeError("\n".'<error>Removal failed, reverting '.$file.' to its original content.</error>');
  5120. file_put_contents($jsonFile->getPath(), $composerBackup);
  5121. }
  5122. if (!$dryRun) {
  5123. foreach ($packages as $package) {
  5124. if ($composer->getRepositoryManager()->getLocalRepository()->findPackages($package)) {
  5125. $io->writeError('<error>Removal failed, '.$package.' is still present, it may be required by another package. See `composer why '.$package.'`.</error>');
  5126. return 2;
  5127. }
  5128. }
  5129. }
  5130. return $status;
  5131. }
  5132. }
  5133. <?php
  5134. namespace Composer\Command;
  5135. use Composer\DependencyResolver\Request;
  5136. use Symfony\Component\Console\Input\InputInterface;
  5137. use Symfony\Component\Console\Input\InputArgument;
  5138. use Symfony\Component\Console\Input\InputOption;
  5139. use Symfony\Component\Console\Output\OutputInterface;
  5140. use Composer\Factory;
  5141. use Composer\Installer;
  5142. use Composer\Json\JsonFile;
  5143. use Composer\Json\JsonManipulator;
  5144. use Composer\Package\Version\VersionParser;
  5145. use Composer\Package\Loader\ArrayLoader;
  5146. use Composer\Package\BasePackage;
  5147. use Composer\Plugin\CommandEvent;
  5148. use Composer\Plugin\PluginEvents;
  5149. use Composer\Repository\CompositeRepository;
  5150. use Composer\Repository\PlatformRepository;
  5151. use Composer\IO\IOInterface;
  5152. use Composer\Util\Silencer;
  5153. class RequireCommand extends InitCommand
  5154. {
  5155. private $newlyCreated;
  5156. private $firstRequire;
  5157. private $json;
  5158. private $file;
  5159. private $composerBackup;
  5160. private $lock;
  5161. private $lockBackup;
  5162. protected function configure()
  5163. {
  5164. $this
  5165. ->setName('require')
  5166. ->setDescription('Adds required packages to your composer.json and installs them.')
  5167. ->setDefinition(array(
  5168. 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"'),
  5169. new InputOption('dev', null, InputOption::VALUE_NONE, 'Add requirement to require-dev.'),
  5170. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  5171. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  5172. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
  5173. new InputOption('fixed', null, InputOption::VALUE_NONE, 'Write fixed version to the composer.json.'),
  5174. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  5175. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  5176. new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies (implies --no-install).'),
  5177. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  5178. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  5179. new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'),
  5180. new InputOption('update-with-dependencies', 'w', InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated, except those that are root requirements.'),
  5181. new InputOption('update-with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Allows all inherited dependencies to be updated, including those that are root requirements.'),
  5182. new InputOption('with-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-dependencies'),
  5183. new InputOption('with-all-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-all-dependencies'),
  5184. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  5185. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  5186. new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies.'),
  5187. new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies.'),
  5188. new InputOption('sort-packages', null, InputOption::VALUE_NONE, 'Sorts packages when adding/updating a new dependency'),
  5189. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  5190. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  5191. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  5192. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  5193. ))
  5194. ->setHelp(
  5195. <<<EOT
  5196. The require command adds required packages to your composer.json and installs them.
  5197. If you do not specify a package, composer will prompt you to search for a package, and given results, provide a list of
  5198. matches to require.
  5199. If you do not specify a version constraint, composer will choose a suitable one based on the available package versions.
  5200. If you do not want to install the new dependencies immediately you can call it with --no-update
  5201. Read more at https://getcomposer.org/doc/03-cli.md#require
  5202. EOT
  5203. )
  5204. ;
  5205. }
  5206. protected function execute(InputInterface $input, OutputInterface $output)
  5207. {
  5208. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  5209. pcntl_async_signals(true);
  5210. pcntl_signal(SIGINT, array($this, 'revertComposerFile'));
  5211. pcntl_signal(SIGTERM, array($this, 'revertComposerFile'));
  5212. pcntl_signal(SIGHUP, array($this, 'revertComposerFile'));
  5213. }
  5214. $this->file = Factory::getComposerFile();
  5215. $io = $this->getIO();
  5216. if ($input->getOption('no-suggest')) {
  5217. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  5218. }
  5219. $this->newlyCreated = !file_exists($this->file);
  5220. if ($this->newlyCreated && !file_put_contents($this->file, "{\n}\n")) {
  5221. $io->writeError('<error>'.$this->file.' could not be created.</error>');
  5222. return 1;
  5223. }
  5224. if (!is_readable($this->file) && false === Silencer::call('file_get_contents', $this->file)) {
  5225. $io->writeError('<error>'.$this->file.' is not readable.</error>');
  5226. return 1;
  5227. }
  5228. if (filesize($this->file) === 0) {
  5229. file_put_contents($this->file, "{\n}\n");
  5230. }
  5231. $this->json = new JsonFile($this->file);
  5232. $this->lock = Factory::getLockFile($this->file);
  5233. $this->composerBackup = file_get_contents($this->json->getPath());
  5234. $this->lockBackup = file_exists($this->lock) ? file_get_contents($this->lock) : null;
  5235. if (!is_writable($this->file) && !Silencer::call('file_put_contents', $this->file, $this->composerBackup)) {
  5236. $io->writeError('<error>'.$this->file.' is not writable.</error>');
  5237. return 1;
  5238. }
  5239. if ($input->getOption('fixed') === true) {
  5240. $config = $this->json->read();
  5241. $packageType = empty($config['type']) ? 'library' : $config['type'];
  5242. if ($packageType !== 'project') {
  5243. $io->writeError('<error>"--fixed" option is allowed for "project" package types only to prevent possible misuses.</error>');
  5244. if (empty($config['type'])) {
  5245. $io->writeError('<error>If your package is not library, you should explicitly specify "type" parameter in composer.json.</error>');
  5246. }
  5247. return 1;
  5248. }
  5249. }
  5250. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  5251. $repos = $composer->getRepositoryManager()->getRepositories();
  5252. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  5253. $this->repos = new CompositeRepository(array_merge(
  5254. array($platformRepo = new PlatformRepository(array(), $platformOverrides)),
  5255. $repos
  5256. ));
  5257. if ($composer->getPackage()->getPreferStable()) {
  5258. $preferredStability = 'stable';
  5259. } else {
  5260. $preferredStability = $composer->getPackage()->getMinimumStability();
  5261. }
  5262. try {
  5263. $requirements = $this->determineRequirements(
  5264. $input,
  5265. $output,
  5266. $input->getArgument('packages'),
  5267. $platformRepo,
  5268. $preferredStability,
  5269. !$input->getOption('no-update'),
  5270. $input->getOption('fixed')
  5271. );
  5272. } catch (\Exception $e) {
  5273. if ($this->newlyCreated) {
  5274. throw new \RuntimeException('No composer.json present in the current directory, this may be the cause of the following exception.', 0, $e);
  5275. }
  5276. throw $e;
  5277. }
  5278. $requireKey = $input->getOption('dev') ? 'require-dev' : 'require';
  5279. $removeKey = $input->getOption('dev') ? 'require' : 'require-dev';
  5280. $requirements = $this->formatRequirements($requirements);
  5281. $versionParser = new VersionParser();
  5282. foreach ($requirements as $package => $constraint) {
  5283. if (strtolower($package) === $composer->getPackage()->getName()) {
  5284. $io->writeError(sprintf('<error>Root package \'%s\' cannot require itself in its composer.json</error>', $package));
  5285. return 1;
  5286. }
  5287. $versionParser->parseConstraints($constraint);
  5288. }
  5289. $sortPackages = $input->getOption('sort-packages') || $composer->getConfig()->get('sort-packages');
  5290. $this->firstRequire = $this->newlyCreated;
  5291. if (!$this->firstRequire) {
  5292. $composerDefinition = $this->json->read();
  5293. if (empty($composerDefinition['require']) && empty($composerDefinition['require-dev'])) {
  5294. $this->firstRequire = true;
  5295. }
  5296. }
  5297. if (!$input->getOption('dry-run') && !$this->updateFileCleanly($this->json, $requirements, $requireKey, $removeKey, $sortPackages)) {
  5298. $composerDefinition = $this->json->read();
  5299. foreach ($requirements as $package => $version) {
  5300. $composerDefinition[$requireKey][$package] = $version;
  5301. unset($composerDefinition[$removeKey][$package]);
  5302. }
  5303. $this->json->write($composerDefinition);
  5304. }
  5305. $io->writeError('<info>'.$this->file.' has been '.($this->newlyCreated ? 'created' : 'updated').'</info>');
  5306. if ($input->getOption('no-update')) {
  5307. return 0;
  5308. }
  5309. try {
  5310. return $this->doUpdate($input, $output, $io, $requirements, $requireKey, $removeKey);
  5311. } catch (\Exception $e) {
  5312. $this->revertComposerFile(false);
  5313. throw $e;
  5314. }
  5315. }
  5316. private function doUpdate(InputInterface $input, OutputInterface $output, IOInterface $io, array $requirements, $requireKey, $removeKey)
  5317. {
  5318. $this->resetComposer();
  5319. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  5320. if ($input->getOption('dry-run')) {
  5321. $rootPackage = $composer->getPackage();
  5322. $links = array(
  5323. 'require' => $rootPackage->getRequires(),
  5324. 'require-dev' => $rootPackage->getDevRequires(),
  5325. );
  5326. $loader = new ArrayLoader();
  5327. $newLinks = $loader->parseLinks($rootPackage->getName(), $rootPackage->getPrettyVersion(), BasePackage::$supportedLinkTypes[$requireKey]['description'], $requirements);
  5328. $links[$requireKey] = array_merge($links[$requireKey], $newLinks);
  5329. foreach ($requirements as $package => $constraint) {
  5330. unset($links[$removeKey][$package]);
  5331. }
  5332. $rootPackage->setRequires($links['require']);
  5333. $rootPackage->setDevRequires($links['require-dev']);
  5334. }
  5335. $updateDevMode = !$input->getOption('update-no-dev');
  5336. $optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader');
  5337. $authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative');
  5338. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  5339. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $composer->getConfig()->get('apcu-autoloader');
  5340. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  5341. $flags = '';
  5342. if ($input->getOption('update-with-all-dependencies') || $input->getOption('with-all-dependencies')) {
  5343. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  5344. $flags .= ' --with-all-dependencies';
  5345. } elseif ($input->getOption('update-with-dependencies') || $input->getOption('with-dependencies')) {
  5346. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  5347. $flags .= ' --with-dependencies';
  5348. }
  5349. $io->writeError('<info>Running composer update '.implode(' ', array_keys($requirements)).$flags.'</info>');
  5350. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'require', $input, $output);
  5351. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5352. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  5353. $install = Installer::create($io, $composer);
  5354. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  5355. $install
  5356. ->setDryRun($input->getOption('dry-run'))
  5357. ->setVerbose($input->getOption('verbose'))
  5358. ->setPreferSource($input->getOption('prefer-source'))
  5359. ->setPreferDist($input->getOption('prefer-dist'))
  5360. ->setDevMode($updateDevMode)
  5361. ->setRunScripts(!$input->getOption('no-scripts'))
  5362. ->setOptimizeAutoloader($optimize)
  5363. ->setClassMapAuthoritative($authoritative)
  5364. ->setApcuAutoloader($apcu, $apcuPrefix)
  5365. ->setUpdate(true)
  5366. ->setInstall(!$input->getOption('no-install'))
  5367. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  5368. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  5369. ->setPreferStable($input->getOption('prefer-stable'))
  5370. ->setPreferLowest($input->getOption('prefer-lowest'))
  5371. ;
  5372. if (!$this->firstRequire && $composer->getConfig()->get('lock')) {
  5373. $install->setUpdateAllowList(array_keys($requirements));
  5374. }
  5375. $status = $install->run();
  5376. if ($status !== 0) {
  5377. $this->revertComposerFile(false);
  5378. }
  5379. return $status;
  5380. }
  5381. private function updateFileCleanly($json, array $new, $requireKey, $removeKey, $sortPackages)
  5382. {
  5383. $contents = file_get_contents($json->getPath());
  5384. $manipulator = new JsonManipulator($contents);
  5385. foreach ($new as $package => $constraint) {
  5386. if (!$manipulator->addLink($requireKey, $package, $constraint, $sortPackages)) {
  5387. return false;
  5388. }
  5389. if (!$manipulator->removeSubNode($removeKey, $package)) {
  5390. return false;
  5391. }
  5392. }
  5393. file_put_contents($json->getPath(), $manipulator->getContents());
  5394. return true;
  5395. }
  5396. protected function interact(InputInterface $input, OutputInterface $output)
  5397. {
  5398. return;
  5399. }
  5400. public function revertComposerFile($hardExit = true)
  5401. {
  5402. $io = $this->getIO();
  5403. if ($this->newlyCreated) {
  5404. $io->writeError("\n".'<error>Installation failed, deleting '.$this->file.'.</error>');
  5405. unlink($this->json->getPath());
  5406. if (file_exists($this->lock)) {
  5407. unlink($this->lock);
  5408. }
  5409. } else {
  5410. $msg = ' to its ';
  5411. if ($this->lockBackup) {
  5412. $msg = ' and '.$this->lock.' to their ';
  5413. }
  5414. $io->writeError("\n".'<error>Installation failed, reverting '.$this->file.$msg.'original content.</error>');
  5415. file_put_contents($this->json->getPath(), $this->composerBackup);
  5416. if ($this->lockBackup) {
  5417. file_put_contents($this->lock, $this->lockBackup);
  5418. }
  5419. }
  5420. if ($hardExit) {
  5421. exit(1);
  5422. }
  5423. }
  5424. }
  5425. <?php
  5426. namespace Composer\Command;
  5427. use Composer\Script\Event as ScriptEvent;
  5428. use Composer\Script\ScriptEvents;
  5429. use Composer\Util\ProcessExecutor;
  5430. use Symfony\Component\Console\Input\InputInterface;
  5431. use Symfony\Component\Console\Input\InputOption;
  5432. use Symfony\Component\Console\Input\InputArgument;
  5433. use Symfony\Component\Console\Output\OutputInterface;
  5434. class RunScriptCommand extends BaseCommand
  5435. {
  5436. protected $scriptEvents = array(
  5437. ScriptEvents::PRE_INSTALL_CMD,
  5438. ScriptEvents::POST_INSTALL_CMD,
  5439. ScriptEvents::PRE_UPDATE_CMD,
  5440. ScriptEvents::POST_UPDATE_CMD,
  5441. ScriptEvents::PRE_STATUS_CMD,
  5442. ScriptEvents::POST_STATUS_CMD,
  5443. ScriptEvents::POST_ROOT_PACKAGE_INSTALL,
  5444. ScriptEvents::POST_CREATE_PROJECT_CMD,
  5445. ScriptEvents::PRE_ARCHIVE_CMD,
  5446. ScriptEvents::POST_ARCHIVE_CMD,
  5447. ScriptEvents::PRE_AUTOLOAD_DUMP,
  5448. ScriptEvents::POST_AUTOLOAD_DUMP,
  5449. );
  5450. protected function configure()
  5451. {
  5452. $this
  5453. ->setName('run-script')
  5454. ->setAliases(array('run'))
  5455. ->setDescription('Runs the scripts defined in composer.json.')
  5456. ->setDefinition(array(
  5457. new InputArgument('script', InputArgument::OPTIONAL, 'Script name to run.'),
  5458. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  5459. new InputOption('timeout', null, InputOption::VALUE_REQUIRED, 'Sets script timeout in seconds, or 0 for never.'),
  5460. new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
  5461. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),
  5462. new InputOption('list', 'l', InputOption::VALUE_NONE, 'List scripts.'),
  5463. ))
  5464. ->setHelp(
  5465. <<<EOT
  5466. The <info>run-script</info> command runs scripts defined in composer.json:
  5467. <info>php composer.phar run-script post-update-cmd</info>
  5468. Read more at https://getcomposer.org/doc/03-cli.md#run-script
  5469. EOT
  5470. )
  5471. ;
  5472. }
  5473. protected function execute(InputInterface $input, OutputInterface $output)
  5474. {
  5475. if ($input->getOption('list')) {
  5476. return $this->listScripts($output);
  5477. }
  5478. if (!$input->getArgument('script')) {
  5479. throw new \RuntimeException('Missing required argument "script"');
  5480. }
  5481. $script = $input->getArgument('script');
  5482. if (!in_array($script, $this->scriptEvents)) {
  5483. if (defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
  5484. throw new \InvalidArgumentException(sprintf('Script "%s" cannot be run with this command', $script));
  5485. }
  5486. }
  5487. $composer = $this->getComposer();
  5488. $devMode = $input->getOption('dev') || !$input->getOption('no-dev');
  5489. $event = new ScriptEvent($script, $composer, $this->getIO(), $devMode);
  5490. $hasListeners = $composer->getEventDispatcher()->hasEventListeners($event);
  5491. if (!$hasListeners) {
  5492. throw new \InvalidArgumentException(sprintf('Script "%s" is not defined in this package', $script));
  5493. }
  5494. $args = $input->getArgument('args');
  5495. if (null !== $timeout = $input->getOption('timeout')) {
  5496. if (!ctype_digit($timeout)) {
  5497. throw new \RuntimeException('Timeout value must be numeric and positive if defined, or 0 for forever');
  5498. }
  5499. ProcessExecutor::setTimeout((int) $timeout);
  5500. }
  5501. return $composer->getEventDispatcher()->dispatchScript($script, $devMode, $args);
  5502. }
  5503. protected function listScripts(OutputInterface $output)
  5504. {
  5505. $scripts = $this->getComposer()->getPackage()->getScripts();
  5506. if (!count($scripts)) {
  5507. return 0;
  5508. }
  5509. $io = $this->getIO();
  5510. $io->writeError('<info>scripts:</info>');
  5511. $table = array();
  5512. foreach ($scripts as $name => $script) {
  5513. $description = '';
  5514. try {
  5515. $cmd = $this->getApplication()->find($name);
  5516. if ($cmd instanceof ScriptAliasCommand) {
  5517. $description = $cmd->getDescription();
  5518. }
  5519. } catch (\Symfony\Component\Console\Exception\CommandNotFoundException $e) {
  5520. }
  5521. $table[] = array(' '.$name, $description);
  5522. }
  5523. $this->renderTable($table, $output);
  5524. return 0;
  5525. }
  5526. }
  5527. <?php
  5528. namespace Composer\Command;
  5529. use Symfony\Component\Console\Input\InputInterface;
  5530. use Symfony\Component\Console\Input\InputOption;
  5531. use Symfony\Component\Console\Input\InputArgument;
  5532. use Symfony\Component\Console\Output\OutputInterface;
  5533. class ScriptAliasCommand extends BaseCommand
  5534. {
  5535. private $script;
  5536. private $description;
  5537. public function __construct($script, $description)
  5538. {
  5539. $this->script = $script;
  5540. $this->description = empty($description) ? 'Runs the '.$script.' script as defined in composer.json.' : $description;
  5541. parent::__construct();
  5542. }
  5543. protected function configure()
  5544. {
  5545. $this
  5546. ->setName($this->script)
  5547. ->setDescription($this->description)
  5548. ->setDefinition(array(
  5549. new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
  5550. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),
  5551. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  5552. ))
  5553. ->setHelp(
  5554. <<<EOT
  5555. The <info>run-script</info> command runs scripts defined in composer.json:
  5556. <info>php composer.phar run-script post-update-cmd</info>
  5557. Read more at https://getcomposer.org/doc/03-cli.md#run-script
  5558. EOT
  5559. )
  5560. ;
  5561. }
  5562. protected function execute(InputInterface $input, OutputInterface $output)
  5563. {
  5564. $composer = $this->getComposer();
  5565. $args = $input->getArguments();
  5566. return $composer->getEventDispatcher()->dispatchScript($this->script, $input->getOption('dev') || !$input->getOption('no-dev'), $args['args']);
  5567. }
  5568. }
  5569. <?php
  5570. namespace Composer\Command;
  5571. use Composer\Factory;
  5572. use Symfony\Component\Console\Input\InputInterface;
  5573. use Symfony\Component\Console\Input\InputArgument;
  5574. use Symfony\Component\Console\Input\InputOption;
  5575. use Symfony\Component\Console\Output\OutputInterface;
  5576. use Composer\Repository\CompositeRepository;
  5577. use Composer\Repository\PlatformRepository;
  5578. use Composer\Repository\RepositoryInterface;
  5579. use Composer\Plugin\CommandEvent;
  5580. use Composer\Plugin\PluginEvents;
  5581. class SearchCommand extends BaseCommand
  5582. {
  5583. protected $matches;
  5584. protected $lowMatches = array();
  5585. protected $tokens;
  5586. protected $output;
  5587. protected $onlyName;
  5588. protected function configure()
  5589. {
  5590. $this
  5591. ->setName('search')
  5592. ->setDescription('Searches for packages.')
  5593. ->setDefinition(array(
  5594. new InputOption('only-name', 'N', InputOption::VALUE_NONE, 'Search only in name'),
  5595. new InputOption('type', 't', InputOption::VALUE_REQUIRED, 'Search for a specific package type'),
  5596. new InputArgument('tokens', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'tokens to search for'),
  5597. ))
  5598. ->setHelp(
  5599. <<<EOT
  5600. The search command searches for packages by its name
  5601. <info>php composer.phar search symfony composer</info>
  5602. Read more at https://getcomposer.org/doc/03-cli.md#search
  5603. EOT
  5604. )
  5605. ;
  5606. }
  5607. protected function execute(InputInterface $input, OutputInterface $output)
  5608. {
  5609. $platformRepo = new PlatformRepository;
  5610. $io = $this->getIO();
  5611. if (!($composer = $this->getComposer(false))) {
  5612. $composer = Factory::create($this->getIO(), array(), $input->hasParameterOption('--no-plugins'));
  5613. }
  5614. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  5615. $installedRepo = new CompositeRepository(array($localRepo, $platformRepo));
  5616. $repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories()));
  5617. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'search', $input, $output);
  5618. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5619. $onlyName = $input->getOption('only-name');
  5620. $type = $input->getOption('type') ?: null;
  5621. $flags = $onlyName ? RepositoryInterface::SEARCH_NAME : RepositoryInterface::SEARCH_FULLTEXT;
  5622. $results = $repos->search(implode(' ', $input->getArgument('tokens')), $flags, $type);
  5623. foreach ($results as $result) {
  5624. $io->write($result['name'] . (isset($result['description']) ? ' '. $result['description'] : ''));
  5625. }
  5626. return 0;
  5627. }
  5628. }
  5629. <?php
  5630. namespace Composer\Command;
  5631. use Composer\Composer;
  5632. use Composer\Factory;
  5633. use Composer\Config;
  5634. use Composer\Util\Filesystem;
  5635. use Composer\Util\Platform;
  5636. use Composer\SelfUpdate\Keys;
  5637. use Composer\SelfUpdate\Versions;
  5638. use Composer\IO\IOInterface;
  5639. use Composer\Downloader\FilesystemException;
  5640. use Symfony\Component\Console\Input\InputInterface;
  5641. use Symfony\Component\Console\Input\InputOption;
  5642. use Symfony\Component\Console\Input\InputArgument;
  5643. use Symfony\Component\Console\Output\OutputInterface;
  5644. use Symfony\Component\Finder\Finder;
  5645. class SelfUpdateCommand extends BaseCommand
  5646. {
  5647. const HOMEPAGE = 'getcomposer.org';
  5648. const OLD_INSTALL_EXT = '-old.phar';
  5649. protected function configure()
  5650. {
  5651. $this
  5652. ->setName('self-update')
  5653. ->setAliases(array('selfupdate'))
  5654. ->setDescription('Updates composer.phar to the latest version.')
  5655. ->setDefinition(array(
  5656. new InputOption('rollback', 'r', InputOption::VALUE_NONE, 'Revert to an older installation of composer'),
  5657. 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'),
  5658. new InputArgument('version', InputArgument::OPTIONAL, 'The version to update to'),
  5659. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  5660. new InputOption('update-keys', null, InputOption::VALUE_NONE, 'Prompt user for a key update'),
  5661. new InputOption('stable', null, InputOption::VALUE_NONE, 'Force an update to the stable channel'),
  5662. new InputOption('preview', null, InputOption::VALUE_NONE, 'Force an update to the preview channel'),
  5663. new InputOption('snapshot', null, InputOption::VALUE_NONE, 'Force an update to the snapshot channel'),
  5664. new InputOption('1', null, InputOption::VALUE_NONE, 'Force an update to the stable channel, but only use 1.x versions'),
  5665. new InputOption('2', null, InputOption::VALUE_NONE, 'Force an update to the stable channel, but only use 2.x versions'),
  5666. new InputOption('set-channel-only', null, InputOption::VALUE_NONE, 'Only store the channel as the default one and then exit'),
  5667. ))
  5668. ->setHelp(
  5669. <<<EOT
  5670. The <info>self-update</info> command checks getcomposer.org for newer
  5671. versions of composer and if found, installs the latest.
  5672. <info>php composer.phar self-update</info>
  5673. Read more at https://getcomposer.org/doc/03-cli.md#self-update-selfupdate-
  5674. EOT
  5675. )
  5676. ;
  5677. }
  5678. protected function execute(InputInterface $input, OutputInterface $output)
  5679. {
  5680. $config = Factory::createConfig();
  5681. if ($config->get('disable-tls') === true) {
  5682. $baseUrl = 'http://' . self::HOMEPAGE;
  5683. } else {
  5684. $baseUrl = 'https://' . self::HOMEPAGE;
  5685. }
  5686. $io = $this->getIO();
  5687. $httpDownloader = Factory::createHttpDownloader($io, $config);
  5688. $versionsUtil = new Versions($config, $httpDownloader);
  5689. $requestedChannel = null;
  5690. foreach (Versions::$channels as $channel) {
  5691. if ($input->getOption($channel)) {
  5692. $requestedChannel = $channel;
  5693. $versionsUtil->setChannel($channel);
  5694. break;
  5695. }
  5696. }
  5697. if ($input->getOption('set-channel-only')) {
  5698. return 0;
  5699. }
  5700. $cacheDir = $config->get('cache-dir');
  5701. $rollbackDir = $config->get('data-dir');
  5702. $home = $config->get('home');
  5703. $localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0];
  5704. if ($input->getOption('update-keys')) {
  5705. return $this->fetchKeys($io, $config);
  5706. }
  5707. if (!file_exists($localFilename)) {
  5708. throw new FilesystemException('Composer update failed: the "'.$localFilename.'" is not accessible');
  5709. }
  5710. $tmpDir = is_writable(dirname($localFilename)) ? dirname($localFilename) : $cacheDir;
  5711. if (!is_writable($tmpDir)) {
  5712. throw new FilesystemException('Composer update failed: the "'.$tmpDir.'" directory used to download the temp file could not be written');
  5713. }
  5714. if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
  5715. $composeUser = posix_getpwuid(posix_geteuid());
  5716. $homeOwner = posix_getpwuid(fileowner($home));
  5717. if (isset($composeUser['name'], $homeOwner['name']) && $composeUser['name'] !== $homeOwner['name']) {
  5718. $io->writeError('<warning>You are running composer as "'.$composeUser['name'].'", while "'.$home.'" is owned by "'.$homeOwner['name'].'"</warning>');
  5719. }
  5720. }
  5721. if ($input->getOption('rollback')) {
  5722. return $this->rollback($output, $rollbackDir, $localFilename);
  5723. }
  5724. $latest = $versionsUtil->getLatest();
  5725. $latestStable = $versionsUtil->getLatest('stable');
  5726. try {
  5727. $latestPreview = $versionsUtil->getLatest('preview');
  5728. } catch (\UnexpectedValueException $e) {
  5729. $latestPreview = $latestStable;
  5730. }
  5731. $latestVersion = $latest['version'];
  5732. $updateVersion = $input->getArgument('version') ?: $latestVersion;
  5733. $currentMajorVersion = preg_replace('{^(\d+).*}', '$1', Composer::getVersion());
  5734. $updateMajorVersion = preg_replace('{^(\d+).*}', '$1', $updateVersion);
  5735. $previewMajorVersion = preg_replace('{^(\d+).*}', '$1', $latestPreview['version']);
  5736. if ($versionsUtil->getChannel() === 'stable' && !$input->getArgument('version')) {
  5737. if ($currentMajorVersion < $updateMajorVersion) {
  5738. $skippedVersion = $updateVersion;
  5739. $versionsUtil->setChannel($currentMajorVersion);
  5740. $latest = $versionsUtil->getLatest();
  5741. $latestStable = $versionsUtil->getLatest('stable');
  5742. $latestVersion = $latest['version'];
  5743. $updateVersion = $latestVersion;
  5744. $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://github.com/composer/composer/releases for changelogs.</warning>');
  5745. } elseif ($currentMajorVersion < $previewMajorVersion) {
  5746. $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>');
  5747. }
  5748. }
  5749. if ($requestedChannel && is_numeric($requestedChannel) && strpos($latestStable['version'], $requestedChannel) !== 0) {
  5750. $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>');
  5751. }
  5752. if (preg_match('{^[0-9a-f]{40}$}', $updateVersion) && $updateVersion !== $latestVersion) {
  5753. $io->writeError('<error>You can not update to a specific SHA-1 as those phars are not available for download</error>');
  5754. return 1;
  5755. }
  5756. if (Composer::VERSION === $updateVersion) {
  5757. $io->writeError(sprintf('<info>You are already using composer version %s (%s channel).</info>', $updateVersion, $versionsUtil->getChannel()));
  5758. if ($input->getOption('clean-backups')) {
  5759. $this->cleanBackups($rollbackDir, $this->getLastBackupVersion($rollbackDir));
  5760. }
  5761. return 0;
  5762. }
  5763. $tempFilename = $tmpDir . '/' . basename($localFilename, '.phar').'-temp.phar';
  5764. $backupFile = sprintf(
  5765. '%s/%s-%s%s',
  5766. $rollbackDir,
  5767. strtr(Composer::RELEASE_DATE, ' :', '_-'),
  5768. preg_replace('{^([0-9a-f]{7})[0-9a-f]{33}$}', '$1', Composer::VERSION),
  5769. self::OLD_INSTALL_EXT
  5770. );
  5771. $updatingToTag = !preg_match('{^[0-9a-f]{40}$}', $updateVersion);
  5772. $io->write(sprintf("Upgrading to version <info>%s</info> (%s channel).", $updateVersion, $versionsUtil->getChannel()));
  5773. $remoteFilename = $baseUrl . ($updatingToTag ? "/download/{$updateVersion}/composer.phar" : '/composer.phar');
  5774. $signature = $httpDownloader->get($remoteFilename.'.sig')->getBody();
  5775. $io->writeError(' ', false);
  5776. $httpDownloader->copy($remoteFilename, $tempFilename);
  5777. $io->writeError('');
  5778. if (!file_exists($tempFilename) || !$signature) {
  5779. $io->writeError('<error>The download of the new composer version failed for an unexpected reason</error>');
  5780. return 1;
  5781. }
  5782. if (!extension_loaded('openssl') && $config->get('disable-tls')) {
  5783. $io->writeError('<warning>Skipping phar signature verification as you have disabled OpenSSL via config.disable-tls</warning>');
  5784. } else {
  5785. if (!extension_loaded('openssl')) {
  5786. throw new \RuntimeException('The openssl extension is required for phar signatures to be verified but it is not available. '
  5787. . '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.');
  5788. }
  5789. $sigFile = 'file://'.$home.'/' . ($updatingToTag ? 'keys.tags.pub' : 'keys.dev.pub');
  5790. if (!file_exists($sigFile)) {
  5791. file_put_contents(
  5792. $home.'/keys.dev.pub',
  5793. <<<DEVPUBKEY
  5794. -----BEGIN PUBLIC KEY-----
  5795. MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnBDHjZS6e0ZMoK3xTD7f
  5796. FNCzlXjX/Aie2dit8QXA03pSrOTbaMnxON3hUL47Lz3g1SC6YJEMVHr0zYq4elWi
  5797. i3ecFEgzLcj+pZM5X6qWu2Ozz4vWx3JYo1/a/HYdOuW9e3lwS8VtS0AVJA+U8X0A
  5798. hZnBmGpltHhO8hPKHgkJtkTUxCheTcbqn4wGHl8Z2SediDcPTLwqezWKUfrYzu1f
  5799. o/j3WFwFs6GtK4wdYtiXr+yspBZHO3y1udf8eFFGcb2V3EaLOrtfur6XQVizjOuk
  5800. 8lw5zzse1Qp/klHqbDRsjSzJ6iL6F4aynBc6Euqt/8ccNAIz0rLjLhOraeyj4eNn
  5801. 8iokwMKiXpcrQLTKH+RH1JCuOVxQ436bJwbSsp1VwiqftPQieN+tzqy+EiHJJmGf
  5802. TBAbWcncicCk9q2md+AmhNbvHO4PWbbz9TzC7HJb460jyWeuMEvw3gNIpEo2jYa9
  5803. pMV6cVqnSa+wOc0D7pC9a6bne0bvLcm3S+w6I5iDB3lZsb3A9UtRiSP7aGSo7D72
  5804. 8tC8+cIgZcI7k9vjvOqH+d7sdOU2yPCnRY6wFh62/g8bDnUpr56nZN1G89GwM4d4
  5805. r/TU7BQQIzsZgAiqOGXvVklIgAMiV0iucgf3rNBLjjeNEwNSTTG9F0CtQ+7JLwaE
  5806. wSEuAuRm+pRqi8BRnQ/GKUcCAwEAAQ==
  5807. -----END PUBLIC KEY-----
  5808. DEVPUBKEY
  5809. );
  5810. file_put_contents(
  5811. $home.'/keys.tags.pub',
  5812. <<<TAGSPUBKEY
  5813. -----BEGIN PUBLIC KEY-----
  5814. MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0Vi/2K6apCVj76nCnCl2
  5815. MQUPdK+A9eqkYBacXo2wQBYmyVlXm2/n/ZsX6pCLYPQTHyr5jXbkQzBw8SKqPdlh
  5816. vA7NpbMeNCz7wP/AobvUXM8xQuXKbMDTY2uZ4O7sM+PfGbptKPBGLe8Z8d2sUnTO
  5817. bXtX6Lrj13wkRto7st/w/Yp33RHe9SlqkiiS4MsH1jBkcIkEHsRaveZzedUaxY0M
  5818. mba0uPhGUInpPzEHwrYqBBEtWvP97t2vtfx8I5qv28kh0Y6t+jnjL1Urid2iuQZf
  5819. noCMFIOu4vksK5HxJxxrN0GOmGmwVQjOOtxkwikNiotZGPR4KsVj8NnBrLX7oGuM
  5820. nQvGciiu+KoC2r3HDBrpDeBVdOWxDzT5R4iI0KoLzFh2pKqwbY+obNPS2bj+2dgJ
  5821. rV3V5Jjry42QOCBN3c88wU1PKftOLj2ECpewY6vnE478IipiEu7EAdK8Zwj2LmTr
  5822. RKQUSa9k7ggBkYZWAeO/2Ag0ey3g2bg7eqk+sHEq5ynIXd5lhv6tC5PBdHlWipDK
  5823. tl2IxiEnejnOmAzGVivE1YGduYBjN+mjxDVy8KGBrjnz1JPgAvgdwJ2dYw4Rsc/e
  5824. TzCFWGk/HM6a4f0IzBWbJ5ot0PIi4amk07IotBXDWwqDiQTwyuGCym5EqWQ2BD95
  5825. RGv89BPD+2DLnJysngsvVaUCAwEAAQ==
  5826. -----END PUBLIC KEY-----
  5827. TAGSPUBKEY
  5828. );
  5829. }
  5830. $pubkeyid = openssl_pkey_get_public($sigFile);
  5831. $algo = defined('OPENSSL_ALGO_SHA384') ? OPENSSL_ALGO_SHA384 : 'SHA384';
  5832. if (!in_array('sha384', array_map('strtolower', openssl_get_md_methods()))) {
  5833. throw new \RuntimeException('SHA384 is not supported by your openssl extension, could not verify the phar file integrity');
  5834. }
  5835. $signature = json_decode($signature, true);
  5836. $signature = base64_decode($signature['sha384']);
  5837. $verified = 1 === openssl_verify(file_get_contents($tempFilename), $signature, $pubkeyid, $algo);
  5838. if (PHP_VERSION_ID < 80000) {
  5839. openssl_free_key($pubkeyid);
  5840. }
  5841. if (!$verified) {
  5842. 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');
  5843. }
  5844. }
  5845. if ($input->getOption('clean-backups')) {
  5846. $this->cleanBackups($rollbackDir);
  5847. }
  5848. if (!$this->setLocalPhar($localFilename, $tempFilename, $backupFile)) {
  5849. @unlink($tempFilename);
  5850. return 1;
  5851. }
  5852. if (file_exists($backupFile)) {
  5853. $io->writeError(sprintf(
  5854. 'Use <info>composer self-update --rollback</info> to return to version <comment>%s</comment>',
  5855. Composer::VERSION
  5856. ));
  5857. } else {
  5858. $io->writeError('<warning>A backup of the current version could not be written to '.$backupFile.', no rollback possible</warning>');
  5859. }
  5860. return 0;
  5861. }
  5862. protected function fetchKeys(IOInterface $io, Config $config)
  5863. {
  5864. if (!$io->isInteractive()) {
  5865. throw new \RuntimeException('Public keys can not be fetched in non-interactive mode, please run Composer interactively');
  5866. }
  5867. $io->write('Open <info>https://composer.github.io/pubkeys.html</info> to find the latest keys');
  5868. $validator = function ($value) {
  5869. if (!preg_match('{^-----BEGIN PUBLIC KEY-----$}', trim($value))) {
  5870. throw new \UnexpectedValueException('Invalid input');
  5871. }
  5872. return trim($value)."\n";
  5873. };
  5874. $devKey = '';
  5875. while (!preg_match('{(-----BEGIN PUBLIC KEY-----.+?-----END PUBLIC KEY-----)}s', $devKey, $match)) {
  5876. $devKey = $io->askAndValidate('Enter Dev / Snapshot Public Key (including lines with -----): ', $validator);
  5877. while ($line = $io->ask('')) {
  5878. $devKey .= trim($line)."\n";
  5879. if (trim($line) === '-----END PUBLIC KEY-----') {
  5880. break;
  5881. }
  5882. }
  5883. }
  5884. file_put_contents($keyPath = $config->get('home').'/keys.dev.pub', $match[0]);
  5885. $io->write('Stored key with fingerprint: ' . Keys::fingerprint($keyPath));
  5886. $tagsKey = '';
  5887. while (!preg_match('{(-----BEGIN PUBLIC KEY-----.+?-----END PUBLIC KEY-----)}s', $tagsKey, $match)) {
  5888. $tagsKey = $io->askAndValidate('Enter Tags Public Key (including lines with -----): ', $validator);
  5889. while ($line = $io->ask('')) {
  5890. $tagsKey .= trim($line)."\n";
  5891. if (trim($line) === '-----END PUBLIC KEY-----') {
  5892. break;
  5893. }
  5894. }
  5895. }
  5896. file_put_contents($keyPath = $config->get('home').'/keys.tags.pub', $match[0]);
  5897. $io->write('Stored key with fingerprint: ' . Keys::fingerprint($keyPath));
  5898. $io->write('Public keys stored in '.$config->get('home'));
  5899. }
  5900. protected function rollback(OutputInterface $output, $rollbackDir, $localFilename)
  5901. {
  5902. $rollbackVersion = $this->getLastBackupVersion($rollbackDir);
  5903. if (!$rollbackVersion) {
  5904. throw new \UnexpectedValueException('Composer rollback failed: no installation to roll back to in "'.$rollbackDir.'"');
  5905. }
  5906. $oldFile = $rollbackDir . '/' . $rollbackVersion . self::OLD_INSTALL_EXT;
  5907. if (!is_file($oldFile)) {
  5908. throw new FilesystemException('Composer rollback failed: "'.$oldFile.'" could not be found');
  5909. }
  5910. if (!is_readable($oldFile)) {
  5911. throw new FilesystemException('Composer rollback failed: "'.$oldFile.'" could not be read');
  5912. }
  5913. $io = $this->getIO();
  5914. $io->writeError(sprintf("Rolling back to version <info>%s</info>.", $rollbackVersion));
  5915. if (!$this->setLocalPhar($localFilename, $oldFile)) {
  5916. return 1;
  5917. }
  5918. return 0;
  5919. }
  5920. protected function setLocalPhar($localFilename, $newFilename, $backupTarget = null)
  5921. {
  5922. $io = $this->getIO();
  5923. @chmod($newFilename, fileperms($localFilename));
  5924. if (!$this->validatePhar($newFilename, $error)) {
  5925. $io->writeError('<error>The '.($backupTarget ? 'update' : 'backup').' file is corrupted ('.$error.')</error>');
  5926. if ($backupTarget) {
  5927. $io->writeError('<error>Please re-run the self-update command to try again.</error>');
  5928. }
  5929. return false;
  5930. }
  5931. if ($backupTarget) {
  5932. @copy($localFilename, $backupTarget);
  5933. }
  5934. try {
  5935. rename($newFilename, $localFilename);
  5936. return true;
  5937. } catch (\Exception $e) {
  5938. if (!is_writable(dirname($localFilename))
  5939. && $io->isInteractive()
  5940. && $this->isWindowsNonAdminUser()) {
  5941. return $this->tryAsWindowsAdmin($localFilename, $newFilename);
  5942. }
  5943. $action = 'Composer '.($backupTarget ? 'update' : 'rollback');
  5944. throw new FilesystemException($action.' failed: "'.$localFilename.'" could not be written.'.PHP_EOL.$e->getMessage());
  5945. }
  5946. }
  5947. protected function cleanBackups($rollbackDir, $except = null)
  5948. {
  5949. $finder = $this->getOldInstallationFinder($rollbackDir);
  5950. $io = $this->getIO();
  5951. $fs = new Filesystem;
  5952. foreach ($finder as $file) {
  5953. if ($except && $file->getBasename(self::OLD_INSTALL_EXT) === $except) {
  5954. continue;
  5955. }
  5956. $file = (string) $file;
  5957. $io->writeError('<info>Removing: '.$file.'</info>');
  5958. $fs->remove($file);
  5959. }
  5960. }
  5961. protected function getLastBackupVersion($rollbackDir)
  5962. {
  5963. $finder = $this->getOldInstallationFinder($rollbackDir);
  5964. $finder->sortByName();
  5965. $files = iterator_to_array($finder);
  5966. if (count($files)) {
  5967. return basename(end($files), self::OLD_INSTALL_EXT);
  5968. }
  5969. return false;
  5970. }
  5971. protected function getOldInstallationFinder($rollbackDir)
  5972. {
  5973. return Finder::create()
  5974. ->depth(0)
  5975. ->files()
  5976. ->name('*' . self::OLD_INSTALL_EXT)
  5977. ->in($rollbackDir);
  5978. }
  5979. protected function validatePhar($pharFile, &$error)
  5980. {
  5981. if (ini_get('phar.readonly')) {
  5982. return true;
  5983. }
  5984. try {
  5985. $phar = new \Phar($pharFile);
  5986. unset($phar);
  5987. $result = true;
  5988. } catch (\Exception $e) {
  5989. if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) {
  5990. throw $e;
  5991. }
  5992. $error = $e->getMessage();
  5993. $result = false;
  5994. }
  5995. return $result;
  5996. }
  5997. protected function isWindowsNonAdminUser()
  5998. {
  5999. if (!Platform::isWindows()) {
  6000. return false;
  6001. }
  6002. exec('fltmc.exe filters', $output, $exitCode);
  6003. return $exitCode !== 0;
  6004. }
  6005. protected function tryAsWindowsAdmin($localFilename, $newFilename)
  6006. {
  6007. $io = $this->getIO();
  6008. $io->writeError('<error>Unable to write "'.$localFilename.'". Access is denied.</error>');
  6009. $helpMessage = 'Please run the self-update command as an Administrator.';
  6010. $question = 'Complete this operation with Administrator privileges [<comment>Y,n</comment>]? ';
  6011. if (!$io->askConfirmation($question, false)) {
  6012. $io->writeError('<warning>Operation cancelled. '.$helpMessage.'</warning>');
  6013. return false;
  6014. }
  6015. $tmpFile = tempnam(sys_get_temp_dir(), '');
  6016. $script = $tmpFile.'.vbs';
  6017. rename($tmpFile, $script);
  6018. $checksum = hash_file('sha256', $newFilename);
  6019. $source = str_replace('/', '\\', $newFilename);
  6020. $destination = str_replace('/', '\\', $localFilename);
  6021. $vbs = <<<EOT
  6022. Set UAC = CreateObject("Shell.Application")
  6023. UAC.ShellExecute "cmd.exe", "/c move /y ""$source"" ""$destination""", "", "runas", 0
  6024. Wscript.Sleep(300)
  6025. EOT;
  6026. file_put_contents($script, $vbs);
  6027. exec('"'.$script.'"');
  6028. @unlink($script);
  6029. if ($result = (hash_file('sha256', $localFilename) === $checksum)) {
  6030. $io->writeError('<info>Operation succeeded.</info>');
  6031. } else {
  6032. $io->writeError('<error>Operation failed (file not written). '.$helpMessage.'</error>');
  6033. }
  6034. return $result;
  6035. }
  6036. }
  6037. <?php
  6038. namespace Composer\Command;
  6039. use Composer\Composer;
  6040. use Composer\DependencyResolver\DefaultPolicy;
  6041. use Composer\Json\JsonFile;
  6042. use Composer\Package\BasePackage;
  6043. use Composer\Package\CompletePackageInterface;
  6044. use Composer\Package\Link;
  6045. use Composer\Package\AliasPackage;
  6046. use Composer\Package\PackageInterface;
  6047. use Composer\Package\Version\VersionParser;
  6048. use Composer\Package\Version\VersionSelector;
  6049. use Composer\Plugin\CommandEvent;
  6050. use Composer\Plugin\PluginEvents;
  6051. use Composer\Repository\InstalledArrayRepository;
  6052. use Composer\Repository\ComposerRepository;
  6053. use Composer\Repository\CompositeRepository;
  6054. use Composer\Repository\PlatformRepository;
  6055. use Composer\Repository\RepositoryFactory;
  6056. use Composer\Repository\InstalledRepository;
  6057. use Composer\Repository\RepositoryInterface;
  6058. use Composer\Repository\RepositorySet;
  6059. use Composer\Repository\RootPackageRepository;
  6060. use Composer\Semver\Constraint\ConstraintInterface;
  6061. use Composer\Semver\Semver;
  6062. use Composer\Spdx\SpdxLicenses;
  6063. use Composer\Util\Platform;
  6064. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  6065. use Symfony\Component\Console\Input\InputArgument;
  6066. use Symfony\Component\Console\Input\InputInterface;
  6067. use Symfony\Component\Console\Input\InputOption;
  6068. use Symfony\Component\Console\Output\OutputInterface;
  6069. use Symfony\Component\Console\Terminal;
  6070. class ShowCommand extends BaseCommand
  6071. {
  6072. protected $versionParser;
  6073. protected $colors;
  6074. private $repositorySet;
  6075. protected function configure()
  6076. {
  6077. $this
  6078. ->setName('show')
  6079. ->setAliases(array('info'))
  6080. ->setDescription('Shows information about packages.')
  6081. ->setDefinition(array(
  6082. new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.'),
  6083. new InputArgument('version', InputArgument::OPTIONAL, 'Version or version constraint to inspect'),
  6084. new InputOption('all', null, InputOption::VALUE_NONE, 'List all packages'),
  6085. new InputOption('locked', null, InputOption::VALUE_NONE, 'List all locked packages'),
  6086. new InputOption('installed', 'i', InputOption::VALUE_NONE, 'List installed packages only (enabled by default, only present for BC).'),
  6087. new InputOption('platform', 'p', InputOption::VALUE_NONE, 'List platform packages only'),
  6088. new InputOption('available', 'a', InputOption::VALUE_NONE, 'List available packages only'),
  6089. new InputOption('self', 's', InputOption::VALUE_NONE, 'Show the root package information'),
  6090. new InputOption('name-only', 'N', InputOption::VALUE_NONE, 'List package names only'),
  6091. new InputOption('path', 'P', InputOption::VALUE_NONE, 'Show package paths'),
  6092. new InputOption('tree', 't', InputOption::VALUE_NONE, 'List the dependencies as a tree'),
  6093. new InputOption('latest', 'l', InputOption::VALUE_NONE, 'Show the latest version'),
  6094. new InputOption('outdated', 'o', InputOption::VALUE_NONE, 'Show the latest version but only for packages that are outdated'),
  6095. 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.'),
  6096. new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages that have minor SemVer-compatible updates. Use with the --outdated option.'),
  6097. new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'),
  6098. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code when there are outdated packages'),
  6099. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  6100. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  6101. ))
  6102. ->setHelp(
  6103. <<<EOT
  6104. The show command displays detailed information about a package, or
  6105. lists all packages available.
  6106. Read more at https://getcomposer.org/doc/03-cli.md#show
  6107. EOT
  6108. )
  6109. ;
  6110. }
  6111. protected function execute(InputInterface $input, OutputInterface $output)
  6112. {
  6113. $this->versionParser = new VersionParser;
  6114. if ($input->getOption('tree')) {
  6115. $this->initStyles($output);
  6116. }
  6117. $composer = $this->getComposer(false);
  6118. $io = $this->getIO();
  6119. if ($input->getOption('installed')) {
  6120. $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>');
  6121. }
  6122. if ($input->getOption('outdated')) {
  6123. $input->setOption('latest', true);
  6124. } elseif ($input->getOption('ignore')) {
  6125. $io->writeError('<warning>You are using the option "ignore" for action other than "outdated", it will be ignored.</warning>');
  6126. }
  6127. if ($input->getOption('direct') && ($input->getOption('all') || $input->getOption('available') || $input->getOption('platform'))) {
  6128. $io->writeError('The --direct (-D) option is not usable in combination with --all, --platform (-p) or --available (-a)');
  6129. return 1;
  6130. }
  6131. if ($input->getOption('tree') && ($input->getOption('all') || $input->getOption('available'))) {
  6132. $io->writeError('The --tree (-t) option is not usable in combination with --all or --available (-a)');
  6133. return 1;
  6134. }
  6135. if ($input->getOption('tree') && $input->getOption('latest')) {
  6136. $io->writeError('The --tree (-t) option is not usable in combination with --latest (-l)');
  6137. return 1;
  6138. }
  6139. if ($input->getOption('tree') && $input->getOption('path')) {
  6140. $io->writeError('The --tree (-t) option is not usable in combination with --path (-P)');
  6141. return 1;
  6142. }
  6143. $format = $input->getOption('format');
  6144. if (!in_array($format, array('text', 'json'))) {
  6145. $io->writeError(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  6146. return 1;
  6147. }
  6148. $platformOverrides = array();
  6149. if ($composer) {
  6150. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  6151. }
  6152. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  6153. $lockedRepo = null;
  6154. if ($input->getOption('self')) {
  6155. $package = $this->getComposer()->getPackage();
  6156. if ($input->getOption('name-only')) {
  6157. $io->write($package->getName());
  6158. return 0;
  6159. }
  6160. $repos = $installedRepo = new InstalledRepository(array(new RootPackageRepository($package)));
  6161. } elseif ($input->getOption('platform')) {
  6162. $repos = $installedRepo = new InstalledRepository(array($platformRepo));
  6163. } elseif ($input->getOption('available')) {
  6164. $installedRepo = new InstalledRepository(array($platformRepo));
  6165. if ($composer) {
  6166. $repos = new CompositeRepository($composer->getRepositoryManager()->getRepositories());
  6167. $installedRepo->addRepository($composer->getRepositoryManager()->getLocalRepository());
  6168. } else {
  6169. $defaultRepos = RepositoryFactory::defaultRepos($io);
  6170. $repos = new CompositeRepository($defaultRepos);
  6171. $io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
  6172. }
  6173. } elseif ($input->getOption('all') && $composer) {
  6174. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  6175. $locker = $composer->getLocker();
  6176. if ($locker->isLocked()) {
  6177. $lockedRepo = $locker->getLockedRepository(true);
  6178. $installedRepo = new InstalledRepository(array($lockedRepo, $localRepo, $platformRepo));
  6179. } else {
  6180. $installedRepo = new InstalledRepository(array($localRepo, $platformRepo));
  6181. }
  6182. $repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories()));
  6183. } elseif ($input->getOption('all')) {
  6184. $defaultRepos = RepositoryFactory::defaultRepos($io);
  6185. $io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
  6186. $installedRepo = new InstalledRepository(array($platformRepo));
  6187. $repos = new CompositeRepository(array_merge(array($installedRepo), $defaultRepos));
  6188. } elseif ($input->getOption('locked')) {
  6189. if (!$composer || !$composer->getLocker()->isLocked()) {
  6190. throw new \UnexpectedValueException('A valid composer.json and composer.lock files is required to run this command with --locked');
  6191. }
  6192. $locker = $composer->getLocker();
  6193. $lockedRepo = $locker->getLockedRepository(true);
  6194. $repos = $installedRepo = new InstalledRepository(array($lockedRepo));
  6195. } else {
  6196. if (!$composer) {
  6197. $composer = $this->getComposer();
  6198. }
  6199. $rootPkg = $composer->getPackage();
  6200. $repos = $installedRepo = new InstalledRepository(array($composer->getRepositoryManager()->getLocalRepository()));
  6201. if ($input->getOption('no-dev')) {
  6202. $packages = $this->filterRequiredPackages($installedRepo, $rootPkg);
  6203. $repos = $installedRepo = new InstalledRepository(array(new InstalledArrayRepository(array_map(function ($pkg) { return clone $pkg; }, $packages))));
  6204. }
  6205. if (!$installedRepo->getPackages() && ($rootPkg->getRequires() || $rootPkg->getDevRequires())) {
  6206. $io->writeError('<warning>No dependencies installed. Try running composer install or update.</warning>');
  6207. }
  6208. }
  6209. if ($composer) {
  6210. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'show', $input, $output);
  6211. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  6212. }
  6213. if ($input->getOption('latest') && null === $composer) {
  6214. $io->writeError('No composer.json found in the current directory, disabling "latest" option');
  6215. $input->setOption('latest', false);
  6216. }
  6217. $packageFilter = $input->getArgument('package');
  6218. if (($packageFilter && false === strpos($packageFilter, '*')) || !empty($package)) {
  6219. if (empty($package)) {
  6220. list($package, $versions) = $this->getPackage($installedRepo, $repos, $input->getArgument('package'), $input->getArgument('version'));
  6221. if (empty($package)) {
  6222. $options = $input->getOptions();
  6223. if (!isset($options['working-dir']) || !file_exists('composer.json')) {
  6224. if (PlatformRepository::isPlatformPackage($input->getArgument('package')) && !$input->getOption('platform')) {
  6225. throw new \InvalidArgumentException('Package ' . $packageFilter . ' not found, try using --platform (-p) to show platform packages.');
  6226. }
  6227. throw new \InvalidArgumentException('Package ' . $packageFilter . ' not found');
  6228. }
  6229. $io->writeError('Package ' . $packageFilter . ' not found in ' . $options['working-dir'] . '/composer.json');
  6230. return 1;
  6231. }
  6232. } else {
  6233. $versions = array($package->getPrettyVersion() => $package->getVersion());
  6234. }
  6235. $exitCode = 0;
  6236. if ($input->getOption('tree')) {
  6237. $arrayTree = $this->generatePackageTree($package, $installedRepo, $repos);
  6238. if ('json' === $format) {
  6239. $io->write(JsonFile::encode(array('installed' => array($arrayTree))));
  6240. } else {
  6241. $this->displayPackageTree(array($arrayTree));
  6242. }
  6243. } else {
  6244. $latestPackage = null;
  6245. if ($input->getOption('latest')) {
  6246. $latestPackage = $this->findLatestPackage($package, $composer, $platformRepo, $input->getOption('minor-only'));
  6247. }
  6248. if ($input->getOption('outdated') && $input->getOption('strict') && $latestPackage && $latestPackage->getFullPrettyVersion() !== $package->getFullPrettyVersion() && !$latestPackage->isAbandoned()) {
  6249. $exitCode = 1;
  6250. }
  6251. if ($input->getOption('path')) {
  6252. $io->write($package->getName(), false);
  6253. $io->write(' ' . strtok(realpath($composer->getInstallationManager()->getInstallPath($package)), "\r\n"));
  6254. return $exitCode;
  6255. }
  6256. if ('json' === $format) {
  6257. $this->printPackageInfoAsJson($package, $versions, $installedRepo, $latestPackage ?: null);
  6258. } else {
  6259. $this->printPackageInfo($package, $versions, $installedRepo, $latestPackage ?: null);
  6260. }
  6261. }
  6262. return $exitCode;
  6263. }
  6264. if ($input->getOption('tree')) {
  6265. $rootRequires = $this->getRootRequires();
  6266. $packages = $installedRepo->getPackages();
  6267. usort($packages, 'strcmp');
  6268. $arrayTree = array();
  6269. foreach ($packages as $package) {
  6270. if (in_array($package->getName(), $rootRequires, true)) {
  6271. $arrayTree[] = $this->generatePackageTree($package, $installedRepo, $repos);
  6272. }
  6273. }
  6274. if ('json' === $format) {
  6275. $io->write(JsonFile::encode(array('installed' => $arrayTree)));
  6276. } else {
  6277. $this->displayPackageTree($arrayTree);
  6278. }
  6279. return 0;
  6280. }
  6281. if ($repos instanceof CompositeRepository) {
  6282. $repos = $repos->getRepositories();
  6283. } elseif (!is_array($repos)) {
  6284. $repos = array($repos);
  6285. }
  6286. $packages = array();
  6287. $packageFilterRegex = null;
  6288. if (null !== $packageFilter) {
  6289. $packageFilterRegex = '{^'.str_replace('\\*', '.*?', preg_quote($packageFilter)).'$}i';
  6290. }
  6291. $packageListFilter = array();
  6292. if ($input->getOption('direct')) {
  6293. $packageListFilter = $this->getRootRequires();
  6294. }
  6295. if (class_exists('Symfony\Component\Console\Terminal')) {
  6296. $terminal = new Terminal();
  6297. $width = $terminal->getWidth();
  6298. } else {
  6299. list($width) = $this->getApplication()->getTerminalDimensions();
  6300. }
  6301. if (null === $width) {
  6302. $width = PHP_INT_MAX;
  6303. }
  6304. if (Platform::isWindows()) {
  6305. $width--;
  6306. } else {
  6307. $width = max(80, $width);
  6308. }
  6309. if ($input->getOption('path') && null === $composer) {
  6310. $io->writeError('No composer.json found in the current directory, disabling "path" option');
  6311. $input->setOption('path', false);
  6312. }
  6313. foreach ($repos as $repo) {
  6314. if ($repo === $platformRepo) {
  6315. $type = 'platform';
  6316. } elseif ($lockedRepo !== null && $repo === $lockedRepo) {
  6317. $type = 'locked';
  6318. } elseif ($repo === $installedRepo || in_array($repo, $installedRepo->getRepositories(), true)) {
  6319. $type = 'installed';
  6320. } else {
  6321. $type = 'available';
  6322. }
  6323. if ($repo instanceof ComposerRepository) {
  6324. foreach ($repo->getPackageNames($packageFilter) as $name) {
  6325. $packages[$type][$name] = $name;
  6326. }
  6327. } else {
  6328. foreach ($repo->getPackages() as $package) {
  6329. if (!isset($packages[$type][$package->getName()])
  6330. || !is_object($packages[$type][$package->getName()])
  6331. || version_compare($packages[$type][$package->getName()]->getVersion(), $package->getVersion(), '<')
  6332. ) {
  6333. while ($package instanceof AliasPackage) {
  6334. $package = $package->getAliasOf();
  6335. }
  6336. if (!$packageFilterRegex || preg_match($packageFilterRegex, $package->getName())) {
  6337. if (!$packageListFilter || in_array($package->getName(), $packageListFilter, true)) {
  6338. $packages[$type][$package->getName()] = $package;
  6339. }
  6340. }
  6341. }
  6342. }
  6343. }
  6344. }
  6345. $showAllTypes = $input->getOption('all');
  6346. $showLatest = $input->getOption('latest');
  6347. $showMinorOnly = $input->getOption('minor-only');
  6348. $ignoredPackages = array_map('strtolower', $input->getOption('ignore'));
  6349. $indent = $showAllTypes ? ' ' : '';
  6350. $latestPackages = array();
  6351. $exitCode = 0;
  6352. $viewData = array();
  6353. $viewMetaData = array();
  6354. foreach (array('platform' => true, 'locked' => true, 'available' => false, 'installed' => true) as $type => $showVersion) {
  6355. if (isset($packages[$type])) {
  6356. ksort($packages[$type]);
  6357. $nameLength = $versionLength = $latestLength = 0;
  6358. if ($showLatest && $showVersion) {
  6359. foreach ($packages[$type] as $package) {
  6360. if (is_object($package)) {
  6361. $latestPackage = $this->findLatestPackage($package, $composer, $platformRepo, $showMinorOnly);
  6362. if ($latestPackage === false) {
  6363. continue;
  6364. }
  6365. $latestPackages[$package->getPrettyName()] = $latestPackage;
  6366. }
  6367. }
  6368. }
  6369. $writePath = !$input->getOption('name-only') && $input->getOption('path');
  6370. $writeVersion = !$input->getOption('name-only') && !$input->getOption('path') && $showVersion;
  6371. $writeLatest = $writeVersion && $showLatest;
  6372. $writeDescription = !$input->getOption('name-only') && !$input->getOption('path');
  6373. $hasOutdatedPackages = false;
  6374. $viewData[$type] = array();
  6375. foreach ($packages[$type] as $package) {
  6376. $packageViewData = array();
  6377. if (is_object($package)) {
  6378. $latestPackage = null;
  6379. if ($showLatest && isset($latestPackages[$package->getPrettyName()])) {
  6380. $latestPackage = $latestPackages[$package->getPrettyName()];
  6381. }
  6382. $packageIsUpToDate = $latestPackage && $latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion() && !$latestPackage->isAbandoned();
  6383. $packageIsIgnored = \in_array($package->getPrettyName(), $ignoredPackages, true);
  6384. if ($input->getOption('outdated') && ($packageIsUpToDate || $packageIsIgnored)) {
  6385. continue;
  6386. }
  6387. if ($input->getOption('outdated') || $input->getOption('strict')) {
  6388. $hasOutdatedPackages = true;
  6389. }
  6390. $packageViewData['name'] = $package->getPrettyName();
  6391. $nameLength = max($nameLength, strlen($package->getPrettyName()));
  6392. if ($writeVersion) {
  6393. $packageViewData['version'] = $package->getFullPrettyVersion();
  6394. $versionLength = max($versionLength, strlen($package->getFullPrettyVersion()));
  6395. }
  6396. if ($writeLatest && $latestPackage) {
  6397. $packageViewData['latest'] = $latestPackage->getFullPrettyVersion();
  6398. $packageViewData['latest-status'] = $this->getUpdateStatus($latestPackage, $package);
  6399. $latestLength = max($latestLength, strlen($latestPackage->getFullPrettyVersion()));
  6400. }
  6401. if ($writeDescription) {
  6402. $packageViewData['description'] = $package->getDescription();
  6403. }
  6404. if ($writePath) {
  6405. $packageViewData['path'] = strtok(realpath($composer->getInstallationManager()->getInstallPath($package)), "\r\n");
  6406. }
  6407. if ($latestPackage && $latestPackage->isAbandoned()) {
  6408. $replacement = is_string($latestPackage->getReplacementPackage())
  6409. ? 'Use ' . $latestPackage->getReplacementPackage() . ' instead'
  6410. : 'No replacement was suggested';
  6411. $packageWarning = sprintf(
  6412. 'Package %s is abandoned, you should avoid using it. %s.',
  6413. $package->getPrettyName(),
  6414. $replacement
  6415. );
  6416. $packageViewData['warning'] = $packageWarning;
  6417. }
  6418. } else {
  6419. $packageViewData['name'] = $package;
  6420. $nameLength = max($nameLength, strlen($package));
  6421. }
  6422. $viewData[$type][] = $packageViewData;
  6423. }
  6424. $viewMetaData[$type] = array(
  6425. 'nameLength' => $nameLength,
  6426. 'versionLength' => $versionLength,
  6427. 'latestLength' => $latestLength,
  6428. );
  6429. if ($input->getOption('strict') && $hasOutdatedPackages) {
  6430. $exitCode = 1;
  6431. break;
  6432. }
  6433. }
  6434. }
  6435. if ('json' === $format) {
  6436. $io->write(JsonFile::encode($viewData));
  6437. } else {
  6438. foreach ($viewData as $type => $packages) {
  6439. $nameLength = $viewMetaData[$type]['nameLength'];
  6440. $versionLength = $viewMetaData[$type]['versionLength'];
  6441. $latestLength = $viewMetaData[$type]['latestLength'];
  6442. $writeVersion = $nameLength + $versionLength + 3 <= $width;
  6443. $writeLatest = $nameLength + $versionLength + $latestLength + 3 <= $width;
  6444. $writeDescription = $nameLength + $versionLength + $latestLength + 24 <= $width;
  6445. if ($writeLatest && !$io->isDecorated()) {
  6446. $latestLength += 2;
  6447. }
  6448. if ($showAllTypes) {
  6449. if ('available' === $type) {
  6450. $io->write('<comment>' . $type . '</comment>:');
  6451. } else {
  6452. $io->write('<info>' . $type . '</info>:');
  6453. }
  6454. }
  6455. foreach ($packages as $package) {
  6456. $io->write($indent . str_pad($package['name'], $nameLength, ' '), false);
  6457. if (isset($package['version']) && $writeVersion) {
  6458. $io->write(' ' . str_pad($package['version'], $versionLength, ' '), false);
  6459. }
  6460. if (isset($package['latest']) && $writeLatest) {
  6461. $latestVersion = $package['latest'];
  6462. $updateStatus = $package['latest-status'];
  6463. $style = $this->updateStatusToVersionStyle($updateStatus);
  6464. if (!$io->isDecorated()) {
  6465. $latestVersion = str_replace(array('up-to-date', 'semver-safe-update', 'update-possible'), array('=', '!', '~'), $updateStatus) . ' ' . $latestVersion;
  6466. }
  6467. $io->write(' <' . $style . '>' . str_pad($latestVersion, $latestLength, ' ') . '</' . $style . '>', false);
  6468. }
  6469. if (isset($package['description']) && $writeDescription) {
  6470. $description = strtok($package['description'], "\r\n");
  6471. $remaining = $width - $nameLength - $versionLength - 4;
  6472. if ($writeLatest) {
  6473. $remaining -= $latestLength;
  6474. }
  6475. if (strlen($description) > $remaining) {
  6476. $description = substr($description, 0, $remaining - 3) . '...';
  6477. }
  6478. $io->write(' ' . $description, false);
  6479. }
  6480. if (isset($package['path'])) {
  6481. $io->write(' ' . $package['path'], false);
  6482. }
  6483. $io->write('');
  6484. if (isset($package['warning'])) {
  6485. $io->write('<warning>' . $package['warning'] . '</warning>');
  6486. }
  6487. }
  6488. if ($showAllTypes) {
  6489. $io->write('');
  6490. }
  6491. }
  6492. }
  6493. return $exitCode;
  6494. }
  6495. protected function getRootRequires()
  6496. {
  6497. $rootPackage = $this->getComposer()->getPackage();
  6498. return array_map(
  6499. 'strtolower',
  6500. array_keys(array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires()))
  6501. );
  6502. }
  6503. protected function getVersionStyle(PackageInterface $latestPackage, PackageInterface $package)
  6504. {
  6505. return $this->updateStatusToVersionStyle($this->getUpdateStatus($latestPackage, $package));
  6506. }
  6507. protected function getPackage(InstalledRepository $installedRepo, RepositoryInterface $repos, $name, $version = null)
  6508. {
  6509. $name = strtolower($name);
  6510. $constraint = is_string($version) ? $this->versionParser->parseConstraints($version) : $version;
  6511. $policy = new DefaultPolicy();
  6512. $repositorySet = new RepositorySet('dev');
  6513. $repositorySet->allowInstalledRepositories();
  6514. $repositorySet->addRepository($repos);
  6515. $matchedPackage = null;
  6516. $versions = array();
  6517. if (PlatformRepository::isPlatformPackage($name)) {
  6518. $pool = $repositorySet->createPoolWithAllPackages();
  6519. } else {
  6520. $pool = $repositorySet->createPoolForPackage($name);
  6521. }
  6522. $matches = $pool->whatProvides($name, $constraint);
  6523. foreach ($matches as $index => $package) {
  6524. if (null === $version && $installedRepo->hasPackage($package)) {
  6525. $matchedPackage = $package;
  6526. }
  6527. $versions[$package->getPrettyVersion()] = $package->getVersion();
  6528. $matches[$index] = $package->getId();
  6529. }
  6530. if (!$matchedPackage && $matches && $preferred = $policy->selectPreferredPackages($pool, $matches)) {
  6531. $matchedPackage = $pool->literalToPackage($preferred[0]);
  6532. }
  6533. return array($matchedPackage, $versions);
  6534. }
  6535. protected function printPackageInfo(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null)
  6536. {
  6537. $io = $this->getIO();
  6538. $this->printMeta($package, $versions, $installedRepo, $latestPackage ?: null);
  6539. $this->printLinks($package, Link::TYPE_REQUIRE);
  6540. $this->printLinks($package, Link::TYPE_DEV_REQUIRE, 'requires (dev)');
  6541. if ($package->getSuggests()) {
  6542. $io->write("\n<info>suggests</info>");
  6543. foreach ($package->getSuggests() as $suggested => $reason) {
  6544. $io->write($suggested . ' <comment>' . $reason . '</comment>');
  6545. }
  6546. }
  6547. $this->printLinks($package, Link::TYPE_PROVIDE);
  6548. $this->printLinks($package, Link::TYPE_CONFLICT);
  6549. $this->printLinks($package, Link::TYPE_REPLACE);
  6550. }
  6551. protected function printMeta(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null)
  6552. {
  6553. $io = $this->getIO();
  6554. $io->write('<info>name</info> : ' . $package->getPrettyName());
  6555. $io->write('<info>descrip.</info> : ' . $package->getDescription());
  6556. $io->write('<info>keywords</info> : ' . implode(', ', $package->getKeywords() ?: array()));
  6557. $this->printVersions($package, $versions, $installedRepo);
  6558. if ($latestPackage) {
  6559. $style = $this->getVersionStyle($latestPackage, $package);
  6560. $io->write('<info>latest</info> : <'.$style.'>' . $latestPackage->getPrettyVersion() . '</'.$style.'>');
  6561. } else {
  6562. $latestPackage = $package;
  6563. }
  6564. $io->write('<info>type</info> : ' . $package->getType());
  6565. $this->printLicenses($package);
  6566. $io->write('<info>homepage</info> : ' . $package->getHomepage());
  6567. $io->write('<info>source</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getSourceType(), $package->getSourceUrl(), $package->getSourceReference()));
  6568. $io->write('<info>dist</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getDistType(), $package->getDistUrl(), $package->getDistReference()));
  6569. if ($installedRepo->hasPackage($package)) {
  6570. $io->write('<info>path</info> : ' . sprintf('%s', realpath($this->getComposer()->getInstallationManager()->getInstallPath($package))));
  6571. }
  6572. $io->write('<info>names</info> : ' . implode(', ', $package->getNames()));
  6573. if ($latestPackage->isAbandoned()) {
  6574. $replacement = ($latestPackage->getReplacementPackage() !== null)
  6575. ? ' The author suggests using the ' . $latestPackage->getReplacementPackage(). ' package instead.'
  6576. : null;
  6577. $io->writeError(
  6578. sprintf('<warning>Attention: This package is abandoned and no longer maintained.%s</warning>', $replacement)
  6579. );
  6580. }
  6581. if ($package->getSupport()) {
  6582. $io->write("\n<info>support</info>");
  6583. foreach ($package->getSupport() as $type => $value) {
  6584. $io->write('<comment>' . $type . '</comment> : '.$value);
  6585. }
  6586. }
  6587. if ($package->getAutoload()) {
  6588. $io->write("\n<info>autoload</info>");
  6589. foreach ($package->getAutoload() as $type => $autoloads) {
  6590. $io->write('<comment>' . $type . '</comment>');
  6591. if ($type === 'psr-0' || $type === 'psr-4') {
  6592. foreach ($autoloads as $name => $path) {
  6593. $io->write(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
  6594. }
  6595. } elseif ($type === 'classmap') {
  6596. $io->write(implode(', ', $autoloads));
  6597. }
  6598. }
  6599. if ($package->getIncludePaths()) {
  6600. $io->write('<comment>include-path</comment>');
  6601. $io->write(implode(', ', $package->getIncludePaths()));
  6602. }
  6603. }
  6604. }
  6605. protected function printVersions(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo)
  6606. {
  6607. $versions = array_keys($versions);
  6608. $versions = Semver::rsort($versions);
  6609. if ($installedPackages = $installedRepo->findPackages($package->getName())) {
  6610. foreach ($installedPackages as $installedPackage) {
  6611. $installedVersion = $installedPackage->getPrettyVersion();
  6612. $key = array_search($installedVersion, $versions);
  6613. if (false !== $key) {
  6614. $versions[$key] = '<info>* ' . $installedVersion . '</info>';
  6615. }
  6616. }
  6617. }
  6618. $versions = implode(', ', $versions);
  6619. $this->getIO()->write('<info>versions</info> : ' . $versions);
  6620. }
  6621. protected function printLinks(CompletePackageInterface $package, $linkType, $title = null)
  6622. {
  6623. $title = $title ?: $linkType;
  6624. $io = $this->getIO();
  6625. if ($links = $package->{'get'.ucfirst($linkType)}()) {
  6626. $io->write("\n<info>" . $title . "</info>");
  6627. foreach ($links as $link) {
  6628. $io->write($link->getTarget() . ' <comment>' . $link->getPrettyConstraint() . '</comment>');
  6629. }
  6630. }
  6631. }
  6632. protected function printLicenses(CompletePackageInterface $package)
  6633. {
  6634. $spdxLicenses = new SpdxLicenses();
  6635. $licenses = $package->getLicense();
  6636. $io = $this->getIO();
  6637. foreach ($licenses as $licenseId) {
  6638. $license = $spdxLicenses->getLicenseByIdentifier($licenseId);
  6639. if (!$license) {
  6640. $out = $licenseId;
  6641. } else {
  6642. if ($license[1] === true) {
  6643. $out = sprintf('%s (%s) (OSI approved) %s', $license[0], $licenseId, $license[2]);
  6644. } else {
  6645. $out = sprintf('%s (%s) %s', $license[0], $licenseId, $license[2]);
  6646. }
  6647. }
  6648. $io->write('<info>license</info> : ' . $out);
  6649. }
  6650. }
  6651. protected function printPackageInfoAsJson(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null)
  6652. {
  6653. $json = array(
  6654. 'name' => $package->getPrettyName(),
  6655. 'description' => $package->getDescription(),
  6656. 'keywords' => $package->getKeywords() ?: array(),
  6657. 'type' => $package->getType(),
  6658. 'homepage' => $package->getHomepage(),
  6659. 'names' => $package->getNames()
  6660. );
  6661. $json = $this->appendVersions($json, $versions);
  6662. $json = $this->appendLicenses($json, $package);
  6663. if ($latestPackage) {
  6664. $json['latest'] = $latestPackage->getPrettyVersion();
  6665. } else {
  6666. $latestPackage = $package;
  6667. }
  6668. if ($package->getSourceType()) {
  6669. $json['source'] = array(
  6670. 'type' => $package->getSourceType(),
  6671. 'url' => $package->getSourceUrl(),
  6672. 'reference' => $package->getSourceReference()
  6673. );
  6674. }
  6675. if ($package->getDistType()) {
  6676. $json['dist'] = array(
  6677. 'type' => $package->getDistType(),
  6678. 'url' => $package->getDistUrl(),
  6679. 'reference' => $package->getDistReference()
  6680. );
  6681. }
  6682. if ($installedRepo->hasPackage($package)) {
  6683. $json['path'] = realpath($this->getComposer()->getInstallationManager()->getInstallPath($package));
  6684. if ($json['path'] === false) {
  6685. unset($json['path']);
  6686. }
  6687. }
  6688. if ($latestPackage->isAbandoned()) {
  6689. $json['replacement'] = $latestPackage->getReplacementPackage();
  6690. }
  6691. if ($package->getSuggests()) {
  6692. $json['suggests'] = $package->getSuggests();
  6693. }
  6694. if ($package->getSupport()) {
  6695. $json['support'] = $package->getSupport();
  6696. }
  6697. $json = $this->appendAutoload($json, $package);
  6698. if ($package->getIncludePaths()) {
  6699. $json['include_path'] = $package->getIncludePaths();
  6700. }
  6701. $json = $this->appendLinks($json, $package);
  6702. $this->getIO()->write(JsonFile::encode($json));
  6703. }
  6704. private function appendVersions($json, array $versions)
  6705. {
  6706. uasort($versions, 'version_compare');
  6707. $versions = array_keys(array_reverse($versions));
  6708. $json['versions'] = $versions;
  6709. return $json;
  6710. }
  6711. private function appendLicenses($json, CompletePackageInterface $package)
  6712. {
  6713. if ($licenses = $package->getLicense()) {
  6714. $spdxLicenses = new SpdxLicenses();
  6715. $json['licenses'] = array_map(function ($licenseId) use ($spdxLicenses) {
  6716. $license = $spdxLicenses->getLicenseByIdentifier($licenseId);
  6717. if (!$license) {
  6718. return $licenseId;
  6719. }
  6720. return array(
  6721. 'name' => $license[0],
  6722. 'osi' => $licenseId,
  6723. 'url' => $license[2]
  6724. );
  6725. }, $licenses);
  6726. }
  6727. return $json;
  6728. }
  6729. private function appendAutoload($json, CompletePackageInterface $package)
  6730. {
  6731. if ($package->getAutoload()) {
  6732. $autoload = array();
  6733. foreach ($package->getAutoload() as $type => $autoloads) {
  6734. if ($type === 'psr-0' || $type === 'psr-4') {
  6735. $psr = array();
  6736. foreach ($autoloads as $name => $path) {
  6737. if (!$path) {
  6738. $path = '.';
  6739. }
  6740. $psr[$name ?: '*'] = $path;
  6741. }
  6742. $autoload[$type] = $psr;
  6743. } elseif ($type === 'classmap') {
  6744. $autoload['classmap'] = $autoloads;
  6745. }
  6746. }
  6747. $json['autoload'] = $autoload;
  6748. }
  6749. return $json;
  6750. }
  6751. private function appendLinks($json, CompletePackageInterface $package)
  6752. {
  6753. foreach (Link::$TYPES as $linkType) {
  6754. $json = $this->appendLink($json, $package, $linkType);
  6755. }
  6756. return $json;
  6757. }
  6758. private function appendLink($json, CompletePackageInterface $package, $linkType)
  6759. {
  6760. $links = $package->{'get' . ucfirst($linkType)}();
  6761. if ($links) {
  6762. $json[$linkType] = array();
  6763. foreach ($links as $link) {
  6764. $json[$linkType][$link->getTarget()] = $link->getPrettyConstraint();
  6765. }
  6766. }
  6767. return $json;
  6768. }
  6769. protected function initStyles(OutputInterface $output)
  6770. {
  6771. $this->colors = array(
  6772. 'green',
  6773. 'yellow',
  6774. 'cyan',
  6775. 'magenta',
  6776. 'blue',
  6777. );
  6778. foreach ($this->colors as $color) {
  6779. $style = new OutputFormatterStyle($color);
  6780. $output->getFormatter()->setStyle($color, $style);
  6781. }
  6782. }
  6783. protected function displayPackageTree(array $arrayTree)
  6784. {
  6785. $io = $this->getIO();
  6786. foreach ($arrayTree as $package) {
  6787. $io->write(sprintf('<info>%s</info>', $package['name']), false);
  6788. $io->write(' ' . $package['version'], false);
  6789. $io->write(' ' . strtok($package['description'], "\r\n"));
  6790. if (isset($package['requires'])) {
  6791. $requires = $package['requires'];
  6792. $treeBar = '├';
  6793. $j = 0;
  6794. $total = count($requires);
  6795. foreach ($requires as $require) {
  6796. $requireName = $require['name'];
  6797. $j++;
  6798. if ($j === $total) {
  6799. $treeBar = 'â””';
  6800. }
  6801. $level = 1;
  6802. $color = $this->colors[$level];
  6803. $info = sprintf(
  6804. '%s──<%s>%s</%s> %s',
  6805. $treeBar,
  6806. $color,
  6807. $requireName,
  6808. $color,
  6809. $require['version']
  6810. );
  6811. $this->writeTreeLine($info);
  6812. $treeBar = str_replace('â””', ' ', $treeBar);
  6813. $packagesInTree = array($package['name'], $requireName);
  6814. $this->displayTree($require, $packagesInTree, $treeBar, $level + 1);
  6815. }
  6816. }
  6817. }
  6818. }
  6819. protected function generatePackageTree(
  6820. PackageInterface $package,
  6821. InstalledRepository $installedRepo,
  6822. RepositoryInterface $remoteRepos
  6823. ) {
  6824. $requires = $package->getRequires();
  6825. ksort($requires);
  6826. $children = array();
  6827. foreach ($requires as $requireName => $require) {
  6828. $packagesInTree = array($package->getName(), $requireName);
  6829. $treeChildDesc = array(
  6830. 'name' => $requireName,
  6831. 'version' => $require->getPrettyConstraint(),
  6832. );
  6833. $deepChildren = $this->addTree($requireName, $require, $installedRepo, $remoteRepos, $packagesInTree);
  6834. if ($deepChildren) {
  6835. $treeChildDesc['requires'] = $deepChildren;
  6836. }
  6837. $children[] = $treeChildDesc;
  6838. }
  6839. $tree = array(
  6840. 'name' => $package->getPrettyName(),
  6841. 'version' => $package->getPrettyVersion(),
  6842. 'description' => $package->getDescription(),
  6843. );
  6844. if ($children) {
  6845. $tree['requires'] = $children;
  6846. }
  6847. return $tree;
  6848. }
  6849. protected function displayTree(
  6850. $package,
  6851. array $packagesInTree,
  6852. $previousTreeBar = '├',
  6853. $level = 1
  6854. ) {
  6855. $previousTreeBar = str_replace('├', '│', $previousTreeBar);
  6856. if (is_array($package) && isset($package['requires'])) {
  6857. $requires = $package['requires'];
  6858. $treeBar = $previousTreeBar . ' ├';
  6859. $i = 0;
  6860. $total = count($requires);
  6861. foreach ($requires as $require) {
  6862. $currentTree = $packagesInTree;
  6863. $i++;
  6864. if ($i === $total) {
  6865. $treeBar = $previousTreeBar . ' â””';
  6866. }
  6867. $colorIdent = $level % count($this->colors);
  6868. $color = $this->colors[$colorIdent];
  6869. $circularWarn = in_array(
  6870. $require['name'],
  6871. $currentTree,
  6872. true
  6873. ) ? '(circular dependency aborted here)' : '';
  6874. $info = rtrim(sprintf(
  6875. '%s──<%s>%s</%s> %s %s',
  6876. $treeBar,
  6877. $color,
  6878. $require['name'],
  6879. $color,
  6880. $require['version'],
  6881. $circularWarn
  6882. ));
  6883. $this->writeTreeLine($info);
  6884. $treeBar = str_replace('â””', ' ', $treeBar);
  6885. $currentTree[] = $require['name'];
  6886. $this->displayTree($require, $currentTree, $treeBar, $level + 1);
  6887. }
  6888. }
  6889. }
  6890. protected function addTree(
  6891. $name,
  6892. $package,
  6893. InstalledRepository $installedRepo,
  6894. RepositoryInterface $remoteRepos,
  6895. array $packagesInTree
  6896. ) {
  6897. $children = array();
  6898. list($package) = $this->getPackage(
  6899. $installedRepo,
  6900. $remoteRepos,
  6901. $name,
  6902. $package->getPrettyConstraint() === 'self.version' ? $package->getConstraint() : $package->getPrettyConstraint()
  6903. );
  6904. if (is_object($package)) {
  6905. $requires = $package->getRequires();
  6906. ksort($requires);
  6907. foreach ($requires as $requireName => $require) {
  6908. $currentTree = $packagesInTree;
  6909. $treeChildDesc = array(
  6910. 'name' => $requireName,
  6911. 'version' => $require->getPrettyConstraint(),
  6912. );
  6913. if (!in_array($requireName, $currentTree, true)) {
  6914. $currentTree[] = $requireName;
  6915. $deepChildren = $this->addTree($requireName, $require, $installedRepo, $remoteRepos, $currentTree);
  6916. if ($deepChildren) {
  6917. $treeChildDesc['requires'] = $deepChildren;
  6918. }
  6919. }
  6920. $children[] = $treeChildDesc;
  6921. }
  6922. }
  6923. return $children;
  6924. }
  6925. private function updateStatusToVersionStyle($updateStatus)
  6926. {
  6927. return str_replace(array('up-to-date', 'semver-safe-update', 'update-possible'), array('info', 'highlight', 'comment'), $updateStatus);
  6928. }
  6929. private function getUpdateStatus(PackageInterface $latestPackage, PackageInterface $package)
  6930. {
  6931. if ($latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion()) {
  6932. return 'up-to-date';
  6933. }
  6934. $constraint = $package->getVersion();
  6935. if (0 !== strpos($constraint, 'dev-')) {
  6936. $constraint = '^'.$constraint;
  6937. }
  6938. if ($latestPackage->getVersion() && Semver::satisfies($latestPackage->getVersion(), $constraint)) {
  6939. return 'semver-safe-update';
  6940. }
  6941. return 'update-possible';
  6942. }
  6943. private function writeTreeLine($line)
  6944. {
  6945. $io = $this->getIO();
  6946. if (!$io->isDecorated()) {
  6947. $line = str_replace(array('└', '├', '──', '│'), array('`-', '|-', '-', '|'), $line);
  6948. }
  6949. $io->write($line);
  6950. }
  6951. private function findLatestPackage(PackageInterface $package, Composer $composer, PlatformRepository $platformRepo, $minorOnly = false)
  6952. {
  6953. $name = $package->getName();
  6954. $versionSelector = new VersionSelector($this->getRepositorySet($composer), $platformRepo);
  6955. $stability = $composer->getPackage()->getMinimumStability();
  6956. $flags = $composer->getPackage()->getStabilityFlags();
  6957. if (isset($flags[$name])) {
  6958. $stability = array_search($flags[$name], BasePackage::$stabilities, true);
  6959. }
  6960. $bestStability = $stability;
  6961. if ($composer->getPackage()->getPreferStable()) {
  6962. $bestStability = $package->getStability();
  6963. }
  6964. $targetVersion = null;
  6965. if (0 === strpos($package->getVersion(), 'dev-')) {
  6966. $targetVersion = $package->getVersion();
  6967. }
  6968. if ($targetVersion === null && $minorOnly) {
  6969. $targetVersion = '^' . $package->getVersion();
  6970. }
  6971. return $versionSelector->findBestCandidate($name, $targetVersion, $bestStability);
  6972. }
  6973. private function getRepositorySet(Composer $composer)
  6974. {
  6975. if (!$this->repositorySet) {
  6976. $this->repositorySet = new RepositorySet($composer->getPackage()->getMinimumStability(), $composer->getPackage()->getStabilityFlags());
  6977. $this->repositorySet->addRepository(new CompositeRepository($composer->getRepositoryManager()->getRepositories()));
  6978. }
  6979. return $this->repositorySet;
  6980. }
  6981. private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, $bucket = array())
  6982. {
  6983. $requires = $package->getRequires();
  6984. foreach ($repo->getPackages() as $candidate) {
  6985. foreach ($candidate->getNames() as $name) {
  6986. if (isset($requires[$name])) {
  6987. if (!in_array($candidate, $bucket, true)) {
  6988. $bucket[] = $candidate;
  6989. $bucket = $this->filterRequiredPackages($repo, $candidate, $bucket);
  6990. }
  6991. break;
  6992. }
  6993. }
  6994. }
  6995. return $bucket;
  6996. }
  6997. }
  6998. <?php
  6999. namespace Composer\Command;
  7000. use Symfony\Component\Console\Input\InputInterface;
  7001. use Symfony\Component\Console\Input\InputOption;
  7002. use Symfony\Component\Console\Output\OutputInterface;
  7003. use Composer\Downloader\ChangeReportInterface;
  7004. use Composer\Downloader\DvcsDownloaderInterface;
  7005. use Composer\Downloader\VcsCapableDownloaderInterface;
  7006. use Composer\Package\Dumper\ArrayDumper;
  7007. use Composer\Package\Version\VersionGuesser;
  7008. use Composer\Package\Version\VersionParser;
  7009. use Composer\Plugin\CommandEvent;
  7010. use Composer\Plugin\PluginEvents;
  7011. use Composer\Script\ScriptEvents;
  7012. use Composer\Util\ProcessExecutor;
  7013. class StatusCommand extends BaseCommand
  7014. {
  7015. const EXIT_CODE_ERRORS = 1;
  7016. const EXIT_CODE_UNPUSHED_CHANGES = 2;
  7017. const EXIT_CODE_VERSION_CHANGES = 4;
  7018. protected function configure()
  7019. {
  7020. $this
  7021. ->setName('status')
  7022. ->setDescription('Shows a list of locally modified packages.')
  7023. ->setDefinition(array(
  7024. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Show modified files for each directory that contains changes.'),
  7025. ))
  7026. ->setHelp(
  7027. <<<EOT
  7028. The status command displays a list of dependencies that have
  7029. been modified locally.
  7030. Read more at https://getcomposer.org/doc/03-cli.md#status
  7031. EOT
  7032. )
  7033. ;
  7034. }
  7035. protected function execute(InputInterface $input, OutputInterface $output)
  7036. {
  7037. $composer = $this->getComposer();
  7038. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'status', $input, $output);
  7039. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  7040. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::PRE_STATUS_CMD, true);
  7041. $exitCode = $this->doExecute($input);
  7042. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_STATUS_CMD, true);
  7043. return $exitCode;
  7044. }
  7045. private function doExecute(InputInterface $input)
  7046. {
  7047. $composer = $this->getComposer();
  7048. $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
  7049. $dm = $composer->getDownloadManager();
  7050. $im = $composer->getInstallationManager();
  7051. $errors = array();
  7052. $io = $this->getIO();
  7053. $unpushedChanges = array();
  7054. $vcsVersionChanges = array();
  7055. $parser = new VersionParser;
  7056. $guesser = new VersionGuesser($composer->getConfig(), new ProcessExecutor($io), $parser);
  7057. $dumper = new ArrayDumper;
  7058. foreach ($installedRepo->getCanonicalPackages() as $package) {
  7059. $downloader = $dm->getDownloaderForPackage($package);
  7060. $targetDir = $im->getInstallPath($package);
  7061. if ($downloader instanceof ChangeReportInterface) {
  7062. if (is_link($targetDir)) {
  7063. $errors[$targetDir] = $targetDir . ' is a symbolic link.';
  7064. }
  7065. if ($changes = $downloader->getLocalChanges($package, $targetDir)) {
  7066. $errors[$targetDir] = $changes;
  7067. }
  7068. }
  7069. if ($downloader instanceof VcsCapableDownloaderInterface) {
  7070. if ($downloader->getVcsReference($package, $targetDir)) {
  7071. switch ($package->getInstallationSource()) {
  7072. case 'source':
  7073. $previousRef = $package->getSourceReference();
  7074. break;
  7075. case 'dist':
  7076. $previousRef = $package->getDistReference();
  7077. break;
  7078. default:
  7079. $previousRef = null;
  7080. }
  7081. $currentVersion = $guesser->guessVersion($dumper->dump($package), $targetDir);
  7082. if ($previousRef && $currentVersion && $currentVersion['commit'] !== $previousRef) {
  7083. $vcsVersionChanges[$targetDir] = array(
  7084. 'previous' => array(
  7085. 'version' => $package->getPrettyVersion(),
  7086. 'ref' => $previousRef,
  7087. ),
  7088. 'current' => array(
  7089. 'version' => $currentVersion['pretty_version'],
  7090. 'ref' => $currentVersion['commit'],
  7091. ),
  7092. );
  7093. }
  7094. }
  7095. }
  7096. if ($downloader instanceof DvcsDownloaderInterface) {
  7097. if ($unpushed = $downloader->getUnpushedChanges($package, $targetDir)) {
  7098. $unpushedChanges[$targetDir] = $unpushed;
  7099. }
  7100. }
  7101. }
  7102. if (!$errors && !$unpushedChanges && !$vcsVersionChanges) {
  7103. $io->writeError('<info>No local changes</info>');
  7104. return 0;
  7105. }
  7106. if ($errors) {
  7107. $io->writeError('<error>You have changes in the following dependencies:</error>');
  7108. foreach ($errors as $path => $changes) {
  7109. if ($input->getOption('verbose')) {
  7110. $indentedChanges = implode("\n", array_map(function ($line) {
  7111. return ' ' . ltrim($line);
  7112. }, explode("\n", $changes)));
  7113. $io->write('<info>'.$path.'</info>:');
  7114. $io->write($indentedChanges);
  7115. } else {
  7116. $io->write($path);
  7117. }
  7118. }
  7119. }
  7120. if ($unpushedChanges) {
  7121. $io->writeError('<warning>You have unpushed changes on the current branch in the following dependencies:</warning>');
  7122. foreach ($unpushedChanges as $path => $changes) {
  7123. if ($input->getOption('verbose')) {
  7124. $indentedChanges = implode("\n", array_map(function ($line) {
  7125. return ' ' . ltrim($line);
  7126. }, explode("\n", $changes)));
  7127. $io->write('<info>'.$path.'</info>:');
  7128. $io->write($indentedChanges);
  7129. } else {
  7130. $io->write($path);
  7131. }
  7132. }
  7133. }
  7134. if ($vcsVersionChanges) {
  7135. $io->writeError('<warning>You have version variations in the following dependencies:</warning>');
  7136. foreach ($vcsVersionChanges as $path => $changes) {
  7137. if ($input->getOption('verbose')) {
  7138. $currentVersion = $changes['current']['version'] ?: $changes['current']['ref'];
  7139. $previousVersion = $changes['previous']['version'] ?: $changes['previous']['ref'];
  7140. if ($io->isVeryVerbose()) {
  7141. $currentVersion .= sprintf(' (%s)', $changes['current']['ref']);
  7142. $previousVersion .= sprintf(' (%s)', $changes['previous']['ref']);
  7143. }
  7144. $io->write('<info>'.$path.'</info>:');
  7145. $io->write(sprintf(' From <comment>%s</comment> to <comment>%s</comment>', $previousVersion, $currentVersion));
  7146. } else {
  7147. $io->write($path);
  7148. }
  7149. }
  7150. }
  7151. if (($errors || $unpushedChanges || $vcsVersionChanges) && !$input->getOption('verbose')) {
  7152. $io->writeError('Use --verbose (-v) to see a list of files');
  7153. }
  7154. return ($errors ? self::EXIT_CODE_ERRORS : 0) + ($unpushedChanges ? self::EXIT_CODE_UNPUSHED_CHANGES : 0) + ($vcsVersionChanges ? self::EXIT_CODE_VERSION_CHANGES : 0);
  7155. }
  7156. }
  7157. <?php
  7158. namespace Composer\Command;
  7159. use Composer\Repository\PlatformRepository;
  7160. use Composer\Repository\RootPackageRepository;
  7161. use Composer\Repository\InstalledRepository;
  7162. use Composer\Installer\SuggestedPackagesReporter;
  7163. use Symfony\Component\Console\Input\InputArgument;
  7164. use Symfony\Component\Console\Input\InputInterface;
  7165. use Symfony\Component\Console\Input\InputOption;
  7166. use Symfony\Component\Console\Output\OutputInterface;
  7167. class SuggestsCommand extends BaseCommand
  7168. {
  7169. protected function configure()
  7170. {
  7171. $this
  7172. ->setName('suggests')
  7173. ->setDescription('Shows package suggestions.')
  7174. ->setDefinition(array(
  7175. new InputOption('by-package', null, InputOption::VALUE_NONE, 'Groups output by suggesting package (default)'),
  7176. new InputOption('by-suggestion', null, InputOption::VALUE_NONE, 'Groups output by suggested package'),
  7177. new InputOption('all', 'a', InputOption::VALUE_NONE, 'Show suggestions from all dependencies, including transitive ones'),
  7178. new InputOption('list', null, InputOption::VALUE_NONE, 'Show only list of suggested package names'),
  7179. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Exclude suggestions from require-dev packages'),
  7180. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that you want to list suggestions from.'),
  7181. ))
  7182. ->setHelp(
  7183. <<<EOT
  7184. The <info>%command.name%</info> command shows a sorted list of suggested packages.
  7185. Read more at https://getcomposer.org/doc/03-cli.md#suggests
  7186. EOT
  7187. )
  7188. ;
  7189. }
  7190. protected function execute(InputInterface $input, OutputInterface $output)
  7191. {
  7192. $composer = $this->getComposer();
  7193. $installedRepos = array(
  7194. new RootPackageRepository(clone $composer->getPackage()),
  7195. );
  7196. $locker = $composer->getLocker();
  7197. if ($locker->isLocked()) {
  7198. $installedRepos[] = new PlatformRepository(array(), $locker->getPlatformOverrides());
  7199. $installedRepos[] = $locker->getLockedRepository(!$input->getOption('no-dev'));
  7200. } else {
  7201. $installedRepos[] = new PlatformRepository(array(), $composer->getConfig()->get('platform') ?: array());
  7202. $installedRepos[] = $composer->getRepositoryManager()->getLocalRepository();
  7203. }
  7204. $installedRepo = new InstalledRepository($installedRepos);
  7205. $reporter = new SuggestedPackagesReporter($this->getIO());
  7206. $filter = $input->getArgument('packages');
  7207. $packages = $installedRepo->getPackages();
  7208. $packages[] = $composer->getPackage();
  7209. foreach ($packages as $package) {
  7210. if (!empty($filter) && !in_array($package->getName(), $filter)) {
  7211. continue;
  7212. }
  7213. $reporter->addSuggestionsFromPackage($package);
  7214. }
  7215. $mode = SuggestedPackagesReporter::MODE_BY_PACKAGE;
  7216. if ($input->getOption('by-suggestion')) {
  7217. $mode = SuggestedPackagesReporter::MODE_BY_SUGGESTION;
  7218. }
  7219. if ($input->getOption('by-package')) {
  7220. $mode |= SuggestedPackagesReporter::MODE_BY_PACKAGE;
  7221. }
  7222. if ($input->getOption('list')) {
  7223. $mode = SuggestedPackagesReporter::MODE_LIST;
  7224. }
  7225. $reporter->output($mode, $installedRepo, empty($filter) && !$input->getOption('all') ? $composer->getPackage() : null);
  7226. return 0;
  7227. }
  7228. }
  7229. <?php
  7230. namespace Composer\Command;
  7231. use Composer\Composer;
  7232. use Composer\DependencyResolver\Request;
  7233. use Composer\Installer;
  7234. use Composer\IO\IOInterface;
  7235. use Composer\Plugin\CommandEvent;
  7236. use Composer\Plugin\PluginEvents;
  7237. use Composer\Package\Version\VersionParser;
  7238. use Composer\Semver\Constraint\MultiConstraint;
  7239. use Composer\Package\Link;
  7240. use Symfony\Component\Console\Helper\Table;
  7241. use Symfony\Component\Console\Input\InputInterface;
  7242. use Symfony\Component\Console\Input\InputOption;
  7243. use Symfony\Component\Console\Input\InputArgument;
  7244. use Symfony\Component\Console\Output\OutputInterface;
  7245. use Symfony\Component\Console\Question\Question;
  7246. class UpdateCommand extends BaseCommand
  7247. {
  7248. protected function configure()
  7249. {
  7250. $this
  7251. ->setName('update')
  7252. ->setAliases(array('u', 'upgrade'))
  7253. ->setDescription('Upgrades your dependencies to the latest version according to composer.json, and updates the composer.lock file.')
  7254. ->setDefinition(array(
  7255. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that should be updated, if not provided all packages are.'),
  7256. 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'),
  7257. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  7258. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
  7259. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  7260. new InputOption('dev', null, InputOption::VALUE_NONE, 'DEPRECATED: Enables installation of require-dev packages (enabled by default, only present for BC).'),
  7261. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  7262. new InputOption('lock', null, InputOption::VALUE_NONE, 'Only updates the lock file hash to suppress warning about the lock file being out of date.'),
  7263. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  7264. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  7265. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  7266. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  7267. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  7268. new InputOption('with-dependencies', 'w', InputOption::VALUE_NONE, 'Update also dependencies of packages in the argument list, except those which are root requirements.'),
  7269. new InputOption('with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Update also dependencies of packages in the argument list, including those which are root requirements.'),
  7270. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
  7271. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump.'),
  7272. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  7273. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  7274. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  7275. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  7276. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  7277. new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies.'),
  7278. new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies.'),
  7279. new InputOption('interactive', 'i', InputOption::VALUE_NONE, 'Interactive interface with autocompletion to select the packages to update.'),
  7280. new InputOption('root-reqs', null, InputOption::VALUE_NONE, 'Restricts the update to your first degree dependencies.'),
  7281. ))
  7282. ->setHelp(
  7283. <<<EOT
  7284. The <info>update</info> command reads the composer.json file from the
  7285. current directory, processes it, and updates, removes or installs all the
  7286. dependencies.
  7287. <info>php composer.phar update</info>
  7288. To limit the update operation to a few packages, you can list the package(s)
  7289. you want to update as such:
  7290. <info>php composer.phar update vendor/package1 foo/mypackage [...]</info>
  7291. You may also use an asterisk (*) pattern to limit the update operation to package(s)
  7292. from a specific vendor:
  7293. <info>php composer.phar update vendor/package1 foo/* [...]</info>
  7294. To run an update with more restrictive constraints you can use:
  7295. <info>php composer.phar update --with vendor/package:1.0.*</info>
  7296. To run a partial update with more restrictive constraints you can use the shorthand:
  7297. <info>php composer.phar update vendor/package:1.0.*</info>
  7298. To select packages names interactively with auto-completion use <info>-i</info>.
  7299. Read more at https://getcomposer.org/doc/03-cli.md#update-u
  7300. EOT
  7301. )
  7302. ;
  7303. }
  7304. protected function execute(InputInterface $input, OutputInterface $output)
  7305. {
  7306. $io = $this->getIO();
  7307. if ($input->getOption('dev')) {
  7308. $io->writeError('<warning>You are using the deprecated option "--dev". It has no effect and will break in Composer 3.</warning>');
  7309. }
  7310. if ($input->getOption('no-suggest')) {
  7311. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  7312. }
  7313. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  7314. $packages = $input->getArgument('packages');
  7315. $reqs = $this->formatRequirements($input->getOption('with'));
  7316. if ($packages) {
  7317. $allowlistPackagesWithRequirements = array_filter($packages, function ($pkg) {
  7318. return preg_match('{\S+[ =:]\S+}', $pkg) > 0;
  7319. });
  7320. foreach ($this->formatRequirements($allowlistPackagesWithRequirements) as $package => $constraint) {
  7321. $reqs[$package] = $constraint;
  7322. }
  7323. foreach ($allowlistPackagesWithRequirements as $package) {
  7324. $packageName = preg_replace('{^([^ =:]+)[ =:].*$}', '$1', $package);
  7325. $index = array_search($package, $packages);
  7326. $packages[$index] = $packageName;
  7327. }
  7328. }
  7329. $rootRequires = $composer->getPackage()->getRequires();
  7330. $rootDevRequires = $composer->getPackage()->getDevRequires();
  7331. foreach ($reqs as $package => $constraint) {
  7332. if (isset($rootRequires[$package])) {
  7333. $rootRequires[$package] = $this->appendConstraintToLink($rootRequires[$package], $constraint);
  7334. } elseif (isset($rootDevRequires[$package])) {
  7335. $rootDevRequires[$package] = $this->appendConstraintToLink($rootDevRequires[$package], $constraint);
  7336. } else {
  7337. throw new \UnexpectedValueException('Only root package requirements can receive temporary constraints and '.$package.' is not one');
  7338. }
  7339. }
  7340. $composer->getPackage()->setRequires($rootRequires);
  7341. $composer->getPackage()->setDevRequires($rootDevRequires);
  7342. if ($input->getOption('interactive')) {
  7343. $packages = $this->getPackagesInteractively($io, $input, $output, $composer, $packages);
  7344. }
  7345. if ($input->getOption('root-reqs')) {
  7346. $requires = array_keys($rootRequires);
  7347. if (!$input->getOption('no-dev')) {
  7348. $requires = array_merge($requires, array_keys($rootDevRequires));
  7349. }
  7350. if (!empty($packages)) {
  7351. $packages = array_intersect($packages, $requires);
  7352. } else {
  7353. $packages = $requires;
  7354. }
  7355. }
  7356. $filteredPackages = array_filter($packages, function ($package) {
  7357. return !in_array($package, array('lock', 'nothing', 'mirrors'), true);
  7358. });
  7359. $updateMirrors = $input->getOption('lock') || count($filteredPackages) != count($packages);
  7360. $packages = $filteredPackages;
  7361. if ($updateMirrors && !empty($packages)) {
  7362. $io->writeError('<error>You cannot simultaneously update only a selection of packages and regenerate the lock file metadata.</error>');
  7363. return -1;
  7364. }
  7365. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'update', $input, $output);
  7366. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  7367. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  7368. $install = Installer::create($io, $composer);
  7369. $config = $composer->getConfig();
  7370. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  7371. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  7372. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  7373. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  7374. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  7375. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  7376. if ($input->getOption('with-all-dependencies')) {
  7377. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  7378. } elseif ($input->getOption('with-dependencies')) {
  7379. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  7380. }
  7381. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  7382. $install
  7383. ->setDryRun($input->getOption('dry-run'))
  7384. ->setVerbose($input->getOption('verbose'))
  7385. ->setPreferSource($preferSource)
  7386. ->setPreferDist($preferDist)
  7387. ->setDevMode(!$input->getOption('no-dev'))
  7388. ->setDumpAutoloader(!$input->getOption('no-autoloader'))
  7389. ->setRunScripts(!$input->getOption('no-scripts'))
  7390. ->setOptimizeAutoloader($optimize)
  7391. ->setClassMapAuthoritative($authoritative)
  7392. ->setApcuAutoloader($apcu, $apcuPrefix)
  7393. ->setUpdate(true)
  7394. ->setInstall(!$input->getOption('no-install'))
  7395. ->setUpdateMirrors($updateMirrors)
  7396. ->setUpdateAllowList($packages)
  7397. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  7398. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  7399. ->setPreferStable($input->getOption('prefer-stable'))
  7400. ->setPreferLowest($input->getOption('prefer-lowest'))
  7401. ;
  7402. if ($input->getOption('no-plugins')) {
  7403. $install->disablePlugins();
  7404. }
  7405. return $install->run();
  7406. }
  7407. private function getPackagesInteractively(IOInterface $io, InputInterface $input, OutputInterface $output, Composer $composer, array $packages)
  7408. {
  7409. if (!$input->isInteractive()) {
  7410. throw new \InvalidArgumentException('--interactive cannot be used in non-interactive terminals.');
  7411. }
  7412. $requires = array_merge(
  7413. $composer->getPackage()->getRequires(),
  7414. $composer->getPackage()->getDevRequires()
  7415. );
  7416. $autocompleterValues = array();
  7417. foreach ($requires as $require) {
  7418. $target = $require->getTarget();
  7419. $autocompleterValues[strtolower($target)] = $target;
  7420. }
  7421. $installedPackages = $composer->getRepositoryManager()->getLocalRepository()->getPackages();
  7422. foreach ($installedPackages as $package) {
  7423. $autocompleterValues[$package->getName()] = $package->getPrettyName();
  7424. }
  7425. $helper = $this->getHelper('question');
  7426. $question = new Question('<comment>Enter package name: </comment>', null);
  7427. $io->writeError('<info>Press enter without value to end submission</info>');
  7428. do {
  7429. $autocompleterValues = array_diff($autocompleterValues, $packages);
  7430. $question->setAutocompleterValues($autocompleterValues);
  7431. $addedPackage = $helper->ask($input, $output, $question);
  7432. if (!is_string($addedPackage) || empty($addedPackage)) {
  7433. break;
  7434. }
  7435. $addedPackage = strtolower($addedPackage);
  7436. if (!in_array($addedPackage, $packages)) {
  7437. $packages[] = $addedPackage;
  7438. }
  7439. } while (true);
  7440. $packages = array_filter($packages);
  7441. if (!$packages) {
  7442. throw new \InvalidArgumentException('You must enter minimum one package.');
  7443. }
  7444. $table = new Table($output);
  7445. $table->setHeaders(array('Selected packages'));
  7446. foreach ($packages as $package) {
  7447. $table->addRow(array($package));
  7448. }
  7449. $table->render();
  7450. if ($io->askConfirmation(sprintf(
  7451. 'Would you like to continue and update the above package%s [<comment>yes</comment>]? ',
  7452. 1 === count($packages) ? '' : 's'
  7453. ))) {
  7454. return $packages;
  7455. }
  7456. throw new \RuntimeException('Installation aborted.');
  7457. }
  7458. private function appendConstraintToLink(Link $link, $constraint)
  7459. {
  7460. $parser = new VersionParser;
  7461. $oldPrettyString = $link->getConstraint()->getPrettyString();
  7462. $newConstraint = MultiConstraint::create(array($link->getConstraint(), $parser->parseConstraints($constraint)));
  7463. $newConstraint->setPrettyString($oldPrettyString.', '.$constraint);
  7464. return new Link(
  7465. $link->getSource(),
  7466. $link->getTarget(),
  7467. $newConstraint,
  7468. $link->getDescription(),
  7469. $link->getPrettyConstraint() . ', ' . $constraint
  7470. );
  7471. }
  7472. }
  7473. <?php
  7474. namespace Composer\Command;
  7475. use Composer\Factory;
  7476. use Composer\Package\Loader\ValidatingArrayLoader;
  7477. use Composer\Plugin\CommandEvent;
  7478. use Composer\Plugin\PluginEvents;
  7479. use Composer\Util\ConfigValidator;
  7480. use Symfony\Component\Console\Input\InputArgument;
  7481. use Symfony\Component\Console\Input\InputInterface;
  7482. use Symfony\Component\Console\Input\InputOption;
  7483. use Symfony\Component\Console\Output\OutputInterface;
  7484. class ValidateCommand extends BaseCommand
  7485. {
  7486. protected function configure()
  7487. {
  7488. $this
  7489. ->setName('validate')
  7490. ->setDescription('Validates a composer.json and composer.lock.')
  7491. ->setDefinition(array(
  7492. new InputOption('no-check-all', null, InputOption::VALUE_NONE, 'Do not validate requires for overly strict/loose constraints'),
  7493. new InputOption('no-check-lock', null, InputOption::VALUE_NONE, 'Do not check if lock file is up to date'),
  7494. new InputOption('no-check-publish', null, InputOption::VALUE_NONE, 'Do not check for publish errors'),
  7495. new InputOption('no-check-version', null, InputOption::VALUE_NONE, 'Do not report a warning if the version field is present'),
  7496. new InputOption('with-dependencies', 'A', InputOption::VALUE_NONE, 'Also validate the composer.json of all installed dependencies'),
  7497. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code for warnings as well as errors'),
  7498. new InputArgument('file', InputArgument::OPTIONAL, 'path to composer.json file'),
  7499. ))
  7500. ->setHelp(
  7501. <<<EOT
  7502. The validate command validates a given composer.json and composer.lock
  7503. Exit codes in case of errors are:
  7504. 1 validation warning(s), only when --strict is given
  7505. 2 validation error(s)
  7506. 3 file unreadable or missing
  7507. Read more at https://getcomposer.org/doc/03-cli.md#validate
  7508. EOT
  7509. );
  7510. }
  7511. protected function execute(InputInterface $input, OutputInterface $output)
  7512. {
  7513. $file = $input->getArgument('file') ?: Factory::getComposerFile();
  7514. $io = $this->getIO();
  7515. if (!file_exists($file)) {
  7516. $io->writeError('<error>' . $file . ' not found.</error>');
  7517. return 3;
  7518. }
  7519. if (!is_readable($file)) {
  7520. $io->writeError('<error>' . $file . ' is not readable.</error>');
  7521. return 3;
  7522. }
  7523. $validator = new ConfigValidator($io);
  7524. $checkAll = $input->getOption('no-check-all') ? 0 : ValidatingArrayLoader::CHECK_ALL;
  7525. $checkPublish = !$input->getOption('no-check-publish');
  7526. $checkLock = !$input->getOption('no-check-lock');
  7527. $checkVersion = $input->getOption('no-check-version') ? 0 : ConfigValidator::CHECK_VERSION;
  7528. $isStrict = $input->getOption('strict');
  7529. list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll, $checkVersion);
  7530. $lockErrors = array();
  7531. $composer = Factory::create($io, $file, $input->hasParameterOption('--no-plugins'));
  7532. $locker = $composer->getLocker();
  7533. if ($locker->isLocked() && !$locker->isFresh()) {
  7534. $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>`.';
  7535. }
  7536. $this->outputResult($io, $file, $errors, $warnings, $checkPublish, $publishErrors, $checkLock, $lockErrors, true);
  7537. $exitCode = $errors ? 2 : ($isStrict && $warnings ? 1 : 0);
  7538. if ($input->getOption('with-dependencies')) {
  7539. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  7540. foreach ($localRepo->getPackages() as $package) {
  7541. $path = $composer->getInstallationManager()->getInstallPath($package);
  7542. $file = $path . '/composer.json';
  7543. if (is_dir($path) && file_exists($file)) {
  7544. list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll, $checkVersion);
  7545. $this->outputResult($io, $package->getPrettyName(), $errors, $warnings, $checkPublish, $publishErrors);
  7546. $depCode = $errors ? 2 : ($isStrict && $warnings ? 1 : 0);
  7547. $exitCode = max($depCode, $exitCode);
  7548. }
  7549. }
  7550. }
  7551. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'validate', $input, $output);
  7552. $eventCode = $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  7553. return max($eventCode, $exitCode);
  7554. }
  7555. private function outputResult($io, $name, &$errors, &$warnings, $checkPublish = false, $publishErrors = array(), $checkLock = false, $lockErrors = array(), $printSchemaUrl = false)
  7556. {
  7557. $doPrintSchemaUrl = false;
  7558. if ($errors) {
  7559. $io->writeError('<error>' . $name . ' is invalid, the following errors/warnings were found:</error>');
  7560. } elseif ($publishErrors) {
  7561. $io->writeError('<info>' . $name . ' is valid for simple usage with composer but has</info>');
  7562. $io->writeError('<info>strict errors that make it unable to be published as a package:</info>');
  7563. $doPrintSchemaUrl = $printSchemaUrl;
  7564. } elseif ($warnings) {
  7565. $io->writeError('<info>' . $name . ' is valid, but with a few warnings</info>');
  7566. $doPrintSchemaUrl = $printSchemaUrl;
  7567. } else {
  7568. $io->write('<info>' . $name . ' is valid</info>');
  7569. }
  7570. if ($doPrintSchemaUrl) {
  7571. $io->writeError('<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
  7572. }
  7573. $extraWarnings = array();
  7574. if ($checkPublish) {
  7575. $errors = array_merge($errors, $publishErrors);
  7576. } else {
  7577. $extraWarnings = array_merge($extraWarnings, $publishErrors);
  7578. }
  7579. if ($checkLock) {
  7580. $errors = array_merge($errors, $lockErrors);
  7581. } else {
  7582. $extraWarnings = array_merge($extraWarnings, $lockErrors);
  7583. }
  7584. $messages = array(
  7585. 'error' => $errors,
  7586. 'warning' => array_merge($warnings, $extraWarnings),
  7587. );
  7588. foreach ($messages as $style => $msgs) {
  7589. foreach ($msgs as $msg) {
  7590. $io->writeError('<' . $style . '>' . $msg . '</' . $style . '>');
  7591. }
  7592. }
  7593. }
  7594. }
  7595. <?php
  7596. namespace Composer;
  7597. use Composer\Package\RootPackageInterface;
  7598. use Composer\Package\Locker;
  7599. use Composer\Util\Loop;
  7600. use Composer\Repository\RepositoryManager;
  7601. use Composer\Installer\InstallationManager;
  7602. use Composer\Plugin\PluginManager;
  7603. use Composer\Downloader\DownloadManager;
  7604. use Composer\EventDispatcher\EventDispatcher;
  7605. use Composer\Autoload\AutoloadGenerator;
  7606. use Composer\Package\Archiver\ArchiveManager;
  7607. class Composer
  7608. {
  7609. const VERSION = '14ec957e96a24aefab22ba9eb1e0c6589d9a221c';
  7610. const BRANCH_ALIAS_VERSION = '2.0-dev';
  7611. const RELEASE_DATE = '2020-10-20 15:34:07';
  7612. const SOURCE_VERSION = '';
  7613. const RUNTIME_API_VERSION = '2.0.0';
  7614. public static function getVersion()
  7615. {
  7616. if (self::VERSION === '@package_version'.'@') {
  7617. return self::SOURCE_VERSION;
  7618. }
  7619. if (self::BRANCH_ALIAS_VERSION !== '' && preg_match('{^[a-f0-9]{40}$}', self::VERSION)) {
  7620. return self::BRANCH_ALIAS_VERSION.'+'.self::VERSION;
  7621. }
  7622. return self::VERSION;
  7623. }
  7624. private $package;
  7625. private $locker;
  7626. private $loop;
  7627. private $repositoryManager;
  7628. private $downloadManager;
  7629. private $installationManager;
  7630. private $pluginManager;
  7631. private $config;
  7632. private $eventDispatcher;
  7633. private $autoloadGenerator;
  7634. private $archiveManager;
  7635. public function setPackage(RootPackageInterface $package)
  7636. {
  7637. $this->package = $package;
  7638. }
  7639. public function getPackage()
  7640. {
  7641. return $this->package;
  7642. }
  7643. public function setConfig(Config $config)
  7644. {
  7645. $this->config = $config;
  7646. }
  7647. public function getConfig()
  7648. {
  7649. return $this->config;
  7650. }
  7651. public function setLocker(Locker $locker)
  7652. {
  7653. $this->locker = $locker;
  7654. }
  7655. public function getLocker()
  7656. {
  7657. return $this->locker;
  7658. }
  7659. public function setLoop(Loop $loop)
  7660. {
  7661. $this->loop = $loop;
  7662. }
  7663. public function getLoop()
  7664. {
  7665. return $this->loop;
  7666. }
  7667. public function setRepositoryManager(RepositoryManager $manager)
  7668. {
  7669. $this->repositoryManager = $manager;
  7670. }
  7671. public function getRepositoryManager()
  7672. {
  7673. return $this->repositoryManager;
  7674. }
  7675. public function setDownloadManager(DownloadManager $manager)
  7676. {
  7677. $this->downloadManager = $manager;
  7678. }
  7679. public function getDownloadManager()
  7680. {
  7681. return $this->downloadManager;
  7682. }
  7683. public function setArchiveManager(ArchiveManager $manager)
  7684. {
  7685. $this->archiveManager = $manager;
  7686. }
  7687. public function getArchiveManager()
  7688. {
  7689. return $this->archiveManager;
  7690. }
  7691. public function setInstallationManager(InstallationManager $manager)
  7692. {
  7693. $this->installationManager = $manager;
  7694. }
  7695. public function getInstallationManager()
  7696. {
  7697. return $this->installationManager;
  7698. }
  7699. public function setPluginManager(PluginManager $manager)
  7700. {
  7701. $this->pluginManager = $manager;
  7702. }
  7703. public function getPluginManager()
  7704. {
  7705. return $this->pluginManager;
  7706. }
  7707. public function setEventDispatcher(EventDispatcher $eventDispatcher)
  7708. {
  7709. $this->eventDispatcher = $eventDispatcher;
  7710. }
  7711. public function getEventDispatcher()
  7712. {
  7713. return $this->eventDispatcher;
  7714. }
  7715. public function setAutoloadGenerator(AutoloadGenerator $autoloadGenerator)
  7716. {
  7717. $this->autoloadGenerator = $autoloadGenerator;
  7718. }
  7719. public function getAutoloadGenerator()
  7720. {
  7721. return $this->autoloadGenerator;
  7722. }
  7723. }
  7724. <?php
  7725. namespace Composer;
  7726. use Composer\Config\ConfigSourceInterface;
  7727. use Composer\Downloader\TransportException;
  7728. use Composer\IO\IOInterface;
  7729. use Composer\Util\Platform;
  7730. use Composer\Util\ProcessExecutor;
  7731. class Config
  7732. {
  7733. const RELATIVE_PATHS = 1;
  7734. public static $defaultConfig = array(
  7735. 'process-timeout' => 300,
  7736. 'use-include-path' => false,
  7737. 'preferred-install' => 'auto',
  7738. 'notify-on-install' => true,
  7739. 'github-protocols' => array('https', 'ssh', 'git'),
  7740. 'vendor-dir' => 'vendor',
  7741. 'bin-dir' => '{$vendor-dir}/bin',
  7742. 'cache-dir' => '{$home}/cache',
  7743. 'data-dir' => '{$home}',
  7744. 'cache-files-dir' => '{$cache-dir}/files',
  7745. 'cache-repo-dir' => '{$cache-dir}/repo',
  7746. 'cache-vcs-dir' => '{$cache-dir}/vcs',
  7747. 'cache-ttl' => 15552000,
  7748. 'cache-files-ttl' => null,
  7749. 'cache-files-maxsize' => '300MiB',
  7750. 'cache-read-only' => false,
  7751. 'bin-compat' => 'auto',
  7752. 'discard-changes' => false,
  7753. 'autoloader-suffix' => null,
  7754. 'sort-packages' => false,
  7755. 'optimize-autoloader' => false,
  7756. 'classmap-authoritative' => false,
  7757. 'apcu-autoloader' => false,
  7758. 'prepend-autoloader' => true,
  7759. 'github-domains' => array('github.com'),
  7760. 'bitbucket-expose-hostname' => true,
  7761. 'disable-tls' => false,
  7762. 'secure-http' => true,
  7763. 'cafile' => null,
  7764. 'capath' => null,
  7765. 'github-expose-hostname' => true,
  7766. 'gitlab-domains' => array('gitlab.com'),
  7767. 'store-auths' => 'prompt',
  7768. 'platform' => array(),
  7769. 'archive-format' => 'tar',
  7770. 'archive-dir' => '.',
  7771. 'htaccess-protect' => true,
  7772. 'use-github-api' => true,
  7773. 'lock' => true,
  7774. 'platform-check' => true,
  7775. );
  7776. public static $defaultRepositories = array(
  7777. 'packagist.org' => array(
  7778. 'type' => 'composer',
  7779. 'url' => 'https?://repo.packagist.org',
  7780. 'allow_ssl_downgrade' => true,
  7781. ),
  7782. );
  7783. private $config;
  7784. private $baseDir;
  7785. private $repositories;
  7786. private $configSource;
  7787. private $authConfigSource;
  7788. private $useEnvironment;
  7789. private $warnedHosts = array();
  7790. public function __construct($useEnvironment = true, $baseDir = null)
  7791. {
  7792. $this->config = static::$defaultConfig;
  7793. $this->repositories = static::$defaultRepositories;
  7794. $this->useEnvironment = (bool) $useEnvironment;
  7795. $this->baseDir = $baseDir;
  7796. }
  7797. public function setConfigSource(ConfigSourceInterface $source)
  7798. {
  7799. $this->configSource = $source;
  7800. }
  7801. public function getConfigSource()
  7802. {
  7803. return $this->configSource;
  7804. }
  7805. public function setAuthConfigSource(ConfigSourceInterface $source)
  7806. {
  7807. $this->authConfigSource = $source;
  7808. }
  7809. public function getAuthConfigSource()
  7810. {
  7811. return $this->authConfigSource;
  7812. }
  7813. public function merge($config)
  7814. {
  7815. if (!empty($config['config']) && is_array($config['config'])) {
  7816. foreach ($config['config'] as $key => $val) {
  7817. if (in_array($key, array('bitbucket-oauth', 'github-oauth', 'gitlab-oauth', 'gitlab-token', 'http-basic', 'bearer')) && isset($this->config[$key])) {
  7818. $this->config[$key] = array_merge($this->config[$key], $val);
  7819. } elseif ('preferred-install' === $key && isset($this->config[$key])) {
  7820. if (is_array($val) || is_array($this->config[$key])) {
  7821. if (is_string($val)) {
  7822. $val = array('*' => $val);
  7823. }
  7824. if (is_string($this->config[$key])) {
  7825. $this->config[$key] = array('*' => $this->config[$key]);
  7826. }
  7827. $this->config[$key] = array_merge($this->config[$key], $val);
  7828. if (isset($this->config[$key]['*'])) {
  7829. $wildcard = $this->config[$key]['*'];
  7830. unset($this->config[$key]['*']);
  7831. $this->config[$key]['*'] = $wildcard;
  7832. }
  7833. } else {
  7834. $this->config[$key] = $val;
  7835. }
  7836. } else {
  7837. $this->config[$key] = $val;
  7838. }
  7839. }
  7840. }
  7841. if (!empty($config['repositories']) && is_array($config['repositories'])) {
  7842. $this->repositories = array_reverse($this->repositories, true);
  7843. $newRepos = array_reverse($config['repositories'], true);
  7844. foreach ($newRepos as $name => $repository) {
  7845. if (false === $repository) {
  7846. $this->disableRepoByName($name);
  7847. continue;
  7848. }
  7849. if (is_array($repository) && 1 === count($repository) && false === current($repository)) {
  7850. $this->disableRepoByName(key($repository));
  7851. continue;
  7852. }
  7853. if (is_int($name)) {
  7854. $this->repositories[] = $repository;
  7855. } else {
  7856. if ($name === 'packagist') {
  7857. $this->repositories[$name . '.org'] = $repository;
  7858. } else {
  7859. $this->repositories[$name] = $repository;
  7860. }
  7861. }
  7862. }
  7863. $this->repositories = array_reverse($this->repositories, true);
  7864. }
  7865. }
  7866. public function getRepositories()
  7867. {
  7868. return $this->repositories;
  7869. }
  7870. public function get($key, $flags = 0)
  7871. {
  7872. switch ($key) {
  7873. case 'vendor-dir':
  7874. case 'bin-dir':
  7875. case 'process-timeout':
  7876. case 'data-dir':
  7877. case 'cache-dir':
  7878. case 'cache-files-dir':
  7879. case 'cache-repo-dir':
  7880. case 'cache-vcs-dir':
  7881. case 'cafile':
  7882. case 'capath':
  7883. $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_'));
  7884. $val = $this->getComposerEnv($env);
  7885. $val = rtrim((string) $this->process(false !== $val ? $val : $this->config[$key], $flags), '/\\');
  7886. $val = Platform::expandPath($val);
  7887. if (substr($key, -4) !== '-dir') {
  7888. return $val;
  7889. }
  7890. return (($flags & self::RELATIVE_PATHS) == self::RELATIVE_PATHS) ? $val : $this->realpath($val);
  7891. case 'cache-read-only':
  7892. case 'htaccess-protect':
  7893. $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_'));
  7894. $val = $this->getComposerEnv($env);
  7895. if (false === $val) {
  7896. $val = $this->config[$key];
  7897. }
  7898. return $val !== 'false' && (bool) $val;
  7899. case 'disable-tls':
  7900. case 'secure-http':
  7901. case 'use-github-api':
  7902. case 'lock':
  7903. if ($key === 'secure-http' && $this->get('disable-tls') === true) {
  7904. return false;
  7905. }
  7906. return $this->config[$key] !== 'false' && (bool) $this->config[$key];
  7907. case 'cache-ttl':
  7908. return (int) $this->config[$key];
  7909. case 'cache-files-maxsize':
  7910. if (!preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $this->config[$key], $matches)) {
  7911. throw new \RuntimeException(
  7912. "Could not parse the value of '$key': {$this->config[$key]}"
  7913. );
  7914. }
  7915. $size = $matches[1];
  7916. if (isset($matches[2])) {
  7917. switch (strtolower($matches[2])) {
  7918. case 'g':
  7919. $size *= 1024;
  7920. case 'm':
  7921. $size *= 1024;
  7922. case 'k':
  7923. $size *= 1024;
  7924. break;
  7925. }
  7926. }
  7927. return $size;
  7928. case 'cache-files-ttl':
  7929. if (isset($this->config[$key])) {
  7930. return (int) $this->config[$key];
  7931. }
  7932. return (int) $this->config['cache-ttl'];
  7933. case 'home':
  7934. $val = preg_replace('#^(\$HOME|~)(/|$)#', rtrim(getenv('HOME') ?: getenv('USERPROFILE'), '/\\') . '/', $this->config[$key]);
  7935. return rtrim($this->process($val, $flags), '/\\');
  7936. case 'bin-compat':
  7937. $value = $this->getComposerEnv('COMPOSER_BIN_COMPAT') ?: $this->config[$key];
  7938. if (!in_array($value, array('auto', 'full'))) {
  7939. throw new \RuntimeException(
  7940. "Invalid value for 'bin-compat': {$value}. Expected auto, full"
  7941. );
  7942. }
  7943. return $value;
  7944. case 'discard-changes':
  7945. if ($env = $this->getComposerEnv('COMPOSER_DISCARD_CHANGES')) {
  7946. if (!in_array($env, array('stash', 'true', 'false', '1', '0'), true)) {
  7947. throw new \RuntimeException(
  7948. "Invalid value for COMPOSER_DISCARD_CHANGES: {$env}. Expected 1, 0, true, false or stash"
  7949. );
  7950. }
  7951. if ('stash' === $env) {
  7952. return 'stash';
  7953. }
  7954. return $env !== 'false' && (bool) $env;
  7955. }
  7956. if (!in_array($this->config[$key], array(true, false, 'stash'), true)) {
  7957. throw new \RuntimeException(
  7958. "Invalid value for 'discard-changes': {$this->config[$key]}. Expected true, false or stash"
  7959. );
  7960. }
  7961. return $this->config[$key];
  7962. case 'github-protocols':
  7963. $protos = $this->config['github-protocols'];
  7964. if ($this->config['secure-http'] && false !== ($index = array_search('git', $protos))) {
  7965. unset($protos[$index]);
  7966. }
  7967. if (reset($protos) === 'http') {
  7968. throw new \RuntimeException('The http protocol for github is not available anymore, update your config\'s github-protocols to use "https", "git" or "ssh"');
  7969. }
  7970. return $protos;
  7971. default:
  7972. if (!isset($this->config[$key])) {
  7973. return null;
  7974. }
  7975. return $this->process($this->config[$key], $flags);
  7976. }
  7977. }
  7978. public function all($flags = 0)
  7979. {
  7980. $all = array(
  7981. 'repositories' => $this->getRepositories(),
  7982. );
  7983. foreach (array_keys($this->config) as $key) {
  7984. $all['config'][$key] = $this->get($key, $flags);
  7985. }
  7986. return $all;
  7987. }
  7988. public function raw()
  7989. {
  7990. return array(
  7991. 'repositories' => $this->getRepositories(),
  7992. 'config' => $this->config,
  7993. );
  7994. }
  7995. public function has($key)
  7996. {
  7997. return array_key_exists($key, $this->config);
  7998. }
  7999. private function process($value, $flags)
  8000. {
  8001. $config = $this;
  8002. if (!is_string($value)) {
  8003. return $value;
  8004. }
  8005. return preg_replace_callback('#\{\$(.+)\}#', function ($match) use ($config, $flags) {
  8006. return $config->get($match[1], $flags);
  8007. }, $value);
  8008. }
  8009. private function realpath($path)
  8010. {
  8011. if (preg_match('{^(?:/|[a-z]:|[a-z0-9.]+://)}i', $path)) {
  8012. return $path;
  8013. }
  8014. return $this->baseDir . '/' . $path;
  8015. }
  8016. private function getComposerEnv($var)
  8017. {
  8018. if ($this->useEnvironment) {
  8019. return getenv($var);
  8020. }
  8021. return false;
  8022. }
  8023. private function disableRepoByName($name)
  8024. {
  8025. if (isset($this->repositories[$name])) {
  8026. unset($this->repositories[$name]);
  8027. } elseif ($name === 'packagist') {
  8028. unset($this->repositories['packagist.org']);
  8029. }
  8030. }
  8031. public function prohibitUrlByConfig($url, IOInterface $io = null)
  8032. {
  8033. if (false === filter_var($url, FILTER_VALIDATE_URL)) {
  8034. return;
  8035. }
  8036. $scheme = parse_url($url, PHP_URL_SCHEME);
  8037. if (in_array($scheme, array('http', 'git', 'ftp', 'svn'))) {
  8038. if ($this->get('secure-http')) {
  8039. throw new TransportException("Your configuration does not allow connections to $url. See https://getcomposer.org/doc/06-config.md#secure-http for details.");
  8040. }
  8041. if ($io) {
  8042. $host = parse_url($url, PHP_URL_HOST);
  8043. if (!isset($this->warnedHosts[$host])) {
  8044. $io->writeError("<warning>Warning: Accessing $host over $scheme which is an insecure protocol.</warning>");
  8045. }
  8046. $this->warnedHosts[$host] = true;
  8047. }
  8048. }
  8049. }
  8050. public static function disableProcessTimeout()
  8051. {
  8052. ProcessExecutor::setTimeout(0);
  8053. }
  8054. }
  8055. <?php
  8056. namespace Composer\Config;
  8057. interface ConfigSourceInterface
  8058. {
  8059. public function addRepository($name, $config);
  8060. public function removeRepository($name);
  8061. public function addConfigSetting($name, $value);
  8062. public function removeConfigSetting($name);
  8063. public function addProperty($name, $value);
  8064. public function removeProperty($name);
  8065. public function addLink($type, $name, $value);
  8066. public function removeLink($type, $name);
  8067. public function getName();
  8068. }
  8069. <?php
  8070. namespace Composer\Config;
  8071. use Composer\Json\JsonFile;
  8072. use Composer\Json\JsonManipulator;
  8073. use Composer\Util\Silencer;
  8074. class JsonConfigSource implements ConfigSourceInterface
  8075. {
  8076. private $file;
  8077. private $authConfig;
  8078. public function __construct(JsonFile $file, $authConfig = false)
  8079. {
  8080. $this->file = $file;
  8081. $this->authConfig = $authConfig;
  8082. }
  8083. public function getName()
  8084. {
  8085. return $this->file->getPath();
  8086. }
  8087. public function addRepository($name, $config)
  8088. {
  8089. $this->manipulateJson('addRepository', $name, $config, function (&$config, $repo, $repoConfig) {
  8090. if (isset($config['repositories'])) {
  8091. foreach ($config['repositories'] as $index => $val) {
  8092. if ($index === $repo) {
  8093. continue;
  8094. }
  8095. if (is_numeric($index) && ($val === array('packagist' => false) || $val === array('packagist.org' => false))) {
  8096. unset($config['repositories'][$index]);
  8097. $config['repositories']['packagist.org'] = false;
  8098. break;
  8099. }
  8100. }
  8101. }
  8102. $config['repositories'][$repo] = $repoConfig;
  8103. });
  8104. }
  8105. public function removeRepository($name)
  8106. {
  8107. $this->manipulateJson('removeRepository', $name, function (&$config, $repo) {
  8108. unset($config['repositories'][$repo]);
  8109. });
  8110. }
  8111. public function addConfigSetting($name, $value)
  8112. {
  8113. $authConfig = $this->authConfig;
  8114. $this->manipulateJson('addConfigSetting', $name, $value, function (&$config, $key, $val) use ($authConfig) {
  8115. if (preg_match('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|bearer|http-basic|platform)\.}', $key)) {
  8116. list($key, $host) = explode('.', $key, 2);
  8117. if ($authConfig) {
  8118. $config[$key][$host] = $val;
  8119. } else {
  8120. $config['config'][$key][$host] = $val;
  8121. }
  8122. } else {
  8123. $config['config'][$key] = $val;
  8124. }
  8125. });
  8126. }
  8127. public function removeConfigSetting($name)
  8128. {
  8129. $authConfig = $this->authConfig;
  8130. $this->manipulateJson('removeConfigSetting', $name, function (&$config, $key) use ($authConfig) {
  8131. if (preg_match('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|bearer|http-basic|platform)\.}', $key)) {
  8132. list($key, $host) = explode('.', $key, 2);
  8133. if ($authConfig) {
  8134. unset($config[$key][$host]);
  8135. } else {
  8136. unset($config['config'][$key][$host]);
  8137. }
  8138. } else {
  8139. unset($config['config'][$key]);
  8140. }
  8141. });
  8142. }
  8143. public function addProperty($name, $value)
  8144. {
  8145. $this->manipulateJson('addProperty', $name, $value, function (&$config, $key, $val) {
  8146. if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
  8147. $bits = explode('.', $key);
  8148. $last = array_pop($bits);
  8149. $arr = &$config[reset($bits)];
  8150. foreach ($bits as $bit) {
  8151. if (!isset($arr[$bit])) {
  8152. $arr[$bit] = array();
  8153. }
  8154. $arr = &$arr[$bit];
  8155. }
  8156. $arr[$last] = $val;
  8157. } else {
  8158. $config[$key] = $val;
  8159. }
  8160. });
  8161. }
  8162. public function removeProperty($name)
  8163. {
  8164. $this->manipulateJson('removeProperty', $name, function (&$config, $key) {
  8165. if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
  8166. $bits = explode('.', $key);
  8167. $last = array_pop($bits);
  8168. $arr = &$config[reset($bits)];
  8169. foreach ($bits as $bit) {
  8170. if (!isset($arr[$bit])) {
  8171. return;
  8172. }
  8173. $arr = &$arr[$bit];
  8174. }
  8175. unset($arr[$last]);
  8176. } else {
  8177. unset($config[$key]);
  8178. }
  8179. });
  8180. }
  8181. public function addLink($type, $name, $value)
  8182. {
  8183. $this->manipulateJson('addLink', $type, $name, $value, function (&$config, $type, $name, $value) {
  8184. $config[$type][$name] = $value;
  8185. });
  8186. }
  8187. public function removeLink($type, $name)
  8188. {
  8189. $this->manipulateJson('removeSubNode', $type, $name, function (&$config, $type, $name) {
  8190. unset($config[$type][$name]);
  8191. if (0 === count($config[$type])) {
  8192. unset($config[$type]);
  8193. }
  8194. });
  8195. }
  8196. protected function manipulateJson($method, $args, $fallback)
  8197. {
  8198. $args = func_get_args();
  8199. array_shift($args);
  8200. $fallback = array_pop($args);
  8201. if ($this->file->exists()) {
  8202. if (!is_writable($this->file->getPath())) {
  8203. throw new \RuntimeException(sprintf('The file "%s" is not writable.', $this->file->getPath()));
  8204. }
  8205. if (!is_readable($this->file->getPath())) {
  8206. throw new \RuntimeException(sprintf('The file "%s" is not readable.', $this->file->getPath()));
  8207. }
  8208. $contents = file_get_contents($this->file->getPath());
  8209. } elseif ($this->authConfig) {
  8210. $contents = "{\n}\n";
  8211. } else {
  8212. $contents = "{\n \"config\": {\n }\n}\n";
  8213. }
  8214. $manipulator = new JsonManipulator($contents);
  8215. $newFile = !$this->file->exists();
  8216. if ($this->authConfig && $method === 'addConfigSetting') {
  8217. $method = 'addSubNode';
  8218. list($mainNode, $name) = explode('.', $args[0], 2);
  8219. $args = array($mainNode, $name, $args[1]);
  8220. } elseif ($this->authConfig && $method === 'removeConfigSetting') {
  8221. $method = 'removeSubNode';
  8222. list($mainNode, $name) = explode('.', $args[0], 2);
  8223. $args = array($mainNode, $name);
  8224. }
  8225. if (call_user_func_array(array($manipulator, $method), $args)) {
  8226. file_put_contents($this->file->getPath(), $manipulator->getContents());
  8227. } else {
  8228. $config = $this->file->read();
  8229. $this->arrayUnshiftRef($args, $config);
  8230. call_user_func_array($fallback, $args);
  8231. foreach (array('require', 'require-dev', 'conflict', 'provide', 'replace', 'suggest', 'config', 'autoload', 'autoload-dev') as $linkType) {
  8232. if (isset($config[$linkType]) && $config[$linkType] === array()) {
  8233. $config[$linkType] = new \stdClass;
  8234. }
  8235. }
  8236. $this->file->write($config);
  8237. }
  8238. if ($newFile) {
  8239. Silencer::call('chmod', $this->file->getPath(), 0600);
  8240. }
  8241. }
  8242. private function arrayUnshiftRef(&$array, &$value)
  8243. {
  8244. $return = array_unshift($array, '');
  8245. $array[0] = &$value;
  8246. return $return;
  8247. }
  8248. }
  8249. <?php
  8250. namespace Composer\Console;
  8251. use Composer\IO\NullIO;
  8252. use Composer\Util\Platform;
  8253. use Composer\Util\Silencer;
  8254. use Symfony\Component\Console\Application as BaseApplication;
  8255. use Symfony\Component\Console\Exception\CommandNotFoundException;
  8256. use Symfony\Component\Console\Helper\HelperSet;
  8257. use Symfony\Component\Console\Helper\QuestionHelper;
  8258. use Symfony\Component\Console\Input\InputInterface;
  8259. use Symfony\Component\Console\Input\InputOption;
  8260. use Symfony\Component\Console\Output\OutputInterface;
  8261. use Seld\JsonLint\ParsingException;
  8262. use Composer\Command;
  8263. use Composer\Composer;
  8264. use Composer\Factory;
  8265. use Composer\IO\IOInterface;
  8266. use Composer\IO\ConsoleIO;
  8267. use Composer\Json\JsonValidationException;
  8268. use Composer\Util\ErrorHandler;
  8269. use Composer\EventDispatcher\ScriptExecutionException;
  8270. use Composer\Exception\NoSslException;
  8271. class Application extends BaseApplication
  8272. {
  8273. protected $composer;
  8274. protected $io;
  8275. private static $logo = ' ______
  8276. / ____/___ ____ ___ ____ ____ ________ _____
  8277. / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
  8278. / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
  8279. \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
  8280. /_/
  8281. ';
  8282. private $hasPluginCommands = false;
  8283. private $disablePluginsByDefault = false;
  8284. private $initialWorkingDirectory;
  8285. public function __construct()
  8286. {
  8287. static $shutdownRegistered = false;
  8288. if (function_exists('ini_set') && extension_loaded('xdebug')) {
  8289. ini_set('xdebug.show_exception_trace', false);
  8290. ini_set('xdebug.scream', false);
  8291. }
  8292. if (function_exists('date_default_timezone_set') && function_exists('date_default_timezone_get')) {
  8293. date_default_timezone_set(Silencer::call('date_default_timezone_get'));
  8294. }
  8295. if (!$shutdownRegistered) {
  8296. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  8297. pcntl_async_signals(true);
  8298. pcntl_signal(SIGINT, function ($sig) {
  8299. exit(130);
  8300. });
  8301. }
  8302. $shutdownRegistered = true;
  8303. register_shutdown_function(function () {
  8304. $lastError = error_get_last();
  8305. if ($lastError && $lastError['message'] &&
  8306. (strpos($lastError['message'], 'Allowed memory') !== false ||
  8307. strpos($lastError['message'], 'exceeded memory') !== false )) {
  8308. echo "\n". 'Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.';
  8309. }
  8310. });
  8311. }
  8312. $this->io = new NullIO();
  8313. $this->initialWorkingDirectory = getcwd();
  8314. parent::__construct('Composer', Composer::getVersion());
  8315. }
  8316. public function run(InputInterface $input = null, OutputInterface $output = null)
  8317. {
  8318. if (null === $output) {
  8319. $output = Factory::createOutput();
  8320. }
  8321. return parent::run($input, $output);
  8322. }
  8323. public function doRun(InputInterface $input, OutputInterface $output)
  8324. {
  8325. $this->disablePluginsByDefault = $input->hasParameterOption('--no-plugins');
  8326. if (getenv('COMPOSER_NO_INTERACTION')) {
  8327. $input->setInteractive(false);
  8328. }
  8329. $io = $this->io = new ConsoleIO($input, $output, new HelperSet(array(
  8330. new QuestionHelper(),
  8331. )));
  8332. ErrorHandler::register($io);
  8333. if ($input->hasParameterOption('--no-cache')) {
  8334. $io->writeError('Disabling cache usage', true, IOInterface::DEBUG);
  8335. $_SERVER['COMPOSER_CACHE_DIR'] = Platform::isWindows() ? 'nul' : '/dev/null';
  8336. putenv('COMPOSER_CACHE_DIR='.$_SERVER['COMPOSER_CACHE_DIR']);
  8337. }
  8338. if ($newWorkDir = $this->getNewWorkingDir($input)) {
  8339. $oldWorkingDir = getcwd();
  8340. chdir($newWorkDir);
  8341. $this->initialWorkingDirectory = $newWorkDir;
  8342. $io->writeError('Changed CWD to ' . getcwd(), true, IOInterface::DEBUG);
  8343. }
  8344. $commandName = '';
  8345. if ($name = $this->getCommandName($input)) {
  8346. try {
  8347. $commandName = $this->find($name)->getName();
  8348. } catch (CommandNotFoundException $e) {
  8349. $commandName = false;
  8350. } catch (\InvalidArgumentException $e) {
  8351. }
  8352. }
  8353. if ($io->isInteractive() && !$newWorkDir && !in_array($commandName, array('', 'list', 'init', 'about', 'help', 'diagnose', 'self-update', 'global', 'create-project', 'outdated'), true) && !file_exists(Factory::getComposerFile())) {
  8354. $dir = dirname(getcwd());
  8355. $home = realpath(getenv('HOME') ?: getenv('USERPROFILE') ?: '/');
  8356. while (dirname($dir) !== $dir && $dir !== $home) {
  8357. if (file_exists($dir.'/'.Factory::getComposerFile())) {
  8358. if ($io->askConfirmation('<info>No composer.json in current directory, do you want to use the one at '.$dir.'?</info> [<comment>Y,n</comment>]? ')) {
  8359. $oldWorkingDir = getcwd();
  8360. chdir($dir);
  8361. }
  8362. break;
  8363. }
  8364. $dir = dirname($dir);
  8365. }
  8366. }
  8367. if (!$this->disablePluginsByDefault && !$this->hasPluginCommands && 'global' !== $commandName) {
  8368. try {
  8369. foreach ($this->getPluginCommands() as $command) {
  8370. if ($this->has($command->getName())) {
  8371. $io->writeError('<warning>Plugin command '.$command->getName().' ('.get_class($command).') would override a Composer command and has been skipped</warning>');
  8372. } else {
  8373. $this->add($command);
  8374. }
  8375. }
  8376. } catch (NoSslException $e) {
  8377. } catch (ParsingException $e) {
  8378. $details = $e->getDetails();
  8379. $file = realpath(Factory::getComposerFile());
  8380. $line = null;
  8381. if ($details && isset($details['line'])) {
  8382. $line = $details['line'];
  8383. }
  8384. $ghe = new GithubActionError($this->io);
  8385. $ghe->emit($e->getMessage(), $file, $line);
  8386. throw $e;
  8387. }
  8388. $this->hasPluginCommands = true;
  8389. }
  8390. $isProxyCommand = false;
  8391. if ($name = $this->getCommandName($input)) {
  8392. try {
  8393. $command = $this->find($name);
  8394. $commandName = $command->getName();
  8395. $isProxyCommand = ($command instanceof Command\BaseCommand && $command->isProxyCommand());
  8396. } catch (\InvalidArgumentException $e) {
  8397. }
  8398. }
  8399. if (!$isProxyCommand) {
  8400. $io->writeError(sprintf(
  8401. 'Running %s (%s) with %s on %s',
  8402. Composer::getVersion(),
  8403. Composer::RELEASE_DATE,
  8404. defined('HHVM_VERSION') ? 'HHVM '.HHVM_VERSION : 'PHP '.PHP_VERSION,
  8405. function_exists('php_uname') ? php_uname('s') . ' / ' . php_uname('r') : 'Unknown OS'
  8406. ), true, IOInterface::DEBUG);
  8407. if (PHP_VERSION_ID < 50302) {
  8408. $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>');
  8409. }
  8410. if (extension_loaded('xdebug') && !getenv('COMPOSER_DISABLE_XDEBUG_WARN')) {
  8411. $io->writeError('<warning>You are running composer with Xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug</warning>');
  8412. }
  8413. if (defined('COMPOSER_DEV_WARNING_TIME') && $commandName !== 'self-update' && $commandName !== 'selfupdate' && time() > COMPOSER_DEV_WARNING_TIME) {
  8414. $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']));
  8415. }
  8416. if (
  8417. !Platform::isWindows()
  8418. && function_exists('exec')
  8419. && !getenv('COMPOSER_ALLOW_SUPERUSER')
  8420. && (ini_get('open_basedir') || !file_exists('/.dockerenv'))
  8421. ) {
  8422. if (function_exists('posix_getuid') && posix_getuid() === 0) {
  8423. if ($commandName !== 'self-update' && $commandName !== 'selfupdate') {
  8424. $io->writeError('<warning>Do not run Composer as root/super user! See https://getcomposer.org/root for details</warning>');
  8425. if ($io->isInteractive()) {
  8426. if (!$io->askConfirmation('<info>Continue as root/super user</info> [<comment>yes</comment>]? ')) {
  8427. return 1;
  8428. }
  8429. }
  8430. }
  8431. if ($uid = (int) getenv('SUDO_UID')) {
  8432. Silencer::call('exec', "sudo -u \\#{$uid} sudo -K > /dev/null 2>&1");
  8433. }
  8434. }
  8435. Silencer::call('exec', 'sudo -K > /dev/null 2>&1');
  8436. }
  8437. Silencer::call(function () use ($io) {
  8438. $tempfile = sys_get_temp_dir() . '/temp-' . md5(microtime());
  8439. if (!(file_put_contents($tempfile, __FILE__) && (file_get_contents($tempfile) == __FILE__) && unlink($tempfile) && !file_exists($tempfile))) {
  8440. $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()));
  8441. }
  8442. });
  8443. $file = Factory::getComposerFile();
  8444. if (is_file($file) && is_readable($file) && is_array($composer = json_decode(file_get_contents($file), true))) {
  8445. if (isset($composer['scripts']) && is_array($composer['scripts'])) {
  8446. foreach ($composer['scripts'] as $script => $dummy) {
  8447. if (!defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
  8448. if ($this->has($script)) {
  8449. $io->writeError('<warning>A script named '.$script.' would override a Composer command and has been skipped</warning>');
  8450. } else {
  8451. $description = null;
  8452. if (isset($composer['scripts-descriptions'][$script])) {
  8453. $description = $composer['scripts-descriptions'][$script];
  8454. }
  8455. $this->add(new Command\ScriptAliasCommand($script, $description));
  8456. }
  8457. }
  8458. }
  8459. }
  8460. }
  8461. }
  8462. try {
  8463. if ($input->hasParameterOption('--profile')) {
  8464. $startTime = microtime(true);
  8465. $this->io->enableDebugging($startTime);
  8466. }
  8467. $result = parent::doRun($input, $output);
  8468. if (isset($oldWorkingDir)) {
  8469. chdir($oldWorkingDir);
  8470. }
  8471. if (isset($startTime)) {
  8472. $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');
  8473. }
  8474. restore_error_handler();
  8475. return $result;
  8476. } catch (ScriptExecutionException $e) {
  8477. return (int) $e->getCode();
  8478. } catch (\Exception $e) {
  8479. $ghe = new GithubActionError($this->io);
  8480. $ghe->emit($e->getMessage());
  8481. $this->hintCommonErrors($e);
  8482. restore_error_handler();
  8483. throw $e;
  8484. }
  8485. }
  8486. private function getNewWorkingDir(InputInterface $input)
  8487. {
  8488. $workingDir = $input->getParameterOption(array('--working-dir', '-d'));
  8489. if (false !== $workingDir && !is_dir($workingDir)) {
  8490. throw new \RuntimeException('Invalid working directory specified, '.$workingDir.' does not exist.');
  8491. }
  8492. return $workingDir;
  8493. }
  8494. private function hintCommonErrors($exception)
  8495. {
  8496. $io = $this->getIO();
  8497. Silencer::suppress();
  8498. try {
  8499. $composer = $this->getComposer(false, true);
  8500. if ($composer) {
  8501. $config = $composer->getConfig();
  8502. $minSpaceFree = 1024 * 1024;
  8503. if ((($df = disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree)
  8504. || (($df = disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)
  8505. || (($df = disk_free_space($dir = sys_get_temp_dir())) !== false && $df < $minSpaceFree)
  8506. ) {
  8507. $io->writeError('<error>The disk hosting '.$dir.' is full, this may be the cause of the following exception</error>', true, IOInterface::QUIET);
  8508. }
  8509. }
  8510. } catch (\Exception $e) {
  8511. }
  8512. Silencer::restore();
  8513. if (Platform::isWindows() && false !== strpos($exception->getMessage(), 'The system cannot find the path specified')) {
  8514. $io->writeError('<error>The following exception may be caused by a stale entry in your cmd.exe AutoRun</error>', true, IOInterface::QUIET);
  8515. $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);
  8516. }
  8517. if (false !== strpos($exception->getMessage(), 'fork failed - Cannot allocate memory')) {
  8518. $io->writeError('<error>The following exception is caused by a lack of memory or swap, or not having swap configured</error>', true, IOInterface::QUIET);
  8519. $io->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details</error>', true, IOInterface::QUIET);
  8520. }
  8521. }
  8522. public function getComposer($required = true, $disablePlugins = null)
  8523. {
  8524. if (null === $disablePlugins) {
  8525. $disablePlugins = $this->disablePluginsByDefault;
  8526. }
  8527. if (null === $this->composer) {
  8528. try {
  8529. $this->composer = Factory::create($this->io, null, $disablePlugins);
  8530. } catch (\InvalidArgumentException $e) {
  8531. if ($required) {
  8532. $this->io->writeError($e->getMessage());
  8533. exit(1);
  8534. }
  8535. } catch (JsonValidationException $e) {
  8536. $errors = ' - ' . implode(PHP_EOL . ' - ', $e->getErrors());
  8537. $message = $e->getMessage() . ':' . PHP_EOL . $errors;
  8538. throw new JsonValidationException($message);
  8539. }
  8540. }
  8541. return $this->composer;
  8542. }
  8543. public function resetComposer()
  8544. {
  8545. $this->composer = null;
  8546. if ($this->getIO() && method_exists($this->getIO(), 'resetAuthentications')) {
  8547. $this->getIO()->resetAuthentications();
  8548. }
  8549. }
  8550. public function getIO()
  8551. {
  8552. return $this->io;
  8553. }
  8554. public function getHelp()
  8555. {
  8556. return self::$logo . parent::getHelp();
  8557. }
  8558. protected function getDefaultCommands()
  8559. {
  8560. $commands = array_merge(parent::getDefaultCommands(), array(
  8561. new Command\AboutCommand(),
  8562. new Command\ConfigCommand(),
  8563. new Command\DependsCommand(),
  8564. new Command\ProhibitsCommand(),
  8565. new Command\InitCommand(),
  8566. new Command\InstallCommand(),
  8567. new Command\CreateProjectCommand(),
  8568. new Command\UpdateCommand(),
  8569. new Command\SearchCommand(),
  8570. new Command\ValidateCommand(),
  8571. new Command\ShowCommand(),
  8572. new Command\SuggestsCommand(),
  8573. new Command\RequireCommand(),
  8574. new Command\DumpAutoloadCommand(),
  8575. new Command\StatusCommand(),
  8576. new Command\ArchiveCommand(),
  8577. new Command\DiagnoseCommand(),
  8578. new Command\RunScriptCommand(),
  8579. new Command\LicensesCommand(),
  8580. new Command\GlobalCommand(),
  8581. new Command\ClearCacheCommand(),
  8582. new Command\RemoveCommand(),
  8583. new Command\HomeCommand(),
  8584. new Command\ExecCommand(),
  8585. new Command\OutdatedCommand(),
  8586. new Command\CheckPlatformReqsCommand(),
  8587. new Command\FundCommand(),
  8588. ));
  8589. if (strpos(__FILE__, 'phar:') === 0) {
  8590. $commands[] = new Command\SelfUpdateCommand();
  8591. }
  8592. return $commands;
  8593. }
  8594. public function getLongVersion()
  8595. {
  8596. if (Composer::BRANCH_ALIAS_VERSION && Composer::BRANCH_ALIAS_VERSION !== '@package_branch_alias_version'.'@') {
  8597. return sprintf(
  8598. '<info>%s</info> version <comment>%s (%s)</comment> %s',
  8599. $this->getName(),
  8600. Composer::BRANCH_ALIAS_VERSION,
  8601. $this->getVersion(),
  8602. Composer::RELEASE_DATE
  8603. );
  8604. }
  8605. return parent::getLongVersion() . ' ' . Composer::RELEASE_DATE;
  8606. }
  8607. protected function getDefaultInputDefinition()
  8608. {
  8609. $definition = parent::getDefaultInputDefinition();
  8610. $definition->addOption(new InputOption('--profile', null, InputOption::VALUE_NONE, 'Display timing and memory usage information'));
  8611. $definition->addOption(new InputOption('--no-plugins', null, InputOption::VALUE_NONE, 'Whether to disable plugins.'));
  8612. $definition->addOption(new InputOption('--working-dir', '-d', InputOption::VALUE_REQUIRED, 'If specified, use the given directory as working directory.'));
  8613. $definition->addOption(new InputOption('--no-cache', null, InputOption::VALUE_NONE, 'Prevent use of the cache'));
  8614. return $definition;
  8615. }
  8616. private function getPluginCommands()
  8617. {
  8618. $commands = array();
  8619. $composer = $this->getComposer(false, false);
  8620. if (null === $composer) {
  8621. $composer = Factory::createGlobal($this->io);
  8622. }
  8623. if (null !== $composer) {
  8624. $pm = $composer->getPluginManager();
  8625. foreach ($pm->getPluginCapabilities('Composer\Plugin\Capability\CommandProvider', array('composer' => $composer, 'io' => $this->io)) as $capability) {
  8626. $newCommands = $capability->getCommands();
  8627. if (!is_array($newCommands)) {
  8628. throw new \UnexpectedValueException('Plugin capability '.get_class($capability).' failed to return an array from getCommands');
  8629. }
  8630. foreach ($newCommands as $command) {
  8631. if (!$command instanceof Command\BaseCommand) {
  8632. throw new \UnexpectedValueException('Plugin capability '.get_class($capability).' returned an invalid value, we expected an array of Composer\Command\BaseCommand objects');
  8633. }
  8634. }
  8635. $commands = array_merge($commands, $newCommands);
  8636. }
  8637. }
  8638. return $commands;
  8639. }
  8640. public function getInitialWorkingDirectory()
  8641. {
  8642. return $this->initialWorkingDirectory;
  8643. }
  8644. }
  8645. <?php
  8646. namespace Composer\Console;
  8647. use Composer\IO\IOInterface;
  8648. final class GithubActionError
  8649. {
  8650. protected $io;
  8651. public function __construct(IOInterface $io)
  8652. {
  8653. $this->io = $io;
  8654. }
  8655. public function emit($message, $file = null, $line = null)
  8656. {
  8657. if (getenv('GITHUB_ACTIONS') && !getenv('COMPOSER_TESTS_ARE_RUNNING')) {
  8658. $message = str_replace("\n", '%0A', $message);
  8659. if ($file && $line) {
  8660. $this->io->write("::error file=". $file .",line=". $line ."::". $message);
  8661. } elseif ($file) {
  8662. $this->io->write("::error file=". $file ."::". $message);
  8663. } else {
  8664. $this->io->write("::error ::". $message);
  8665. }
  8666. }
  8667. }
  8668. }
  8669. <?php
  8670. namespace Composer\Console;
  8671. use Symfony\Component\Console\Formatter\OutputFormatter;
  8672. class HtmlOutputFormatter extends OutputFormatter
  8673. {
  8674. private static $availableForegroundColors = array(
  8675. 30 => 'black',
  8676. 31 => 'red',
  8677. 32 => 'green',
  8678. 33 => 'yellow',
  8679. 34 => 'blue',
  8680. 35 => 'magenta',
  8681. 36 => 'cyan',
  8682. 37 => 'white',
  8683. );
  8684. private static $availableBackgroundColors = array(
  8685. 40 => 'black',
  8686. 41 => 'red',
  8687. 42 => 'green',
  8688. 43 => 'yellow',
  8689. 44 => 'blue',
  8690. 45 => 'magenta',
  8691. 46 => 'cyan',
  8692. 47 => 'white',
  8693. );
  8694. private static $availableOptions = array(
  8695. 1 => 'bold',
  8696. 4 => 'underscore',
  8697. );
  8698. public function __construct(array $styles = array())
  8699. {
  8700. parent::__construct(true, $styles);
  8701. }
  8702. public function format($message)
  8703. {
  8704. $formatted = parent::format($message);
  8705. $clearEscapeCodes = '(?:39|49|0|22|24|25|27|28)';
  8706. return preg_replace_callback("{\033\[([0-9;]+)m(.*?)\033\[(?:".$clearEscapeCodes.";)*?".$clearEscapeCodes."m}s", array($this, 'formatHtml'), $formatted);
  8707. }
  8708. private function formatHtml($matches)
  8709. {
  8710. $out = '<span style="';
  8711. foreach (explode(';', $matches[1]) as $code) {
  8712. if (isset(self::$availableForegroundColors[$code])) {
  8713. $out .= 'color:'.self::$availableForegroundColors[$code].';';
  8714. } elseif (isset(self::$availableBackgroundColors[$code])) {
  8715. $out .= 'background-color:'.self::$availableBackgroundColors[$code].';';
  8716. } elseif (isset(self::$availableOptions[$code])) {
  8717. switch (self::$availableOptions[$code]) {
  8718. case 'bold':
  8719. $out .= 'font-weight:bold;';
  8720. break;
  8721. case 'underscore':
  8722. $out .= 'text-decoration:underline;';
  8723. break;
  8724. }
  8725. }
  8726. }
  8727. return $out.'">'.$matches[2].'</span>';
  8728. }
  8729. }
  8730. <?php
  8731. namespace Composer\DependencyResolver;
  8732. class Decisions implements \Iterator, \Countable
  8733. {
  8734. const DECISION_LITERAL = 0;
  8735. const DECISION_REASON = 1;
  8736. protected $pool;
  8737. protected $decisionMap;
  8738. protected $decisionQueue = array();
  8739. public function __construct($pool)
  8740. {
  8741. $this->pool = $pool;
  8742. $this->decisionMap = array();
  8743. }
  8744. public function decide($literal, $level, $why)
  8745. {
  8746. $this->addDecision($literal, $level);
  8747. $this->decisionQueue[] = array(
  8748. self::DECISION_LITERAL => $literal,
  8749. self::DECISION_REASON => $why,
  8750. );
  8751. }
  8752. public function satisfy($literal)
  8753. {
  8754. $packageId = abs($literal);
  8755. return (
  8756. $literal > 0 && isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0 ||
  8757. $literal < 0 && isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] < 0
  8758. );
  8759. }
  8760. public function conflict($literal)
  8761. {
  8762. $packageId = abs($literal);
  8763. return (
  8764. (isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0 && $literal < 0) ||
  8765. (isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] < 0 && $literal > 0)
  8766. );
  8767. }
  8768. public function decided($literalOrPackageId)
  8769. {
  8770. return !empty($this->decisionMap[abs($literalOrPackageId)]);
  8771. }
  8772. public function undecided($literalOrPackageId)
  8773. {
  8774. return empty($this->decisionMap[abs($literalOrPackageId)]);
  8775. }
  8776. public function decidedInstall($literalOrPackageId)
  8777. {
  8778. $packageId = abs($literalOrPackageId);
  8779. return isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0;
  8780. }
  8781. public function decisionLevel($literalOrPackageId)
  8782. {
  8783. $packageId = abs($literalOrPackageId);
  8784. if (isset($this->decisionMap[$packageId])) {
  8785. return abs($this->decisionMap[$packageId]);
  8786. }
  8787. return 0;
  8788. }
  8789. public function decisionRule($literalOrPackageId)
  8790. {
  8791. $packageId = abs($literalOrPackageId);
  8792. foreach ($this->decisionQueue as $i => $decision) {
  8793. if ($packageId === abs($decision[self::DECISION_LITERAL])) {
  8794. return $decision[self::DECISION_REASON];
  8795. }
  8796. }
  8797. return null;
  8798. }
  8799. public function atOffset($queueOffset)
  8800. {
  8801. return $this->decisionQueue[$queueOffset];
  8802. }
  8803. public function validOffset($queueOffset)
  8804. {
  8805. return $queueOffset >= 0 && $queueOffset < \count($this->decisionQueue);
  8806. }
  8807. public function lastReason()
  8808. {
  8809. return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_REASON];
  8810. }
  8811. public function lastLiteral()
  8812. {
  8813. return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_LITERAL];
  8814. }
  8815. public function reset()
  8816. {
  8817. while ($decision = array_pop($this->decisionQueue)) {
  8818. $this->decisionMap[abs($decision[self::DECISION_LITERAL])] = 0;
  8819. }
  8820. }
  8821. public function resetToOffset($offset)
  8822. {
  8823. while (\count($this->decisionQueue) > $offset + 1) {
  8824. $decision = array_pop($this->decisionQueue);
  8825. $this->decisionMap[abs($decision[self::DECISION_LITERAL])] = 0;
  8826. }
  8827. }
  8828. public function revertLast()
  8829. {
  8830. $this->decisionMap[abs($this->lastLiteral())] = 0;
  8831. array_pop($this->decisionQueue);
  8832. }
  8833. public function count()
  8834. {
  8835. return \count($this->decisionQueue);
  8836. }
  8837. public function rewind()
  8838. {
  8839. end($this->decisionQueue);
  8840. }
  8841. public function current()
  8842. {
  8843. return current($this->decisionQueue);
  8844. }
  8845. public function key()
  8846. {
  8847. return key($this->decisionQueue);
  8848. }
  8849. public function next()
  8850. {
  8851. return prev($this->decisionQueue);
  8852. }
  8853. public function valid()
  8854. {
  8855. return false !== current($this->decisionQueue);
  8856. }
  8857. public function isEmpty()
  8858. {
  8859. return \count($this->decisionQueue) === 0;
  8860. }
  8861. protected function addDecision($literal, $level)
  8862. {
  8863. $packageId = abs($literal);
  8864. $previousDecision = isset($this->decisionMap[$packageId]) ? $this->decisionMap[$packageId] : null;
  8865. if ($previousDecision != 0) {
  8866. $literalString = $this->pool->literalToPrettyString($literal, array());
  8867. $package = $this->pool->literalToPackage($literal);
  8868. throw new SolverBugException(
  8869. "Trying to decide $literalString on level $level, even though $package was previously decided as ".(int) $previousDecision."."
  8870. );
  8871. }
  8872. if ($literal > 0) {
  8873. $this->decisionMap[$packageId] = $level;
  8874. } else {
  8875. $this->decisionMap[$packageId] = -$level;
  8876. }
  8877. }
  8878. public function __toString()
  8879. {
  8880. $decisionMap = $this->decisionMap;
  8881. ksort($decisionMap);
  8882. $str = '[';
  8883. foreach ($decisionMap as $packageId => $level) {
  8884. $str .= $packageId.':'.$level.',';
  8885. }
  8886. $str .= ']';
  8887. return $str;
  8888. }
  8889. }
  8890. <?php
  8891. namespace Composer\DependencyResolver;
  8892. use Composer\Package\PackageInterface;
  8893. use Composer\Package\AliasPackage;
  8894. use Composer\Package\BasePackage;
  8895. use Composer\Semver\Constraint\Constraint;
  8896. class DefaultPolicy implements PolicyInterface
  8897. {
  8898. private $preferStable;
  8899. private $preferLowest;
  8900. public function __construct($preferStable = false, $preferLowest = false)
  8901. {
  8902. $this->preferStable = $preferStable;
  8903. $this->preferLowest = $preferLowest;
  8904. }
  8905. public function versionCompare(PackageInterface $a, PackageInterface $b, $operator)
  8906. {
  8907. if ($this->preferStable && ($stabA = $a->getStability()) !== ($stabB = $b->getStability())) {
  8908. return BasePackage::$stabilities[$stabA] < BasePackage::$stabilities[$stabB];
  8909. }
  8910. $constraint = new Constraint($operator, $b->getVersion());
  8911. $version = new Constraint('==', $a->getVersion());
  8912. return $constraint->matchSpecific($version, true);
  8913. }
  8914. public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null)
  8915. {
  8916. $packages = $this->groupLiteralsByName($pool, $literals);
  8917. $policy = $this;
  8918. foreach ($packages as &$nameLiterals) {
  8919. usort($nameLiterals, function ($a, $b) use ($policy, $pool, $requiredPackage) {
  8920. return $policy->compareByPriority($pool, $pool->literalToPackage($a), $pool->literalToPackage($b), $requiredPackage, true);
  8921. });
  8922. }
  8923. foreach ($packages as &$sortedLiterals) {
  8924. $sortedLiterals = $this->pruneToBestVersion($pool, $sortedLiterals);
  8925. $sortedLiterals = $this->pruneRemoteAliases($pool, $sortedLiterals);
  8926. }
  8927. $selected = \call_user_func_array('array_merge', array_values($packages));
  8928. usort($selected, function ($a, $b) use ($policy, $pool, $requiredPackage) {
  8929. return $policy->compareByPriority($pool, $pool->literalToPackage($a), $pool->literalToPackage($b), $requiredPackage);
  8930. });
  8931. return $selected;
  8932. }
  8933. protected function groupLiteralsByName(Pool $pool, $literals)
  8934. {
  8935. $packages = array();
  8936. foreach ($literals as $literal) {
  8937. $packageName = $pool->literalToPackage($literal)->getName();
  8938. if (!isset($packages[$packageName])) {
  8939. $packages[$packageName] = array();
  8940. }
  8941. $packages[$packageName][] = $literal;
  8942. }
  8943. return $packages;
  8944. }
  8945. public function compareByPriority(Pool $pool, PackageInterface $a, PackageInterface $b, $requiredPackage = null, $ignoreReplace = false)
  8946. {
  8947. if ($a->getName() === $b->getName()) {
  8948. $aAliased = $a instanceof AliasPackage;
  8949. $bAliased = $b instanceof AliasPackage;
  8950. if ($aAliased && !$bAliased) {
  8951. return -1;
  8952. }
  8953. if (!$aAliased && $bAliased) {
  8954. return 1;
  8955. }
  8956. }
  8957. if (!$ignoreReplace) {
  8958. if ($this->replaces($a, $b)) {
  8959. return 1;
  8960. }
  8961. if ($this->replaces($b, $a)) {
  8962. return -1;
  8963. }
  8964. if ($requiredPackage && false !== ($pos = strpos($requiredPackage, '/'))) {
  8965. $requiredVendor = substr($requiredPackage, 0, $pos);
  8966. $aIsSameVendor = strpos($a->getName(), $requiredVendor) === 0;
  8967. $bIsSameVendor = strpos($b->getName(), $requiredVendor) === 0;
  8968. if ($bIsSameVendor !== $aIsSameVendor) {
  8969. return $aIsSameVendor ? -1 : 1;
  8970. }
  8971. }
  8972. }
  8973. if ($a->id === $b->id) {
  8974. return 0;
  8975. }
  8976. return ($a->id < $b->id) ? -1 : 1;
  8977. }
  8978. protected function replaces(PackageInterface $source, PackageInterface $target)
  8979. {
  8980. foreach ($source->getReplaces() as $link) {
  8981. if ($link->getTarget() === $target->getName()
  8982. ) {
  8983. return true;
  8984. }
  8985. }
  8986. return false;
  8987. }
  8988. protected function pruneToBestVersion(Pool $pool, $literals)
  8989. {
  8990. $operator = $this->preferLowest ? '<' : '>';
  8991. $bestLiterals = array($literals[0]);
  8992. $bestPackage = $pool->literalToPackage($literals[0]);
  8993. foreach ($literals as $i => $literal) {
  8994. if (0 === $i) {
  8995. continue;
  8996. }
  8997. $package = $pool->literalToPackage($literal);
  8998. if ($this->versionCompare($package, $bestPackage, $operator)) {
  8999. $bestPackage = $package;
  9000. $bestLiterals = array($literal);
  9001. } elseif ($this->versionCompare($package, $bestPackage, '==')) {
  9002. $bestLiterals[] = $literal;
  9003. }
  9004. }
  9005. return $bestLiterals;
  9006. }
  9007. protected function pruneRemoteAliases(Pool $pool, array $literals)
  9008. {
  9009. $hasLocalAlias = false;
  9010. foreach ($literals as $literal) {
  9011. $package = $pool->literalToPackage($literal);
  9012. if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
  9013. $hasLocalAlias = true;
  9014. break;
  9015. }
  9016. }
  9017. if (!$hasLocalAlias) {
  9018. return $literals;
  9019. }
  9020. $selected = array();
  9021. foreach ($literals as $literal) {
  9022. $package = $pool->literalToPackage($literal);
  9023. if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
  9024. $selected[] = $literal;
  9025. }
  9026. }
  9027. return $selected;
  9028. }
  9029. }
  9030. <?php
  9031. namespace Composer\DependencyResolver;
  9032. use Composer\Package\PackageInterface;
  9033. use Composer\Package\Link;
  9034. class GenericRule extends Rule
  9035. {
  9036. protected $literals;
  9037. public function __construct(array $literals, $reason, $reasonData)
  9038. {
  9039. parent::__construct($reason, $reasonData);
  9040. sort($literals);
  9041. $this->literals = $literals;
  9042. }
  9043. public function getLiterals()
  9044. {
  9045. return $this->literals;
  9046. }
  9047. public function getHash()
  9048. {
  9049. $data = unpack('ihash', md5(implode(',', $this->literals), true));
  9050. return $data['hash'];
  9051. }
  9052. public function equals(Rule $rule)
  9053. {
  9054. return $this->literals === $rule->getLiterals();
  9055. }
  9056. public function isAssertion()
  9057. {
  9058. return 1 === \count($this->literals);
  9059. }
  9060. public function __toString()
  9061. {
  9062. $result = $this->isDisabled() ? 'disabled(' : '(';
  9063. foreach ($this->literals as $i => $literal) {
  9064. if ($i != 0) {
  9065. $result .= '|';
  9066. }
  9067. $result .= $literal;
  9068. }
  9069. $result .= ')';
  9070. return $result;
  9071. }
  9072. }
  9073. <?php
  9074. namespace Composer\DependencyResolver;
  9075. use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
  9076. use Composer\DependencyResolver\Operation\UninstallOperation;
  9077. use Composer\Package\AliasPackage;
  9078. use Composer\Package\Link;
  9079. use Composer\Package\PackageInterface;
  9080. use Composer\Repository\PlatformRepository;
  9081. use Composer\Repository\RepositoryInterface;
  9082. use Composer\Semver\Constraint\Constraint;
  9083. class LocalRepoTransaction extends Transaction
  9084. {
  9085. public function __construct(RepositoryInterface $lockedRepository, $localRepository)
  9086. {
  9087. parent::__construct(
  9088. $localRepository->getPackages(),
  9089. $lockedRepository->getPackages()
  9090. );
  9091. }
  9092. }
  9093. <?php
  9094. namespace Composer\DependencyResolver;
  9095. use Composer\DependencyResolver\Operation\OperationInterface;
  9096. use Composer\Package\AliasPackage;
  9097. use Composer\Package\RootAliasPackage;
  9098. use Composer\Package\RootPackageInterface;
  9099. use Composer\Repository\ArrayRepository;
  9100. use Composer\Repository\RepositoryInterface;
  9101. use Composer\Test\Repository\ArrayRepositoryTest;
  9102. class LockTransaction extends Transaction
  9103. {
  9104. protected $presentMap;
  9105. protected $unlockableMap;
  9106. protected $resultPackages;
  9107. public function __construct(Pool $pool, $presentMap, $unlockableMap, $decisions)
  9108. {
  9109. $this->presentMap = $presentMap;
  9110. $this->unlockableMap = $unlockableMap;
  9111. $this->setResultPackages($pool, $decisions);
  9112. parent::__construct($this->presentMap, $this->resultPackages['all']);
  9113. }
  9114. public function setResultPackages(Pool $pool, Decisions $decisions)
  9115. {
  9116. $this->resultPackages = array('all' => array(), 'non-dev' => array(), 'dev' => array());
  9117. foreach ($decisions as $i => $decision) {
  9118. $literal = $decision[Decisions::DECISION_LITERAL];
  9119. if ($literal > 0) {
  9120. $package = $pool->literalToPackage($literal);
  9121. $this->resultPackages['all'][] = $package;
  9122. if (!isset($this->unlockableMap[$package->id])) {
  9123. $this->resultPackages['non-dev'][] = $package;
  9124. }
  9125. }
  9126. }
  9127. }
  9128. public function setNonDevPackages(LockTransaction $extractionResult)
  9129. {
  9130. $packages = $extractionResult->getNewLockPackages(false);
  9131. $this->resultPackages['dev'] = $this->resultPackages['non-dev'];
  9132. $this->resultPackages['non-dev'] = array();
  9133. foreach ($packages as $package) {
  9134. foreach ($this->resultPackages['dev'] as $i => $resultPackage) {
  9135. if ($package->getName() == $resultPackage->getName()) {
  9136. $this->resultPackages['non-dev'][] = $resultPackage;
  9137. unset($this->resultPackages['dev'][$i]);
  9138. }
  9139. }
  9140. }
  9141. }
  9142. public function getNewLockPackages($devMode, $updateMirrors = false)
  9143. {
  9144. $packages = array();
  9145. foreach ($this->resultPackages[$devMode ? 'dev' : 'non-dev'] as $package) {
  9146. if (!($package instanceof AliasPackage) && !($package instanceof RootAliasPackage)) {
  9147. if ($updateMirrors && !isset($this->presentMap[spl_object_hash($package)])) {
  9148. foreach ($this->presentMap as $presentPackage) {
  9149. if ($package->getName() == $presentPackage->getName() &&
  9150. $package->getVersion() == $presentPackage->getVersion() &&
  9151. $presentPackage->getSourceReference() &&
  9152. $presentPackage->getSourceType() === $package->getSourceType()
  9153. ) {
  9154. $package->setSourceDistReferences($presentPackage->getSourceReference());
  9155. }
  9156. }
  9157. }
  9158. $packages[] = $package;
  9159. }
  9160. }
  9161. return $packages;
  9162. }
  9163. public function getAliases($aliases)
  9164. {
  9165. $usedAliases = array();
  9166. foreach ($this->resultPackages['all'] as $package) {
  9167. if ($package instanceof AliasPackage) {
  9168. foreach ($aliases as $index => $alias) {
  9169. if ($alias['package'] === $package->getName()) {
  9170. $usedAliases[] = $alias;
  9171. unset($aliases[$index]);
  9172. }
  9173. }
  9174. }
  9175. }
  9176. return $usedAliases;
  9177. }
  9178. }
  9179. <?php
  9180. namespace Composer\DependencyResolver;
  9181. use Composer\Package\PackageInterface;
  9182. use Composer\Package\Link;
  9183. class MultiConflictRule extends Rule
  9184. {
  9185. protected $literals;
  9186. public function __construct(array $literals, $reason, $reasonData)
  9187. {
  9188. parent::__construct($reason, $reasonData);
  9189. if (\count($literals) < 3) {
  9190. throw new \RuntimeException("multi conflict rule requires at least 3 literals");
  9191. }
  9192. sort($literals);
  9193. $this->literals = $literals;
  9194. }
  9195. public function getLiterals()
  9196. {
  9197. return $this->literals;
  9198. }
  9199. public function getHash()
  9200. {
  9201. $data = unpack('ihash', md5('c:'.implode(',', $this->literals), true));
  9202. return $data['hash'];
  9203. }
  9204. public function equals(Rule $rule)
  9205. {
  9206. if ($rule instanceof MultiConflictRule) {
  9207. return $this->literals === $rule->getLiterals();
  9208. }
  9209. return false;
  9210. }
  9211. public function isAssertion()
  9212. {
  9213. return false;
  9214. }
  9215. public function disable()
  9216. {
  9217. 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.");
  9218. }
  9219. public function __toString()
  9220. {
  9221. $result = $this->isDisabled() ? 'disabled(multi(' : '(multi(';
  9222. foreach ($this->literals as $i => $literal) {
  9223. if ($i != 0) {
  9224. $result .= '|';
  9225. }
  9226. $result .= $literal;
  9227. }
  9228. $result .= '))';
  9229. return $result;
  9230. }
  9231. }
  9232. <?php
  9233. namespace Composer\DependencyResolver\Operation;
  9234. use Composer\Package\PackageInterface;
  9235. class InstallOperation extends SolverOperation implements OperationInterface
  9236. {
  9237. const TYPE = 'install';
  9238. protected $package;
  9239. public function __construct(PackageInterface $package)
  9240. {
  9241. $this->package = $package;
  9242. }
  9243. public function getPackage()
  9244. {
  9245. return $this->package;
  9246. }
  9247. public function show($lock)
  9248. {
  9249. return self::format($this->package, $lock);
  9250. }
  9251. public static function format(PackageInterface $package, $lock = false)
  9252. {
  9253. return ($lock ? 'Locking ' : 'Installing ').'<info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
  9254. }
  9255. }
  9256. <?php
  9257. namespace Composer\DependencyResolver\Operation;
  9258. use Composer\Package\AliasPackage;
  9259. use Composer\Package\PackageInterface;
  9260. class MarkAliasInstalledOperation extends SolverOperation implements OperationInterface
  9261. {
  9262. const TYPE = 'markAliasInstalled';
  9263. protected $package;
  9264. public function __construct(AliasPackage $package)
  9265. {
  9266. $this->package = $package;
  9267. }
  9268. public function getPackage()
  9269. {
  9270. return $this->package;
  9271. }
  9272. public function show($lock)
  9273. {
  9274. 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>)';
  9275. }
  9276. }
  9277. <?php
  9278. namespace Composer\DependencyResolver\Operation;
  9279. use Composer\Package\AliasPackage;
  9280. use Composer\Package\PackageInterface;
  9281. class MarkAliasUninstalledOperation extends SolverOperation implements OperationInterface
  9282. {
  9283. const TYPE = 'markAliasUninstalled';
  9284. protected $package;
  9285. public function __construct(AliasPackage $package)
  9286. {
  9287. $this->package = $package;
  9288. }
  9289. public function getPackage()
  9290. {
  9291. return $this->package;
  9292. }
  9293. public function show($lock)
  9294. {
  9295. 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>)';
  9296. }
  9297. }
  9298. <?php
  9299. namespace Composer\DependencyResolver\Operation;
  9300. interface OperationInterface
  9301. {
  9302. public function getOperationType();
  9303. public function show($lock);
  9304. public function __toString();
  9305. }
  9306. <?php
  9307. namespace Composer\DependencyResolver\Operation;
  9308. use Composer\Package\PackageInterface;
  9309. abstract class SolverOperation implements OperationInterface
  9310. {
  9311. const TYPE = null;
  9312. public function getOperationType()
  9313. {
  9314. return static::TYPE;
  9315. }
  9316. public function __toString()
  9317. {
  9318. return $this->show(false);
  9319. }
  9320. }
  9321. <?php
  9322. namespace Composer\DependencyResolver\Operation;
  9323. use Composer\Package\PackageInterface;
  9324. class UninstallOperation extends SolverOperation implements OperationInterface
  9325. {
  9326. const TYPE = 'uninstall';
  9327. protected $package;
  9328. public function __construct(PackageInterface $package)
  9329. {
  9330. $this->package = $package;
  9331. }
  9332. public function getPackage()
  9333. {
  9334. return $this->package;
  9335. }
  9336. public function show($lock)
  9337. {
  9338. return self::format($this->package, $lock);
  9339. }
  9340. public static function format(PackageInterface $package, $lock = false)
  9341. {
  9342. return 'Removing <info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
  9343. }
  9344. }
  9345. <?php
  9346. namespace Composer\DependencyResolver\Operation;
  9347. use Composer\Package\PackageInterface;
  9348. use Composer\Package\Version\VersionParser;
  9349. class UpdateOperation extends SolverOperation implements OperationInterface
  9350. {
  9351. const TYPE = 'update';
  9352. protected $initialPackage;
  9353. protected $targetPackage;
  9354. public function __construct(PackageInterface $initial, PackageInterface $target)
  9355. {
  9356. $this->initialPackage = $initial;
  9357. $this->targetPackage = $target;
  9358. }
  9359. public function getInitialPackage()
  9360. {
  9361. return $this->initialPackage;
  9362. }
  9363. public function getTargetPackage()
  9364. {
  9365. return $this->targetPackage;
  9366. }
  9367. public function show($lock)
  9368. {
  9369. return self::format($this->initialPackage, $this->targetPackage, $lock);
  9370. }
  9371. public static function format(PackageInterface $initialPackage, PackageInterface $targetPackage, $lock = false)
  9372. {
  9373. $fromVersion = $initialPackage->getFullPrettyVersion();
  9374. $toVersion = $targetPackage->getFullPrettyVersion();
  9375. if ($fromVersion === $toVersion && $initialPackage->getSourceReference() !== $targetPackage->getSourceReference()) {
  9376. $fromVersion = $initialPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_SOURCE_REF);
  9377. $toVersion = $targetPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_SOURCE_REF);
  9378. } elseif ($fromVersion === $toVersion && $initialPackage->getDistReference() !== $targetPackage->getDistReference()) {
  9379. $fromVersion = $initialPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_DIST_REF);
  9380. $toVersion = $targetPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_DIST_REF);
  9381. }
  9382. $actionName = VersionParser::isUpgrade($initialPackage->getVersion(), $targetPackage->getVersion()) ? 'Upgrading' : 'Downgrading';
  9383. return $actionName.' <info>'.$initialPackage->getPrettyName().'</info> (<comment>'.$fromVersion.'</comment> => <comment>'.$toVersion.'</comment>)';
  9384. }
  9385. }
  9386. <?php
  9387. namespace Composer\DependencyResolver;
  9388. use Composer\Package\PackageInterface;
  9389. interface PolicyInterface
  9390. {
  9391. public function versionCompare(PackageInterface $a, PackageInterface $b, $operator);
  9392. public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null);
  9393. }
  9394. <?php
  9395. namespace Composer\DependencyResolver;
  9396. use Composer\Package\AliasPackage;
  9397. use Composer\Package\Version\VersionParser;
  9398. use Composer\Semver\CompilingMatcher;
  9399. use Composer\Semver\Constraint\ConstraintInterface;
  9400. use Composer\Semver\Constraint\Constraint;
  9401. use Composer\Package\PackageInterface;
  9402. class Pool implements \Countable
  9403. {
  9404. protected $packages = array();
  9405. protected $packageByName = array();
  9406. protected $versionParser;
  9407. protected $providerCache = array();
  9408. protected $unacceptableFixedOrLockedPackages;
  9409. public function __construct(array $packages = array(), array $unacceptableFixedOrLockedPackages = array())
  9410. {
  9411. $this->versionParser = new VersionParser;
  9412. $this->setPackages($packages);
  9413. $this->unacceptableFixedOrLockedPackages = $unacceptableFixedOrLockedPackages;
  9414. }
  9415. private function setPackages(array $packages)
  9416. {
  9417. $id = 1;
  9418. foreach ($packages as $package) {
  9419. $this->packages[] = $package;
  9420. $package->id = $id++;
  9421. foreach ($package->getNames() as $provided) {
  9422. $this->packageByName[$provided][] = $package;
  9423. }
  9424. }
  9425. }
  9426. public function packageById($id)
  9427. {
  9428. return $this->packages[$id - 1];
  9429. }
  9430. public function count()
  9431. {
  9432. return \count($this->packages);
  9433. }
  9434. public function whatProvides($name, ConstraintInterface $constraint = null)
  9435. {
  9436. $key = (string) $constraint;
  9437. if (isset($this->providerCache[$name][$key])) {
  9438. return $this->providerCache[$name][$key];
  9439. }
  9440. return $this->providerCache[$name][$key] = $this->computeWhatProvides($name, $constraint);
  9441. }
  9442. private function computeWhatProvides($name, $constraint)
  9443. {
  9444. if (!isset($this->packageByName[$name])) {
  9445. return array();
  9446. }
  9447. $matches = array();
  9448. foreach ($this->packageByName[$name] as $candidate) {
  9449. if ($this->match($candidate, $name, $constraint)) {
  9450. $matches[] = $candidate;
  9451. }
  9452. }
  9453. return $matches;
  9454. }
  9455. public function literalToPackage($literal)
  9456. {
  9457. $packageId = abs($literal);
  9458. return $this->packageById($packageId);
  9459. }
  9460. public function literalToPrettyString($literal, $installedMap)
  9461. {
  9462. $package = $this->literalToPackage($literal);
  9463. if (isset($installedMap[$package->id])) {
  9464. $prefix = ($literal > 0 ? 'keep' : 'remove');
  9465. } else {
  9466. $prefix = ($literal > 0 ? 'install' : 'don\'t install');
  9467. }
  9468. return $prefix.' '.$package->getPrettyString();
  9469. }
  9470. public function match($candidate, $name, ConstraintInterface $constraint = null)
  9471. {
  9472. $candidateName = $candidate->getName();
  9473. $candidateVersion = $candidate->getVersion();
  9474. if ($candidateName === $name) {
  9475. return $constraint === null || CompilingMatcher::match($constraint, Constraint::OP_EQ, $candidateVersion);
  9476. }
  9477. $provides = $candidate->getProvides();
  9478. $replaces = $candidate->getReplaces();
  9479. if (isset($replaces[0]) || isset($provides[0])) {
  9480. foreach ($provides as $link) {
  9481. if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
  9482. return true;
  9483. }
  9484. }
  9485. foreach ($replaces as $link) {
  9486. if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
  9487. return true;
  9488. }
  9489. }
  9490. return false;
  9491. }
  9492. if (isset($provides[$name]) && ($constraint === null || $constraint->matches($provides[$name]->getConstraint()))) {
  9493. return true;
  9494. }
  9495. if (isset($replaces[$name]) && ($constraint === null || $constraint->matches($replaces[$name]->getConstraint()))) {
  9496. return true;
  9497. }
  9498. return false;
  9499. }
  9500. public function isUnacceptableFixedOrLockedPackage(PackageInterface $package)
  9501. {
  9502. return \in_array($package, $this->unacceptableFixedOrLockedPackages, true);
  9503. }
  9504. public function __toString()
  9505. {
  9506. $str = "Pool:\n";
  9507. foreach ($this->packages as $package) {
  9508. $str .= '- '.str_pad($package->id, 6, ' ', STR_PAD_LEFT).': '.$package->getName()."\n";
  9509. }
  9510. return $str;
  9511. }
  9512. }
  9513. <?php
  9514. namespace Composer\DependencyResolver;
  9515. use Composer\EventDispatcher\EventDispatcher;
  9516. use Composer\IO\IOInterface;
  9517. use Composer\Package\AliasPackage;
  9518. use Composer\Package\BasePackage;
  9519. use Composer\Package\PackageInterface;
  9520. use Composer\Package\Version\StabilityFilter;
  9521. use Composer\Plugin\PluginEvents;
  9522. use Composer\Plugin\PrePoolCreateEvent;
  9523. use Composer\Repository\PlatformRepository;
  9524. use Composer\Repository\RootPackageRepository;
  9525. use Composer\Semver\CompilingMatcher;
  9526. use Composer\Semver\Constraint\Constraint;
  9527. use Composer\Semver\Constraint\ConstraintInterface;
  9528. use Composer\Semver\Constraint\MatchAllConstraint;
  9529. use Composer\Semver\Constraint\MultiConstraint;
  9530. use Composer\Semver\Intervals;
  9531. class PoolBuilder
  9532. {
  9533. private $acceptableStabilities;
  9534. private $stabilityFlags;
  9535. private $rootAliases;
  9536. private $rootReferences;
  9537. private $eventDispatcher;
  9538. private $io;
  9539. private $aliasMap = array();
  9540. private $packagesToLoad = array();
  9541. private $loadedPackages = array();
  9542. private $loadedPerRepo = array();
  9543. private $packages = array();
  9544. private $unacceptableFixedOrLockedPackages = array();
  9545. private $updateAllowList = array();
  9546. private $skippedLoad = array();
  9547. private $maxExtendedReqs = array();
  9548. private $updateAllowWarned = array();
  9549. private $indexCounter = 0;
  9550. public function __construct(array $acceptableStabilities, array $stabilityFlags, array $rootAliases, array $rootReferences, IOInterface $io, EventDispatcher $eventDispatcher = null)
  9551. {
  9552. $this->acceptableStabilities = $acceptableStabilities;
  9553. $this->stabilityFlags = $stabilityFlags;
  9554. $this->rootAliases = $rootAliases;
  9555. $this->rootReferences = $rootReferences;
  9556. $this->eventDispatcher = $eventDispatcher;
  9557. $this->io = $io;
  9558. }
  9559. public function buildPool(array $repositories, Request $request)
  9560. {
  9561. if ($request->getUpdateAllowList()) {
  9562. $this->updateAllowList = $request->getUpdateAllowList();
  9563. $this->warnAboutNonMatchingUpdateAllowList($request);
  9564. foreach ($request->getLockedRepository()->getPackages() as $lockedPackage) {
  9565. if (!$this->isUpdateAllowed($lockedPackage)) {
  9566. $request->lockPackage($lockedPackage);
  9567. $lockedName = $lockedPackage->getName();
  9568. $this->skippedLoad[$lockedName] = $lockedName;
  9569. foreach ($lockedPackage->getReplaces() as $link) {
  9570. $this->skippedLoad[$link->getTarget()] = $lockedName;
  9571. }
  9572. }
  9573. }
  9574. }
  9575. foreach ($request->getFixedOrLockedPackages() as $package) {
  9576. $this->loadedPackages[$package->getName()] = new MatchAllConstraint();
  9577. foreach ($package->getReplaces() as $link) {
  9578. $this->loadedPackages[$link->getTarget()] = new MatchAllConstraint();
  9579. }
  9580. if (
  9581. $package->getRepository() instanceof RootPackageRepository
  9582. || $package->getRepository() instanceof PlatformRepository
  9583. || StabilityFilter::isPackageAcceptable($this->acceptableStabilities, $this->stabilityFlags, $package->getNames(), $package->getStability())
  9584. ) {
  9585. $this->loadPackage($request, $package, false);
  9586. } else {
  9587. $this->unacceptableFixedOrLockedPackages[] = $package;
  9588. }
  9589. }
  9590. foreach ($request->getRequires() as $packageName => $constraint) {
  9591. if (isset($this->loadedPackages[$packageName])) {
  9592. continue;
  9593. }
  9594. $this->packagesToLoad[$packageName] = $constraint;
  9595. $this->maxExtendedReqs[$packageName] = true;
  9596. }
  9597. foreach ($this->packagesToLoad as $name => $constraint) {
  9598. if (isset($this->loadedPackages[$name])) {
  9599. unset($this->packagesToLoad[$name]);
  9600. }
  9601. }
  9602. while (!empty($this->packagesToLoad)) {
  9603. $this->loadPackagesMarkedForLoading($request, $repositories);
  9604. }
  9605. foreach ($this->packages as $i => $package) {
  9606. if (!$package instanceof AliasPackage) {
  9607. $constraint = new Constraint('==', $package->getVersion());
  9608. $aliasedPackages = array($i => $package);
  9609. if (isset($this->aliasMap[spl_object_hash($package)])) {
  9610. $aliasedPackages += $this->aliasMap[spl_object_hash($package)];
  9611. }
  9612. $found = false;
  9613. foreach ($aliasedPackages as $packageOrAlias) {
  9614. if (CompilingMatcher::match($constraint, Constraint::OP_EQ, $packageOrAlias->getVersion())) {
  9615. $found = true;
  9616. }
  9617. }
  9618. if (!$found) {
  9619. foreach ($aliasedPackages as $index => $packageOrAlias) {
  9620. unset($this->packages[$index]);
  9621. }
  9622. }
  9623. }
  9624. }
  9625. if ($this->eventDispatcher) {
  9626. $prePoolCreateEvent = new PrePoolCreateEvent(
  9627. PluginEvents::PRE_POOL_CREATE,
  9628. $repositories,
  9629. $request,
  9630. $this->acceptableStabilities,
  9631. $this->stabilityFlags,
  9632. $this->rootAliases,
  9633. $this->rootReferences,
  9634. $this->packages,
  9635. $this->unacceptableFixedOrLockedPackages
  9636. );
  9637. $this->eventDispatcher->dispatch($prePoolCreateEvent->getName(), $prePoolCreateEvent);
  9638. $this->packages = $prePoolCreateEvent->getPackages();
  9639. $this->unacceptableFixedOrLockedPackages = $prePoolCreateEvent->getUnacceptableFixedPackages();
  9640. }
  9641. $pool = new Pool($this->packages, $this->unacceptableFixedOrLockedPackages);
  9642. $this->aliasMap = array();
  9643. $this->packagesToLoad = array();
  9644. $this->loadedPackages = array();
  9645. $this->loadedPerRepo = array();
  9646. $this->packages = array();
  9647. $this->unacceptableFixedOrLockedPackages = array();
  9648. $this->maxExtendedReqs = array();
  9649. $this->skippedLoad = array();
  9650. $this->indexCounter = 0;
  9651. Intervals::clear();
  9652. return $pool;
  9653. }
  9654. private function markPackageNameForLoading(Request $request, $name, ConstraintInterface $constraint)
  9655. {
  9656. if (PlatformRepository::isPlatformPackage($name)) {
  9657. return;
  9658. }
  9659. if (isset($this->maxExtendedReqs[$name])) {
  9660. return;
  9661. }
  9662. $rootRequires = $request->getRequires();
  9663. if (isset($rootRequires[$name]) && !Intervals::isSubsetOf($constraint, $rootRequires[$name])) {
  9664. $constraint = $rootRequires[$name];
  9665. }
  9666. if (!isset($this->loadedPackages[$name])) {
  9667. if (isset($this->packagesToLoad[$name])) {
  9668. if (Intervals::isSubsetOf($constraint, $this->packagesToLoad[$name])) {
  9669. return;
  9670. }
  9671. $constraint = Intervals::compactConstraint(MultiConstraint::create(array($this->packagesToLoad[$name], $constraint), false));
  9672. }
  9673. $this->packagesToLoad[$name] = $constraint;
  9674. return;
  9675. }
  9676. if (Intervals::isSubsetOf($constraint, $this->loadedPackages[$name])) {
  9677. return;
  9678. }
  9679. $this->packagesToLoad[$name] = Intervals::compactConstraint(MultiConstraint::create(array($this->loadedPackages[$name], $constraint), false));
  9680. unset($this->loadedPackages[$name]);
  9681. }
  9682. private function loadPackagesMarkedForLoading(Request $request, $repositories)
  9683. {
  9684. foreach ($this->packagesToLoad as $name => $constraint) {
  9685. $this->loadedPackages[$name] = $constraint;
  9686. }
  9687. $packageBatch = $this->packagesToLoad;
  9688. $this->packagesToLoad = array();
  9689. foreach ($repositories as $repoIndex => $repository) {
  9690. if (empty($packageBatch)) {
  9691. break;
  9692. }
  9693. if ($repository instanceof PlatformRepository || $repository === $request->getLockedRepository()) {
  9694. continue;
  9695. }
  9696. $result = $repository->loadPackages($packageBatch, $this->acceptableStabilities, $this->stabilityFlags, isset($this->loadedPerRepo[$repoIndex]) ? $this->loadedPerRepo[$repoIndex] : array());
  9697. foreach ($result['namesFound'] as $name) {
  9698. unset($packageBatch[$name]);
  9699. }
  9700. foreach ($result['packages'] as $package) {
  9701. $this->loadedPerRepo[$repoIndex][$package->getName()][$package->getVersion()] = $package;
  9702. $this->loadPackage($request, $package);
  9703. }
  9704. }
  9705. }
  9706. private function loadPackage(Request $request, PackageInterface $package, $propagateUpdate = true)
  9707. {
  9708. $index = $this->indexCounter++;
  9709. $this->packages[$index] = $package;
  9710. if ($package instanceof AliasPackage) {
  9711. $this->aliasMap[spl_object_hash($package->getAliasOf())][$index] = $package;
  9712. }
  9713. $name = $package->getName();
  9714. if (isset($this->rootReferences[$name])) {
  9715. if (!$request->isLockedPackage($package) && !$request->isFixedPackage($package)) {
  9716. $package->setSourceDistReferences($this->rootReferences[$name]);
  9717. }
  9718. }
  9719. if ($propagateUpdate && isset($this->rootAliases[$name][$package->getVersion()])) {
  9720. $alias = $this->rootAliases[$name][$package->getVersion()];
  9721. if ($package instanceof AliasPackage) {
  9722. $basePackage = $package->getAliasOf();
  9723. } else {
  9724. $basePackage = $package;
  9725. }
  9726. $aliasPackage = new AliasPackage($basePackage, $alias['alias_normalized'], $alias['alias']);
  9727. $aliasPackage->setRootPackageAlias(true);
  9728. $newIndex = $this->indexCounter++;
  9729. $this->packages[$newIndex] = $aliasPackage;
  9730. $this->aliasMap[spl_object_hash($aliasPackage->getAliasOf())][$newIndex] = $aliasPackage;
  9731. }
  9732. foreach ($package->getRequires() as $link) {
  9733. $require = $link->getTarget();
  9734. $linkConstraint = $link->getConstraint();
  9735. if ($propagateUpdate) {
  9736. if ($request->getUpdateAllowTransitiveDependencies() && isset($this->skippedLoad[$require])) {
  9737. if ($request->getUpdateAllowTransitiveRootDependencies() || !$this->isRootRequire($request, $this->skippedLoad[$require])) {
  9738. $this->unlockPackage($request, $require);
  9739. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  9740. } elseif (!$request->getUpdateAllowTransitiveRootDependencies() && $this->isRootRequire($request, $require) && !isset($this->updateAllowWarned[$require])) {
  9741. $this->updateAllowWarned[$require] = true;
  9742. $this->io->writeError('<warning>Dependency "'.$require.'" is also a root requirement. Package has not been listed as an update argument, so keeping locked at old version. Use --with-all-dependencies (-W) to include root dependencies.</warning>');
  9743. }
  9744. } else {
  9745. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  9746. }
  9747. } else {
  9748. if (!isset($this->skippedLoad[$require])) {
  9749. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  9750. }
  9751. }
  9752. }
  9753. if ($propagateUpdate && $request->getUpdateAllowTransitiveDependencies()) {
  9754. foreach ($package->getReplaces() as $link) {
  9755. $replace = $link->getTarget();
  9756. if (isset($this->loadedPackages[$replace], $this->skippedLoad[$replace])) {
  9757. if ($request->getUpdateAllowTransitiveRootDependencies() || !$this->isRootRequire($request, $this->skippedLoad[$replace])) {
  9758. $this->unlockPackage($request, $replace);
  9759. $this->markPackageNameForLoading($request, $replace, $link->getConstraint());
  9760. } elseif (!$request->getUpdateAllowTransitiveRootDependencies() && $this->isRootRequire($request, $replace) && !isset($this->updateAllowWarned[$replace])) {
  9761. $this->updateAllowWarned[$replace] = true;
  9762. $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>');
  9763. }
  9764. }
  9765. }
  9766. }
  9767. }
  9768. private function isRootRequire(Request $request, $name)
  9769. {
  9770. $rootRequires = $request->getRequires();
  9771. return isset($rootRequires[$name]);
  9772. }
  9773. private function isUpdateAllowed(PackageInterface $package)
  9774. {
  9775. foreach ($this->updateAllowList as $pattern => $void) {
  9776. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  9777. if (preg_match($patternRegexp, $package->getName())) {
  9778. return true;
  9779. }
  9780. }
  9781. return false;
  9782. }
  9783. private function warnAboutNonMatchingUpdateAllowList(Request $request)
  9784. {
  9785. foreach ($this->updateAllowList as $pattern => $void) {
  9786. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  9787. foreach ($request->getLockedRepository()->getPackages() as $package) {
  9788. if (preg_match($patternRegexp, $package->getName())) {
  9789. continue 2;
  9790. }
  9791. }
  9792. foreach ($request->getRequires() as $packageName => $constraint) {
  9793. if (preg_match($patternRegexp, $packageName)) {
  9794. continue 2;
  9795. }
  9796. }
  9797. if (strpos($pattern, '*') !== false) {
  9798. $this->io->writeError('<warning>Pattern "' . $pattern . '" listed for update does not match any locked packages.</warning>');
  9799. } else {
  9800. $this->io->writeError('<warning>Package "' . $pattern . '" listed for update is not locked.</warning>');
  9801. }
  9802. }
  9803. }
  9804. private function unlockPackage(Request $request, $name)
  9805. {
  9806. foreach ($request->getLockedPackages() as $lockedPackage) {
  9807. if (!($lockedPackage instanceof AliasPackage) && $lockedPackage->getName() === $name) {
  9808. if (false !== $index = array_search($lockedPackage, $this->packages, true)) {
  9809. $request->unlockPackage($lockedPackage);
  9810. $this->removeLoadedPackage($request, $lockedPackage, $index);
  9811. }
  9812. }
  9813. }
  9814. if (
  9815. $this->skippedLoad[$name] !== $name
  9816. && isset($this->skippedLoad[$this->skippedLoad[$name]])
  9817. ) {
  9818. $this->unlockPackage($request, $this->skippedLoad[$name]);
  9819. }
  9820. unset($this->skippedLoad[$name], $this->loadedPackages[$name], $this->maxExtendedReqs[$name]);
  9821. }
  9822. private function removeLoadedPackage(Request $request, PackageInterface $package, $index)
  9823. {
  9824. unset($this->packages[$index]);
  9825. if (isset($this->aliasMap[spl_object_hash($package)])) {
  9826. foreach ($this->aliasMap[spl_object_hash($package)] as $aliasIndex => $aliasPackage) {
  9827. $request->unlockPackage($aliasPackage);
  9828. unset($this->packages[$aliasIndex]);
  9829. }
  9830. unset($this->aliasMap[spl_object_hash($package)]);
  9831. }
  9832. }
  9833. }
  9834. <?php
  9835. namespace Composer\DependencyResolver;
  9836. use Composer\Package\CompletePackageInterface;
  9837. use Composer\Package\AliasPackage;
  9838. use Composer\Repository\RepositorySet;
  9839. use Composer\Repository\LockArrayRepository;
  9840. use Composer\Semver\Constraint\Constraint;
  9841. use Composer\Package\Version\VersionParser;
  9842. class Problem
  9843. {
  9844. protected $reasonSeen;
  9845. protected $reasons = array();
  9846. protected $section = 0;
  9847. public function addRule(Rule $rule)
  9848. {
  9849. $this->addReason(spl_object_hash($rule), $rule);
  9850. }
  9851. public function getReasons()
  9852. {
  9853. return $this->reasons;
  9854. }
  9855. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
  9856. {
  9857. $reasons = call_user_func_array('array_merge', array_reverse($this->reasons));
  9858. if (count($reasons) === 1) {
  9859. reset($reasons);
  9860. $rule = current($reasons);
  9861. if (!in_array($rule->getReason(), array(Rule::RULE_ROOT_REQUIRE, Rule::RULE_FIXED), true)) {
  9862. throw new \LogicException("Single reason problems must contain a request rule.");
  9863. }
  9864. $reasonData = $rule->getReasonData();
  9865. $packageName = $reasonData['packageName'];
  9866. $constraint = $reasonData['constraint'];
  9867. if (isset($constraint)) {
  9868. $packages = $pool->whatProvides($packageName, $constraint);
  9869. } else {
  9870. $packages = array();
  9871. }
  9872. if (empty($packages)) {
  9873. return "\n ".implode(self::getMissingPackageReason($repositorySet, $request, $pool, $isVerbose, $packageName, $constraint));
  9874. }
  9875. }
  9876. return self::formatDeduplicatedRules($reasons, ' ', $repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool);
  9877. }
  9878. public static function formatDeduplicatedRules($rules, $indent, RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
  9879. {
  9880. $messages = array();
  9881. $templates = array();
  9882. $parser = new VersionParser;
  9883. $deduplicatableRuleTypes = array(Rule::RULE_PACKAGE_REQUIRES, Rule::RULE_PACKAGE_CONFLICT);
  9884. foreach ($rules as $rule) {
  9885. $message = $rule->getPrettyString($repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool);
  9886. if (in_array($rule->getReason(), $deduplicatableRuleTypes, true) && preg_match('{^(?P<package>\S+) (?P<version>\S+) (?P<type>requires|conflicts)}', $message, $m)) {
  9887. $template = preg_replace('{^\S+ \S+ }', '%s%s ', $message);
  9888. $messages[] = $template;
  9889. $templates[$template][$m[1]][$parser->normalize($m[2])] = $m[2];
  9890. } elseif ($message !== '') {
  9891. $messages[] = $message;
  9892. }
  9893. }
  9894. $result = array();
  9895. foreach (array_unique($messages) as $message) {
  9896. if (isset($templates[$message])) {
  9897. foreach ($templates[$message] as $package => $versions) {
  9898. uksort($versions, 'version_compare');
  9899. if (!$isVerbose) {
  9900. $versions = self::condenseVersionList($versions, 1);
  9901. }
  9902. if (count($versions) > 1) {
  9903. $message = preg_replace('{^(%s%s (?:require|conflict))s}', '$1', $message);
  9904. $result[] = sprintf($message, $package, '['.implode(', ', $versions).']');
  9905. } else {
  9906. $result[] = sprintf($message, $package, ' '.reset($versions));
  9907. }
  9908. }
  9909. } else {
  9910. $result[] = $message;
  9911. }
  9912. }
  9913. return "\n$indent- ".implode("\n$indent- ", $result);
  9914. }
  9915. public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool)
  9916. {
  9917. foreach ($this->reasons as $sectionRules) {
  9918. foreach ($sectionRules as $rule) {
  9919. if ($rule->isCausedByLock($repositorySet, $request, $pool)) {
  9920. return true;
  9921. }
  9922. }
  9923. }
  9924. }
  9925. protected function addReason($id, Rule $reason)
  9926. {
  9927. if (!isset($this->reasonSeen[$id])) {
  9928. $this->reasonSeen[$id] = true;
  9929. $this->reasons[$this->section][] = $reason;
  9930. }
  9931. }
  9932. public function nextSection()
  9933. {
  9934. $this->section++;
  9935. }
  9936. public static function getMissingPackageReason(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, $packageName, $constraint = null)
  9937. {
  9938. if ($packageName === 'php' || $packageName === 'php-64bit' || $packageName === 'hhvm') {
  9939. $version = phpversion();
  9940. $available = $pool->whatProvides($packageName);
  9941. if (count($available)) {
  9942. $firstAvailable = reset($available);
  9943. $version = $firstAvailable->getPrettyVersion();
  9944. $extra = $firstAvailable->getExtra();
  9945. if ($firstAvailable instanceof CompletePackageInterface && isset($extra['config.platform']) && $extra['config.platform'] === true) {
  9946. $version .= '; ' . str_replace('Package ', '', $firstAvailable->getDescription());
  9947. }
  9948. }
  9949. $msg = "- Root composer.json requires ".$packageName.self::constraintToText($constraint).' but ';
  9950. if (defined('HHVM_VERSION') || (count($available) && $packageName === 'hhvm')) {
  9951. return array($msg, 'your HHVM version does not satisfy that requirement.');
  9952. }
  9953. if ($packageName === 'hhvm') {
  9954. return array($msg, 'you are running this with PHP and not HHVM.');
  9955. }
  9956. return array($msg, 'your '.$packageName.' version ('. $version .') does not satisfy that requirement.');
  9957. }
  9958. if (0 === stripos($packageName, 'ext-')) {
  9959. if (false !== strpos($packageName, ' ')) {
  9960. return array('- ', "PHP extension ".$packageName.' should be required as '.str_replace(' ', '-', $packageName).'.');
  9961. }
  9962. $ext = substr($packageName, 4);
  9963. $error = extension_loaded($ext) ? 'it has the wrong version ('.(phpversion($ext) ?: '0').') installed' : 'it is missing from your system';
  9964. return array("- Root composer.json requires PHP extension ".$packageName.self::constraintToText($constraint).' but ', $error.'. Install or enable PHP\'s '.$ext.' extension.');
  9965. }
  9966. if (0 === stripos($packageName, 'lib-')) {
  9967. if (strtolower($packageName) === 'lib-icu') {
  9968. $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.';
  9969. return array("- Root composer.json requires linked library ".$packageName.self::constraintToText($constraint).' but ', $error);
  9970. }
  9971. 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.');
  9972. }
  9973. $lockedPackage = null;
  9974. foreach ($request->getLockedPackages() as $package) {
  9975. if ($package->getName() === $packageName) {
  9976. $lockedPackage = $package;
  9977. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  9978. 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.');
  9979. }
  9980. break;
  9981. }
  9982. }
  9983. if ($packages = $repositorySet->findPackages($packageName, $constraint)) {
  9984. $rootReqs = $repositorySet->getRootRequires();
  9985. if (isset($rootReqs[$packageName])) {
  9986. $filtered = array_filter($packages, function ($p) use ($rootReqs, $packageName) {
  9987. return $rootReqs[$packageName]->matches(new Constraint('==', $p->getVersion()));
  9988. });
  9989. if (0 === count($filtered)) {
  9990. 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().').');
  9991. }
  9992. }
  9993. if ($lockedPackage) {
  9994. $fixedConstraint = new Constraint('==', $lockedPackage->getVersion());
  9995. $filtered = array_filter($packages, function ($p) use ($fixedConstraint) {
  9996. return $fixedConstraint->matches(new Constraint('==', $p->getVersion()));
  9997. });
  9998. if (0 === count($filtered)) {
  9999. 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.');
  10000. }
  10001. }
  10002. $nonLockedPackages = array_filter($packages, function ($p) {
  10003. return !$p->getRepository() instanceof LockArrayRepository;
  10004. });
  10005. if (!$nonLockedPackages) {
  10006. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose).' in lock file but not in remote repositories, make sure you avoid updating this package to keep the one from lock file.');
  10007. }
  10008. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose).' but '.(self::hasMultipleNames($packages) ? 'these conflict' : 'it conflicts').' with another require.');
  10009. }
  10010. if ($packages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES)) {
  10011. if ($allReposPackages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  10012. return self::computeCheckForLowerPrioRepo($isVerbose, $packageName, $constraint, $packages, $allReposPackages, 'minimum-stability');
  10013. }
  10014. 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.');
  10015. }
  10016. if ($packages = $repositorySet->findPackages($packageName, null, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES)) {
  10017. if ($allReposPackages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  10018. return self::computeCheckForLowerPrioRepo($isVerbose, $packageName, $constraint, $packages, $allReposPackages, 'constraint');
  10019. }
  10020. 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.');
  10021. }
  10022. if (!preg_match('{^[A-Za-z0-9_./-]+$}', $packageName)) {
  10023. $illegalChars = preg_replace('{[A-Za-z0-9_./-]+}', '', $packageName);
  10024. 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.');
  10025. }
  10026. if ($providers = $repositorySet->getProviders($packageName)) {
  10027. $maxProviders = 20;
  10028. $providersStr = implode(array_map(function ($p) {
  10029. $description = $p['description'] ? ' '.substr($p['description'], 0, 100) : '';
  10030. return " - ${p['name']}".$description."\n";
  10031. }, count($providers) > $maxProviders+1 ? array_slice($providers, 0, $maxProviders) : $providers));
  10032. if (count($providers) > $maxProviders+1) {
  10033. $providersStr .= ' ... and '.(count($providers)-$maxProviders).' more.'."\n";
  10034. }
  10035. 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.");
  10036. }
  10037. return array("- Root composer.json requires $packageName, it ", "could not be found in any version, there may be a typo in the package name.");
  10038. }
  10039. public static function getPackageList(array $packages, $isVerbose)
  10040. {
  10041. $prepared = array();
  10042. $hasDefaultBranch = array();
  10043. foreach ($packages as $package) {
  10044. $prepared[$package->getName()]['name'] = $package->getPrettyName();
  10045. $prepared[$package->getName()]['versions'][$package->getVersion()] = $package->getPrettyVersion().($package instanceof AliasPackage ? ' (alias of '.$package->getAliasOf()->getPrettyVersion().')' : '');
  10046. if ($package->isDefaultBranch()) {
  10047. $hasDefaultBranch[$package->getName()] = true;
  10048. }
  10049. }
  10050. foreach ($prepared as $name => $package) {
  10051. if (isset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS], $hasDefaultBranch[$name])) {
  10052. unset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS]);
  10053. }
  10054. uksort($package['versions'], 'version_compare');
  10055. if (!$isVerbose) {
  10056. $package['versions'] = self::condenseVersionList($package['versions'], 4);
  10057. }
  10058. $prepared[$name] = $package['name'].'['.implode(', ', $package['versions']).']';
  10059. }
  10060. return implode(', ', $prepared);
  10061. }
  10062. private static function condenseVersionList(array $versions, $max)
  10063. {
  10064. if (count($versions) <= $max) {
  10065. return $versions;
  10066. }
  10067. $filtered = array();
  10068. $byMajor = array();
  10069. foreach ($versions as $version => $pretty) {
  10070. $byMajor[preg_replace('{^(\d+)\..*}', '$1', $version)][] = $pretty;
  10071. }
  10072. foreach ($byMajor as $versionsForMajor) {
  10073. if (count($versionsForMajor) > $max) {
  10074. $filtered[] = $versionsForMajor[0];
  10075. $filtered[] = '...';
  10076. $filtered[] = $versionsForMajor[count($versionsForMajor) - 1];
  10077. } else {
  10078. $filtered = array_merge($filtered, $versionsForMajor);
  10079. }
  10080. }
  10081. return $filtered;
  10082. }
  10083. private static function hasMultipleNames(array $packages)
  10084. {
  10085. $name = null;
  10086. foreach ($packages as $package) {
  10087. if ($name === null || $name === $package->getName()) {
  10088. $name = $package->getName();
  10089. } else {
  10090. return true;
  10091. }
  10092. }
  10093. return false;
  10094. }
  10095. private static function computeCheckForLowerPrioRepo($isVerbose, $packageName, $constraint, array $higherRepoPackages, array $allReposPackages, $reason)
  10096. {
  10097. $nextRepoPackages = array();
  10098. $nextRepo = null;
  10099. foreach ($allReposPackages as $package) {
  10100. if ($nextRepo === null || $nextRepo === $package->getRepository()) {
  10101. $nextRepoPackages[] = $package;
  10102. $nextRepo = $package->getRepository();
  10103. } else {
  10104. break;
  10105. }
  10106. }
  10107. 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.');
  10108. }
  10109. protected static function constraintToText($constraint)
  10110. {
  10111. return $constraint ? ' '.$constraint->getPrettyString() : '';
  10112. }
  10113. }
  10114. <?php
  10115. namespace Composer\DependencyResolver;
  10116. use Composer\Package\Package;
  10117. use Composer\Package\PackageInterface;
  10118. use Composer\Package\RootAliasPackage;
  10119. use Composer\Repository\LockArrayRepository;
  10120. use Composer\Semver\Constraint\ConstraintInterface;
  10121. use Composer\Semver\Constraint\MatchAllConstraint;
  10122. class Request
  10123. {
  10124. const UPDATE_ONLY_LISTED = 0;
  10125. const UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE = 1;
  10126. const UPDATE_LISTED_WITH_TRANSITIVE_DEPS = 2;
  10127. protected $lockedRepository;
  10128. protected $requires = array();
  10129. protected $fixedPackages = array();
  10130. protected $lockedPackages = array();
  10131. protected $fixedLockedPackages = array();
  10132. protected $updateAllowList = array();
  10133. protected $updateAllowTransitiveDependencies = false;
  10134. public function __construct(LockArrayRepository $lockedRepository = null)
  10135. {
  10136. $this->lockedRepository = $lockedRepository;
  10137. }
  10138. public function requireName($packageName, ConstraintInterface $constraint = null)
  10139. {
  10140. $packageName = strtolower($packageName);
  10141. if ($constraint === null) {
  10142. $constraint = new MatchAllConstraint();
  10143. }
  10144. if (isset($this->requires[$packageName])) {
  10145. 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');
  10146. }
  10147. $this->requires[$packageName] = $constraint;
  10148. }
  10149. public function fixPackage(PackageInterface $package)
  10150. {
  10151. $this->fixedPackages[spl_object_hash($package)] = $package;
  10152. }
  10153. public function lockPackage(PackageInterface $package)
  10154. {
  10155. $this->lockedPackages[spl_object_hash($package)] = $package;
  10156. }
  10157. public function fixLockedPackage(PackageInterface $package)
  10158. {
  10159. $this->fixedPackages[spl_object_hash($package)] = $package;
  10160. $this->fixedLockedPackages[spl_object_hash($package)] = $package;
  10161. }
  10162. public function unlockPackage(PackageInterface $package)
  10163. {
  10164. unset($this->lockedPackages[spl_object_hash($package)]);
  10165. }
  10166. public function setUpdateAllowList($updateAllowList, $updateAllowTransitiveDependencies)
  10167. {
  10168. $this->updateAllowList = $updateAllowList;
  10169. $this->updateAllowTransitiveDependencies = $updateAllowTransitiveDependencies;
  10170. }
  10171. public function getUpdateAllowList()
  10172. {
  10173. return $this->updateAllowList;
  10174. }
  10175. public function getUpdateAllowTransitiveDependencies()
  10176. {
  10177. return $this->updateAllowTransitiveDependencies !== self::UPDATE_ONLY_LISTED;
  10178. }
  10179. public function getUpdateAllowTransitiveRootDependencies()
  10180. {
  10181. return $this->updateAllowTransitiveDependencies === self::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  10182. }
  10183. public function getRequires()
  10184. {
  10185. return $this->requires;
  10186. }
  10187. public function getFixedPackages()
  10188. {
  10189. return $this->fixedPackages;
  10190. }
  10191. public function isFixedPackage(PackageInterface $package)
  10192. {
  10193. return isset($this->fixedPackages[spl_object_hash($package)]);
  10194. }
  10195. public function getLockedPackages()
  10196. {
  10197. return $this->lockedPackages;
  10198. }
  10199. public function isLockedPackage(PackageInterface $package)
  10200. {
  10201. return isset($this->lockedPackages[spl_object_hash($package)]) || isset($this->fixedLockedPackages[spl_object_hash($package)]);
  10202. }
  10203. public function getFixedOrLockedPackages()
  10204. {
  10205. return array_merge($this->fixedPackages, $this->lockedPackages);
  10206. }
  10207. public function getPresentMap($packageIds = false)
  10208. {
  10209. $presentMap = array();
  10210. if ($this->lockedRepository) {
  10211. foreach ($this->lockedRepository->getPackages() as $package) {
  10212. $presentMap[$packageIds ? $package->id : spl_object_hash($package)] = $package;
  10213. }
  10214. }
  10215. foreach ($this->fixedPackages as $package) {
  10216. $presentMap[$packageIds ? $package->id : spl_object_hash($package)] = $package;
  10217. }
  10218. return $presentMap;
  10219. }
  10220. public function getFixedPackagesMap()
  10221. {
  10222. $fixedPackagesMap = array();
  10223. foreach ($this->fixedPackages as $package) {
  10224. $fixedPackagesMap[$package->id] = $package;
  10225. }
  10226. return $fixedPackagesMap;
  10227. }
  10228. public function getLockedRepository()
  10229. {
  10230. return $this->lockedRepository;
  10231. }
  10232. }
  10233. <?php
  10234. namespace Composer\DependencyResolver;
  10235. use Composer\Package\CompletePackage;
  10236. use Composer\Package\Link;
  10237. use Composer\Package\PackageInterface;
  10238. use Composer\Package\AliasPackage;
  10239. use Composer\Repository\RepositorySet;
  10240. use Composer\Repository\PlatformRepository;
  10241. use Composer\Package\Version\VersionParser;
  10242. use Composer\Semver\Constraint\Constraint;
  10243. abstract class Rule
  10244. {
  10245. const RULE_ROOT_REQUIRE = 2;
  10246. const RULE_FIXED = 3;
  10247. const RULE_PACKAGE_CONFLICT = 6;
  10248. const RULE_PACKAGE_REQUIRES = 7;
  10249. const RULE_PACKAGE_SAME_NAME = 10;
  10250. const RULE_LEARNED = 12;
  10251. const RULE_PACKAGE_ALIAS = 13;
  10252. const BITFIELD_TYPE = 0;
  10253. const BITFIELD_REASON = 8;
  10254. const BITFIELD_DISABLED = 16;
  10255. protected $bitfield;
  10256. protected $request;
  10257. protected $reasonData;
  10258. public function __construct($reason, $reasonData)
  10259. {
  10260. $this->reasonData = $reasonData;
  10261. $this->bitfield = (0 << self::BITFIELD_DISABLED) |
  10262. ($reason << self::BITFIELD_REASON) |
  10263. (255 << self::BITFIELD_TYPE);
  10264. }
  10265. abstract public function getLiterals();
  10266. abstract public function getHash();
  10267. abstract public function equals(Rule $rule);
  10268. public function getReason()
  10269. {
  10270. return ($this->bitfield & (255 << self::BITFIELD_REASON)) >> self::BITFIELD_REASON;
  10271. }
  10272. public function getReasonData()
  10273. {
  10274. return $this->reasonData;
  10275. }
  10276. public function getRequiredPackage()
  10277. {
  10278. $reason = $this->getReason();
  10279. if ($reason === self::RULE_ROOT_REQUIRE) {
  10280. return $this->reasonData['packageName'];
  10281. }
  10282. if ($reason === self::RULE_FIXED) {
  10283. return $this->reasonData['package']->getName();
  10284. }
  10285. if ($reason === self::RULE_PACKAGE_REQUIRES) {
  10286. return $this->reasonData->getTarget();
  10287. }
  10288. }
  10289. public function setType($type)
  10290. {
  10291. $this->bitfield = ($this->bitfield & ~(255 << self::BITFIELD_TYPE)) | ((255 & $type) << self::BITFIELD_TYPE);
  10292. }
  10293. public function getType()
  10294. {
  10295. return ($this->bitfield & (255 << self::BITFIELD_TYPE)) >> self::BITFIELD_TYPE;
  10296. }
  10297. public function disable()
  10298. {
  10299. $this->bitfield = ($this->bitfield & ~(255 << self::BITFIELD_DISABLED)) | (1 << self::BITFIELD_DISABLED);
  10300. }
  10301. public function enable()
  10302. {
  10303. $this->bitfield &= ~(255 << self::BITFIELD_DISABLED);
  10304. }
  10305. public function isDisabled()
  10306. {
  10307. return (bool) (($this->bitfield & (255 << self::BITFIELD_DISABLED)) >> self::BITFIELD_DISABLED);
  10308. }
  10309. public function isEnabled()
  10310. {
  10311. return !(($this->bitfield & (255 << self::BITFIELD_DISABLED)) >> self::BITFIELD_DISABLED);
  10312. }
  10313. abstract public function isAssertion();
  10314. public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool)
  10315. {
  10316. if ($this->getReason() === self::RULE_PACKAGE_REQUIRES) {
  10317. if (PlatformRepository::isPlatformPackage($this->reasonData->getTarget())) {
  10318. return false;
  10319. }
  10320. if ($request->getLockedRepository()) {
  10321. foreach ($request->getLockedRepository()->getPackages() as $package) {
  10322. if ($package->getName() === $this->reasonData->getTarget()) {
  10323. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  10324. return true;
  10325. }
  10326. if (!$this->reasonData->getConstraint()->matches(new Constraint('=', $package->getVersion()))) {
  10327. return true;
  10328. }
  10329. if (!$request->isLockedPackage($package)) {
  10330. return true;
  10331. }
  10332. break;
  10333. }
  10334. }
  10335. }
  10336. }
  10337. if ($this->getReason() === self::RULE_ROOT_REQUIRE) {
  10338. if (PlatformRepository::isPlatformPackage($this->reasonData['packageName'])) {
  10339. return false;
  10340. }
  10341. if ($request->getLockedRepository()) {
  10342. foreach ($request->getLockedRepository()->getPackages() as $package) {
  10343. if ($package->getName() === $this->reasonData['packageName']) {
  10344. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  10345. return true;
  10346. }
  10347. if (!$this->reasonData['constraint']->matches(new Constraint('=', $package->getVersion()))) {
  10348. return true;
  10349. }
  10350. break;
  10351. }
  10352. }
  10353. }
  10354. }
  10355. return false;
  10356. }
  10357. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
  10358. {
  10359. $literals = $this->getLiterals();
  10360. switch ($this->getReason()) {
  10361. case self::RULE_ROOT_REQUIRE:
  10362. $packageName = $this->reasonData['packageName'];
  10363. $constraint = $this->reasonData['constraint'];
  10364. $packages = $pool->whatProvides($packageName, $constraint);
  10365. if (!$packages) {
  10366. return 'No package found to satisfy root composer.json require '.$packageName.($constraint ? ' '.$constraint->getPrettyString() : '');
  10367. }
  10368. $packagesNonAlias = array_values(array_filter($packages, function ($p) {
  10369. return !($p instanceof AliasPackage);
  10370. }));
  10371. if (count($packagesNonAlias) === 1) {
  10372. $package = $packagesNonAlias[0];
  10373. if ($request->isLockedPackage($package)) {
  10374. return $package->getPrettyName().' is locked to version '.$package->getPrettyVersion()." and an update of this package was not requested.";
  10375. }
  10376. }
  10377. return 'Root composer.json requires '.$packageName.($constraint ? ' '.$constraint->getPrettyString() : '').' -> satisfiable by '.$this->formatPackagesUnique($pool, $packages, $isVerbose).'.';
  10378. case self::RULE_FIXED:
  10379. $package = $this->deduplicateDefaultBranchAlias($this->reasonData['package']);
  10380. if ($request->isLockedPackage($package)) {
  10381. return $package->getPrettyName().' is locked to version '.$package->getPrettyVersion().' and an update of this package was not requested.';
  10382. }
  10383. return $package->getPrettyName().' is present at version '.$package->getPrettyVersion() . ' and cannot be modified by Composer';
  10384. case self::RULE_PACKAGE_CONFLICT:
  10385. $package1 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[0]));
  10386. $package2 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
  10387. return $package2->getPrettyString().' conflicts with '.$package1->getPrettyString().'.';
  10388. case self::RULE_PACKAGE_REQUIRES:
  10389. $sourceLiteral = array_shift($literals);
  10390. $sourcePackage = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($sourceLiteral));
  10391. $requires = array();
  10392. foreach ($literals as $literal) {
  10393. $requires[] = $pool->literalToPackage($literal);
  10394. }
  10395. $text = $this->reasonData->getPrettyString($sourcePackage);
  10396. if ($requires) {
  10397. $text .= ' -> satisfiable by ' . $this->formatPackagesUnique($pool, $requires, $isVerbose) . '.';
  10398. } else {
  10399. $targetName = $this->reasonData->getTarget();
  10400. $reason = Problem::getMissingPackageReason($repositorySet, $request, $pool, $isVerbose, $targetName, $this->reasonData->getConstraint());
  10401. return $text . ' -> ' . $reason[1];
  10402. }
  10403. return $text;
  10404. case self::RULE_PACKAGE_SAME_NAME:
  10405. $packageNames = array();
  10406. foreach ($literals as $literal) {
  10407. $package = $pool->literalToPackage($literal);
  10408. $packageNames[$package->getName()] = true;
  10409. }
  10410. $replacedName = $this->reasonData;
  10411. if (count($packageNames) > 1) {
  10412. $reason = null;
  10413. if (!isset($packageNames[$replacedName])) {
  10414. $reason = 'They '.(count($literals) == 2 ? 'both' : 'all').' replace '.$replacedName.' and thus cannot coexist.';
  10415. } else {
  10416. $replacerNames = $packageNames;
  10417. unset($replacerNames[$replacedName]);
  10418. $replacerNames = array_keys($replacerNames);
  10419. if (count($replacerNames) == 1) {
  10420. $reason = $replacerNames[0] . ' replaces ';
  10421. } else {
  10422. $reason = '['.implode(', ', $replacerNames).'] replace ';
  10423. }
  10424. $reason .= $replacedName.' and thus cannot coexist with it.';
  10425. }
  10426. $installedPackages = array();
  10427. $removablePackages = array();
  10428. foreach ($literals as $literal) {
  10429. if (isset($installedMap[abs($literal)])) {
  10430. $installedPackages[] = $pool->literalToPackage($literal);
  10431. } else {
  10432. $removablePackages[] = $pool->literalToPackage($literal);
  10433. }
  10434. }
  10435. if ($installedPackages && $removablePackages) {
  10436. return $this->formatPackagesUnique($pool, $removablePackages, $isVerbose).' cannot be installed as that would require removing '.$this->formatPackagesUnique($pool, $installedPackages, $isVerbose).'. '.$reason;
  10437. }
  10438. return 'Only one of these can be installed: '.$this->formatPackagesUnique($pool, $literals, $isVerbose).'. '.$reason;
  10439. }
  10440. return 'You can only install one version of a package, so only one of these can be installed: ' . $this->formatPackagesUnique($pool, $literals, $isVerbose) . '.';
  10441. case self::RULE_LEARNED:
  10442. if (isset($learnedPool[$this->reasonData])) {
  10443. $learnedString = ', learned rules:' . Problem::formatDeduplicatedRules($learnedPool[$this->reasonData], ' ', $repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool);
  10444. } else {
  10445. $learnedString = ' (reasoning unavailable)';
  10446. }
  10447. if (count($literals) === 1) {
  10448. $ruleText = $pool->literalToPrettyString($literals[0], $installedMap);
  10449. } else {
  10450. $groups = array();
  10451. foreach ($literals as $literal) {
  10452. $package = $pool->literalToPackage($literal);
  10453. if (isset($installedMap[$package->id])) {
  10454. $group = $literal > 0 ? 'keep' : 'remove';
  10455. } else {
  10456. $group = $literal > 0 ? 'install' : 'don\'t install';
  10457. }
  10458. $groups[$group][] = $this->deduplicateDefaultBranchAlias($package);
  10459. }
  10460. $ruleTexts = array();
  10461. foreach ($groups as $group => $packages) {
  10462. $ruleTexts[] = $group . (count($packages) > 1 ? ' one of' : '').' ' . $this->formatPackagesUnique($pool, $packages, $isVerbose);
  10463. }
  10464. $ruleText = implode(' | ', $ruleTexts);
  10465. }
  10466. return 'Conclusion: '.$ruleText.$learnedString;
  10467. case self::RULE_PACKAGE_ALIAS:
  10468. $aliasPackage = $pool->literalToPackage($literals[0]);
  10469. if ($aliasPackage->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  10470. return '';
  10471. }
  10472. $package = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
  10473. return $aliasPackage->getPrettyString() .' is an alias of '.$package->getPrettyString().' and thus requires it to be installed too.';
  10474. default:
  10475. $ruleText = '';
  10476. foreach ($literals as $i => $literal) {
  10477. if ($i != 0) {
  10478. $ruleText .= '|';
  10479. }
  10480. $ruleText .= $pool->literalToPrettyString($literal, $installedMap);
  10481. }
  10482. return '('.$ruleText.')';
  10483. }
  10484. }
  10485. protected function formatPackagesUnique($pool, array $packages, $isVerbose)
  10486. {
  10487. foreach ($packages as $index => $package) {
  10488. if (!\is_object($package)) {
  10489. $packages[$index] = $pool->literalToPackage($package);
  10490. }
  10491. }
  10492. return Problem::getPackageList($packages, $isVerbose);
  10493. }
  10494. private function deduplicateDefaultBranchAlias(PackageInterface $package)
  10495. {
  10496. if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  10497. $package = $package->getAliasOf();
  10498. }
  10499. return $package;
  10500. }
  10501. }
  10502. <?php
  10503. namespace Composer\DependencyResolver;
  10504. use Composer\Package\PackageInterface;
  10505. use Composer\Package\Link;
  10506. class Rule2Literals extends Rule
  10507. {
  10508. protected $literal1;
  10509. protected $literal2;
  10510. public function __construct($literal1, $literal2, $reason, $reasonData)
  10511. {
  10512. parent::__construct($reason, $reasonData);
  10513. if ($literal1 < $literal2) {
  10514. $this->literal1 = $literal1;
  10515. $this->literal2 = $literal2;
  10516. } else {
  10517. $this->literal1 = $literal2;
  10518. $this->literal2 = $literal1;
  10519. }
  10520. }
  10521. public function getLiterals()
  10522. {
  10523. return array($this->literal1, $this->literal2);
  10524. }
  10525. public function getHash()
  10526. {
  10527. return $this->literal1.','.$this->literal2;
  10528. }
  10529. public function equals(Rule $rule)
  10530. {
  10531. if ($rule instanceof self) {
  10532. if ($this->literal1 !== $rule->literal1) {
  10533. return false;
  10534. }
  10535. if ($this->literal2 !== $rule->literal2) {
  10536. return false;
  10537. }
  10538. return true;
  10539. }
  10540. $literals = $rule->getLiterals();
  10541. if (2 != \count($literals)) {
  10542. return false;
  10543. }
  10544. if ($this->literal1 !== $literals[0]) {
  10545. return false;
  10546. }
  10547. if ($this->literal2 !== $literals[1]) {
  10548. return false;
  10549. }
  10550. return true;
  10551. }
  10552. public function isAssertion()
  10553. {
  10554. return false;
  10555. }
  10556. public function __toString()
  10557. {
  10558. $result = $this->isDisabled() ? 'disabled(' : '(';
  10559. $result .= $this->literal1 . '|' . $this->literal2 . ')';
  10560. return $result;
  10561. }
  10562. }
  10563. <?php
  10564. namespace Composer\DependencyResolver;
  10565. use Composer\Repository\RepositorySet;
  10566. class RuleSet implements \IteratorAggregate, \Countable
  10567. {
  10568. const TYPE_PACKAGE = 0;
  10569. const TYPE_REQUEST = 1;
  10570. const TYPE_LEARNED = 4;
  10571. public $ruleById;
  10572. protected static $types = array(
  10573. 255 => 'UNKNOWN',
  10574. self::TYPE_PACKAGE => 'PACKAGE',
  10575. self::TYPE_REQUEST => 'REQUEST',
  10576. self::TYPE_LEARNED => 'LEARNED',
  10577. );
  10578. protected $rules;
  10579. protected $nextRuleId;
  10580. protected $rulesByHash;
  10581. public function __construct()
  10582. {
  10583. $this->nextRuleId = 0;
  10584. foreach ($this->getTypes() as $type) {
  10585. $this->rules[$type] = array();
  10586. }
  10587. $this->rulesByHash = array();
  10588. }
  10589. public function add(Rule $rule, $type)
  10590. {
  10591. if (!isset(self::$types[$type])) {
  10592. throw new \OutOfBoundsException('Unknown rule type: ' . $type);
  10593. }
  10594. $hash = $rule->getHash();
  10595. if (isset($this->rulesByHash[$hash])) {
  10596. $potentialDuplicates = $this->rulesByHash[$hash];
  10597. if (\is_array($potentialDuplicates)) {
  10598. foreach ($potentialDuplicates as $potentialDuplicate) {
  10599. if ($rule->equals($potentialDuplicate)) {
  10600. return;
  10601. }
  10602. }
  10603. } else {
  10604. if ($rule->equals($potentialDuplicates)) {
  10605. return;
  10606. }
  10607. }
  10608. }
  10609. if (!isset($this->rules[$type])) {
  10610. $this->rules[$type] = array();
  10611. }
  10612. $this->rules[$type][] = $rule;
  10613. $this->ruleById[$this->nextRuleId] = $rule;
  10614. $rule->setType($type);
  10615. $this->nextRuleId++;
  10616. if (!isset($this->rulesByHash[$hash])) {
  10617. $this->rulesByHash[$hash] = $rule;
  10618. } elseif (\is_array($this->rulesByHash[$hash])) {
  10619. $this->rulesByHash[$hash][] = $rule;
  10620. } else {
  10621. $originalRule = $this->rulesByHash[$hash];
  10622. $this->rulesByHash[$hash] = array($originalRule, $rule);
  10623. }
  10624. }
  10625. public function count()
  10626. {
  10627. return $this->nextRuleId;
  10628. }
  10629. public function ruleById($id)
  10630. {
  10631. return $this->ruleById[$id];
  10632. }
  10633. public function getRules()
  10634. {
  10635. return $this->rules;
  10636. }
  10637. public function getIterator()
  10638. {
  10639. return new RuleSetIterator($this->getRules());
  10640. }
  10641. public function getIteratorFor($types)
  10642. {
  10643. if (!\is_array($types)) {
  10644. $types = array($types);
  10645. }
  10646. $allRules = $this->getRules();
  10647. $rules = array();
  10648. foreach ($types as $type) {
  10649. $rules[$type] = $allRules[$type];
  10650. }
  10651. return new RuleSetIterator($rules);
  10652. }
  10653. public function getIteratorWithout($types)
  10654. {
  10655. if (!\is_array($types)) {
  10656. $types = array($types);
  10657. }
  10658. $rules = $this->getRules();
  10659. foreach ($types as $type) {
  10660. unset($rules[$type]);
  10661. }
  10662. return new RuleSetIterator($rules);
  10663. }
  10664. public function getTypes()
  10665. {
  10666. $types = self::$types;
  10667. unset($types[255]);
  10668. return array_keys($types);
  10669. }
  10670. public function getPrettyString(RepositorySet $repositorySet = null, Request $request = null, Pool $pool = null, $isVerbose = false)
  10671. {
  10672. $string = "\n";
  10673. foreach ($this->rules as $type => $rules) {
  10674. $string .= str_pad(self::$types[$type], 8, ' ') . ": ";
  10675. foreach ($rules as $rule) {
  10676. $string .= ($repositorySet && $request && $pool ? $rule->getPrettyString($repositorySet, $request, $pool, $isVerbose) : $rule)."\n";
  10677. }
  10678. $string .= "\n\n";
  10679. }
  10680. return $string;
  10681. }
  10682. public function __toString()
  10683. {
  10684. return $this->getPrettyString();
  10685. }
  10686. }
  10687. <?php
  10688. namespace Composer\DependencyResolver;
  10689. use Composer\Package\LinkConstraint\VersionConstraint;
  10690. use Composer\Package\PackageInterface;
  10691. use Composer\Package\AliasPackage;
  10692. use Composer\Repository\PlatformRepository;
  10693. use Composer\Semver\Constraint\Constraint;
  10694. class RuleSetGenerator
  10695. {
  10696. protected $policy;
  10697. protected $pool;
  10698. protected $rules;
  10699. protected $addedMap;
  10700. protected $conflictAddedMap;
  10701. protected $addedPackages;
  10702. protected $addedPackagesByNames;
  10703. protected $conflictsForName;
  10704. public function __construct(PolicyInterface $policy, Pool $pool)
  10705. {
  10706. $this->policy = $policy;
  10707. $this->pool = $pool;
  10708. }
  10709. protected function createRequireRule(PackageInterface $package, array $providers, $reason, $reasonData = null)
  10710. {
  10711. $literals = array(-$package->id);
  10712. foreach ($providers as $provider) {
  10713. if ($provider === $package) {
  10714. return null;
  10715. }
  10716. $literals[] = $provider->id;
  10717. }
  10718. return new GenericRule($literals, $reason, $reasonData);
  10719. }
  10720. protected function createInstallOneOfRule(array $packages, $reason, $reasonData)
  10721. {
  10722. $literals = array();
  10723. foreach ($packages as $package) {
  10724. $literals[] = $package->id;
  10725. }
  10726. return new GenericRule($literals, $reason, $reasonData);
  10727. }
  10728. protected function createRule2Literals(PackageInterface $issuer, PackageInterface $provider, $reason, $reasonData = null)
  10729. {
  10730. if ($issuer === $provider) {
  10731. return null;
  10732. }
  10733. return new Rule2Literals(-$issuer->id, -$provider->id, $reason, $reasonData);
  10734. }
  10735. protected function createMultiConflictRule(array $packages, $reason, $reasonData = null)
  10736. {
  10737. $literals = array();
  10738. foreach ($packages as $package) {
  10739. $literals[] = -$package->id;
  10740. }
  10741. if (\count($literals) == 2) {
  10742. return new Rule2Literals($literals[0], $literals[1], $reason, $reasonData);
  10743. }
  10744. return new MultiConflictRule($literals, $reason, $reasonData);
  10745. }
  10746. private function addRule($type, Rule $newRule = null)
  10747. {
  10748. if (!$newRule) {
  10749. return;
  10750. }
  10751. $this->rules->add($newRule, $type);
  10752. }
  10753. protected function addRulesForPackage(PackageInterface $package, $ignorePlatformReqs)
  10754. {
  10755. $workQueue = new \SplQueue;
  10756. $workQueue->enqueue($package);
  10757. while (!$workQueue->isEmpty()) {
  10758. $package = $workQueue->dequeue();
  10759. if (isset($this->addedMap[$package->id])) {
  10760. continue;
  10761. }
  10762. $this->addedMap[$package->id] = true;
  10763. $this->addedPackages[] = $package;
  10764. if (!$package instanceof AliasPackage) {
  10765. foreach ($package->getNames(false) as $name) {
  10766. $this->addedPackagesByNames[$name][] = $package;
  10767. }
  10768. } else {
  10769. $workQueue->enqueue($package->getAliasOf());
  10770. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, array($package->getAliasOf()), Rule::RULE_PACKAGE_ALIAS, $package));
  10771. if (!$package->hasSelfVersionRequires()) {
  10772. continue;
  10773. }
  10774. }
  10775. foreach ($package->getRequires() as $link) {
  10776. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($link->getTarget(), $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($link->getTarget())) {
  10777. continue;
  10778. }
  10779. $possibleRequires = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
  10780. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, $possibleRequires, Rule::RULE_PACKAGE_REQUIRES, $link));
  10781. foreach ($possibleRequires as $require) {
  10782. $workQueue->enqueue($require);
  10783. }
  10784. }
  10785. }
  10786. }
  10787. protected function addConflictRules($ignorePlatformReqs = false)
  10788. {
  10789. foreach ($this->addedPackages as $package) {
  10790. foreach ($package->getConflicts() as $link) {
  10791. if (!isset($this->addedPackagesByNames[$link->getTarget()])) {
  10792. continue;
  10793. }
  10794. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($link->getTarget(), $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($link->getTarget())) {
  10795. continue;
  10796. }
  10797. foreach ($this->addedPackagesByNames[$link->getTarget()] as $possibleConflict) {
  10798. if ($this->pool->match($possibleConflict, $link->getTarget(), $link->getConstraint())) {
  10799. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRule2Literals($package, $possibleConflict, Rule::RULE_PACKAGE_CONFLICT, $link));
  10800. }
  10801. }
  10802. }
  10803. }
  10804. foreach ($this->addedPackagesByNames as $name => $packages) {
  10805. if (\count($packages) > 1) {
  10806. $reason = Rule::RULE_PACKAGE_SAME_NAME;
  10807. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createMultiConflictRule($packages, $reason, $name));
  10808. }
  10809. }
  10810. }
  10811. protected function addRulesForRequest(Request $request, $ignorePlatformReqs)
  10812. {
  10813. foreach ($request->getFixedPackages() as $package) {
  10814. if ($package->id == -1) {
  10815. if ($this->pool->isUnacceptableFixedOrLockedPackage($package)) {
  10816. continue;
  10817. }
  10818. throw new \LogicException("Fixed package ".$package->getName()." ".$package->getVersion().($package instanceof AliasPackage ? " (alias)" : "")." was not added to solver pool.");
  10819. }
  10820. $this->addRulesForPackage($package, $ignorePlatformReqs);
  10821. $rule = $this->createInstallOneOfRule(array($package), Rule::RULE_FIXED, array(
  10822. 'package' => $package,
  10823. ));
  10824. $this->addRule(RuleSet::TYPE_REQUEST, $rule);
  10825. }
  10826. foreach ($request->getRequires() as $packageName => $constraint) {
  10827. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($packageName, $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($packageName)) {
  10828. continue;
  10829. }
  10830. $packages = $this->pool->whatProvides($packageName, $constraint);
  10831. if ($packages) {
  10832. foreach ($packages as $package) {
  10833. $this->addRulesForPackage($package, $ignorePlatformReqs);
  10834. }
  10835. $rule = $this->createInstallOneOfRule($packages, Rule::RULE_ROOT_REQUIRE, array(
  10836. 'packageName' => $packageName,
  10837. 'constraint' => $constraint,
  10838. ));
  10839. $this->addRule(RuleSet::TYPE_REQUEST, $rule);
  10840. }
  10841. }
  10842. }
  10843. public function getRulesFor(Request $request, $ignorePlatformReqs = false)
  10844. {
  10845. $this->rules = new RuleSet;
  10846. $this->addedMap = array();
  10847. $this->conflictAddedMap = array();
  10848. $this->addedPackages = array();
  10849. $this->addedPackagesByNames = array();
  10850. $this->conflictsForName = array();
  10851. $this->addRulesForRequest($request, $ignorePlatformReqs);
  10852. $this->addConflictRules($ignorePlatformReqs);
  10853. $this->addedPackages = $this->addedPackagesByNames = null;
  10854. return $this->rules;
  10855. }
  10856. }
  10857. <?php
  10858. namespace Composer\DependencyResolver;
  10859. class RuleSetIterator implements \Iterator
  10860. {
  10861. protected $rules;
  10862. protected $types;
  10863. protected $currentOffset;
  10864. protected $currentType;
  10865. protected $currentTypeOffset;
  10866. public function __construct(array $rules)
  10867. {
  10868. $this->rules = $rules;
  10869. $this->types = array_keys($rules);
  10870. sort($this->types);
  10871. $this->rewind();
  10872. }
  10873. public function current()
  10874. {
  10875. return $this->rules[$this->currentType][$this->currentOffset];
  10876. }
  10877. public function key()
  10878. {
  10879. return $this->currentType;
  10880. }
  10881. public function next()
  10882. {
  10883. $this->currentOffset++;
  10884. if (!isset($this->rules[$this->currentType])) {
  10885. return;
  10886. }
  10887. if ($this->currentOffset >= \count($this->rules[$this->currentType])) {
  10888. $this->currentOffset = 0;
  10889. do {
  10890. $this->currentTypeOffset++;
  10891. if (!isset($this->types[$this->currentTypeOffset])) {
  10892. $this->currentType = -1;
  10893. break;
  10894. }
  10895. $this->currentType = $this->types[$this->currentTypeOffset];
  10896. } while (isset($this->types[$this->currentTypeOffset]) && !\count($this->rules[$this->currentType]));
  10897. }
  10898. }
  10899. public function rewind()
  10900. {
  10901. $this->currentOffset = 0;
  10902. $this->currentTypeOffset = -1;
  10903. $this->currentType = -1;
  10904. do {
  10905. $this->currentTypeOffset++;
  10906. if (!isset($this->types[$this->currentTypeOffset])) {
  10907. $this->currentType = -1;
  10908. break;
  10909. }
  10910. $this->currentType = $this->types[$this->currentTypeOffset];
  10911. } while (isset($this->types[$this->currentTypeOffset]) && !\count($this->rules[$this->currentType]));
  10912. }
  10913. public function valid()
  10914. {
  10915. return isset($this->rules[$this->currentType], $this->rules[$this->currentType][$this->currentOffset]);
  10916. }
  10917. }
  10918. <?php
  10919. namespace Composer\DependencyResolver;
  10920. class RuleWatchChain extends \SplDoublyLinkedList
  10921. {
  10922. protected $offset = 0;
  10923. public function seek($offset)
  10924. {
  10925. $this->rewind();
  10926. for ($i = 0; $i < $offset; $i++, $this->next());
  10927. }
  10928. public function remove()
  10929. {
  10930. $offset = $this->key();
  10931. $this->offsetUnset($offset);
  10932. $this->seek($offset);
  10933. }
  10934. }
  10935. <?php
  10936. namespace Composer\DependencyResolver;
  10937. class RuleWatchGraph
  10938. {
  10939. protected $watchChains = array();
  10940. public function insert(RuleWatchNode $node)
  10941. {
  10942. if ($node->getRule()->isAssertion()) {
  10943. return;
  10944. }
  10945. if (!$node->getRule() instanceof MultiConflictRule) {
  10946. foreach (array($node->watch1, $node->watch2) as $literal) {
  10947. if (!isset($this->watchChains[$literal])) {
  10948. $this->watchChains[$literal] = new RuleWatchChain;
  10949. }
  10950. $this->watchChains[$literal]->unshift($node);
  10951. }
  10952. } else {
  10953. foreach ($node->getRule()->getLiterals() as $literal) {
  10954. if (!isset($this->watchChains[$literal])) {
  10955. $this->watchChains[$literal] = new RuleWatchChain;
  10956. }
  10957. $this->watchChains[$literal]->unshift($node);
  10958. }
  10959. }
  10960. }
  10961. public function propagateLiteral($decidedLiteral, $level, $decisions)
  10962. {
  10963. $literal = -$decidedLiteral;
  10964. if (!isset($this->watchChains[$literal])) {
  10965. return null;
  10966. }
  10967. $chain = $this->watchChains[$literal];
  10968. $chain->rewind();
  10969. while ($chain->valid()) {
  10970. $node = $chain->current();
  10971. if (!$node->getRule() instanceof MultiConflictRule) {
  10972. $otherWatch = $node->getOtherWatch($literal);
  10973. if (!$node->getRule()->isDisabled() && !$decisions->satisfy($otherWatch)) {
  10974. $ruleLiterals = $node->getRule()->getLiterals();
  10975. $alternativeLiterals = array_filter($ruleLiterals, function ($ruleLiteral) use ($literal, $otherWatch, $decisions) {
  10976. return $literal !== $ruleLiteral &&
  10977. $otherWatch !== $ruleLiteral &&
  10978. !$decisions->conflict($ruleLiteral);
  10979. });
  10980. if ($alternativeLiterals) {
  10981. reset($alternativeLiterals);
  10982. $this->moveWatch($literal, current($alternativeLiterals), $node);
  10983. continue;
  10984. }
  10985. if ($decisions->conflict($otherWatch)) {
  10986. return $node->getRule();
  10987. }
  10988. $decisions->decide($otherWatch, $level, $node->getRule());
  10989. }
  10990. } else {
  10991. foreach ($node->getRule()->getLiterals() as $otherLiteral) {
  10992. if ($literal !== $otherLiteral && !$decisions->satisfy($otherLiteral)) {
  10993. if ($decisions->conflict($otherLiteral)) {
  10994. return $node->getRule();
  10995. }
  10996. $decisions->decide($otherLiteral, $level, $node->getRule());
  10997. }
  10998. }
  10999. }
  11000. $chain->next();
  11001. }
  11002. return null;
  11003. }
  11004. protected function moveWatch($fromLiteral, $toLiteral, $node)
  11005. {
  11006. if (!isset($this->watchChains[$toLiteral])) {
  11007. $this->watchChains[$toLiteral] = new RuleWatchChain;
  11008. }
  11009. $node->moveWatch($fromLiteral, $toLiteral);
  11010. $this->watchChains[$fromLiteral]->remove();
  11011. $this->watchChains[$toLiteral]->unshift($node);
  11012. }
  11013. }
  11014. <?php
  11015. namespace Composer\DependencyResolver;
  11016. class RuleWatchNode
  11017. {
  11018. public $watch1;
  11019. public $watch2;
  11020. protected $rule;
  11021. public function __construct($rule)
  11022. {
  11023. $this->rule = $rule;
  11024. $literals = $rule->getLiterals();
  11025. $literalCount = \count($literals);
  11026. $this->watch1 = $literalCount > 0 ? $literals[0] : 0;
  11027. $this->watch2 = $literalCount > 1 ? $literals[1] : 0;
  11028. }
  11029. public function watch2OnHighest(Decisions $decisions)
  11030. {
  11031. $literals = $this->rule->getLiterals();
  11032. if (\count($literals) < 3 || $this->rule instanceof MultiConflictRule) {
  11033. return;
  11034. }
  11035. $watchLevel = 0;
  11036. foreach ($literals as $literal) {
  11037. $level = $decisions->decisionLevel($literal);
  11038. if ($level > $watchLevel) {
  11039. $this->watch2 = $literal;
  11040. $watchLevel = $level;
  11041. }
  11042. }
  11043. }
  11044. public function getRule()
  11045. {
  11046. return $this->rule;
  11047. }
  11048. public function getOtherWatch($literal)
  11049. {
  11050. if ($this->watch1 == $literal) {
  11051. return $this->watch2;
  11052. }
  11053. return $this->watch1;
  11054. }
  11055. public function moveWatch($from, $to)
  11056. {
  11057. if ($this->watch1 == $from) {
  11058. $this->watch1 = $to;
  11059. } else {
  11060. $this->watch2 = $to;
  11061. }
  11062. }
  11063. }
  11064. <?php
  11065. namespace Composer\DependencyResolver;
  11066. use Composer\IO\IOInterface;
  11067. use Composer\Package\PackageInterface;
  11068. use Composer\Repository\PlatformRepository;
  11069. use Composer\Semver\Constraint\MultiConstraint;
  11070. class Solver
  11071. {
  11072. const BRANCH_LITERALS = 0;
  11073. const BRANCH_LEVEL = 1;
  11074. protected $policy;
  11075. protected $pool;
  11076. protected $rules;
  11077. protected $watchGraph;
  11078. protected $decisions;
  11079. protected $fixedMap;
  11080. protected $propagateIndex;
  11081. protected $branches = array();
  11082. protected $problems = array();
  11083. protected $learnedPool = array();
  11084. protected $learnedWhy = array();
  11085. public $testFlagLearnedPositiveLiteral = false;
  11086. protected $io;
  11087. public function __construct(PolicyInterface $policy, Pool $pool, IOInterface $io)
  11088. {
  11089. $this->io = $io;
  11090. $this->policy = $policy;
  11091. $this->pool = $pool;
  11092. }
  11093. public function getRuleSetSize()
  11094. {
  11095. return \count($this->rules);
  11096. }
  11097. public function getPool()
  11098. {
  11099. return $this->pool;
  11100. }
  11101. private function makeAssertionRuleDecisions()
  11102. {
  11103. $decisionStart = \count($this->decisions) - 1;
  11104. $rulesCount = \count($this->rules);
  11105. for ($ruleIndex = 0; $ruleIndex < $rulesCount; $ruleIndex++) {
  11106. $rule = $this->rules->ruleById[$ruleIndex];
  11107. if (!$rule->isAssertion() || $rule->isDisabled()) {
  11108. continue;
  11109. }
  11110. $literals = $rule->getLiterals();
  11111. $literal = $literals[0];
  11112. if (!$this->decisions->decided($literal)) {
  11113. $this->decisions->decide($literal, 1, $rule);
  11114. continue;
  11115. }
  11116. if ($this->decisions->satisfy($literal)) {
  11117. continue;
  11118. }
  11119. if (RuleSet::TYPE_LEARNED === $rule->getType()) {
  11120. $rule->disable();
  11121. continue;
  11122. }
  11123. $conflict = $this->decisions->decisionRule($literal);
  11124. if ($conflict && RuleSet::TYPE_PACKAGE === $conflict->getType()) {
  11125. $problem = new Problem();
  11126. $problem->addRule($rule);
  11127. $problem->addRule($conflict);
  11128. $rule->disable();
  11129. $this->problems[] = $problem;
  11130. continue;
  11131. }
  11132. $problem = new Problem();
  11133. $problem->addRule($rule);
  11134. $problem->addRule($conflict);
  11135. foreach ($this->rules->getIteratorFor(RuleSet::TYPE_REQUEST) as $assertRule) {
  11136. if ($assertRule->isDisabled() || !$assertRule->isAssertion()) {
  11137. continue;
  11138. }
  11139. $assertRuleLiterals = $assertRule->getLiterals();
  11140. $assertRuleLiteral = $assertRuleLiterals[0];
  11141. if (abs($literal) !== abs($assertRuleLiteral)) {
  11142. continue;
  11143. }
  11144. $problem->addRule($assertRule);
  11145. $assertRule->disable();
  11146. }
  11147. $this->problems[] = $problem;
  11148. $this->decisions->resetToOffset($decisionStart);
  11149. $ruleIndex = -1;
  11150. }
  11151. }
  11152. protected function setupFixedMap(Request $request)
  11153. {
  11154. $this->fixedMap = array();
  11155. foreach ($request->getFixedPackages() as $package) {
  11156. $this->fixedMap[$package->id] = $package;
  11157. }
  11158. }
  11159. protected function checkForRootRequireProblems(Request $request, $ignorePlatformReqs)
  11160. {
  11161. foreach ($request->getRequires() as $packageName => $constraint) {
  11162. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($packageName, $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($packageName)) {
  11163. continue;
  11164. }
  11165. if (!$this->pool->whatProvides($packageName, $constraint)) {
  11166. $problem = new Problem();
  11167. $problem->addRule(new GenericRule(array(), Rule::RULE_ROOT_REQUIRE, array('packageName' => $packageName, 'constraint' => $constraint)));
  11168. $this->problems[] = $problem;
  11169. }
  11170. }
  11171. }
  11172. public function solve(Request $request, $ignorePlatformReqs = false)
  11173. {
  11174. $this->setupFixedMap($request);
  11175. $this->io->writeError('Generating rules', true, IOInterface::DEBUG);
  11176. $ruleSetGenerator = new RuleSetGenerator($this->policy, $this->pool);
  11177. $this->rules = $ruleSetGenerator->getRulesFor($request, $ignorePlatformReqs);
  11178. unset($ruleSetGenerator);
  11179. $this->checkForRootRequireProblems($request, $ignorePlatformReqs);
  11180. $this->decisions = new Decisions($this->pool);
  11181. $this->watchGraph = new RuleWatchGraph;
  11182. foreach ($this->rules as $rule) {
  11183. $this->watchGraph->insert(new RuleWatchNode($rule));
  11184. }
  11185. $this->makeAssertionRuleDecisions();
  11186. $this->io->writeError('Resolving dependencies through SAT', true, IOInterface::DEBUG);
  11187. $before = microtime(true);
  11188. $this->runSat();
  11189. $this->io->writeError('', true, IOInterface::DEBUG);
  11190. $this->io->writeError(sprintf('Dependency resolution completed in %.3f seconds', microtime(true) - $before), true, IOInterface::VERBOSE);
  11191. if ($this->problems) {
  11192. throw new SolverProblemsException($this->problems, $this->learnedPool);
  11193. }
  11194. return new LockTransaction($this->pool, $request->getPresentMap(), $request->getFixedPackagesMap(), $this->decisions);
  11195. }
  11196. protected function propagate($level)
  11197. {
  11198. while ($this->decisions->validOffset($this->propagateIndex)) {
  11199. $decision = $this->decisions->atOffset($this->propagateIndex);
  11200. $conflict = $this->watchGraph->propagateLiteral(
  11201. $decision[Decisions::DECISION_LITERAL],
  11202. $level,
  11203. $this->decisions
  11204. );
  11205. $this->propagateIndex++;
  11206. if ($conflict) {
  11207. return $conflict;
  11208. }
  11209. }
  11210. return null;
  11211. }
  11212. private function revert($level)
  11213. {
  11214. while (!$this->decisions->isEmpty()) {
  11215. $literal = $this->decisions->lastLiteral();
  11216. if ($this->decisions->undecided($literal)) {
  11217. break;
  11218. }
  11219. $decisionLevel = $this->decisions->decisionLevel($literal);
  11220. if ($decisionLevel <= $level) {
  11221. break;
  11222. }
  11223. $this->decisions->revertLast();
  11224. $this->propagateIndex = \count($this->decisions);
  11225. }
  11226. while (!empty($this->branches) && $this->branches[\count($this->branches) - 1][self::BRANCH_LEVEL] >= $level) {
  11227. array_pop($this->branches);
  11228. }
  11229. }
  11230. private function setPropagateLearn($level, $literal, Rule $rule)
  11231. {
  11232. $level++;
  11233. $this->decisions->decide($literal, $level, $rule);
  11234. while (true) {
  11235. $rule = $this->propagate($level);
  11236. if (!$rule) {
  11237. break;
  11238. }
  11239. if ($level == 1) {
  11240. return $this->analyzeUnsolvable($rule);
  11241. }
  11242. list($learnLiteral, $newLevel, $newRule, $why) = $this->analyze($level, $rule);
  11243. if ($newLevel <= 0 || $newLevel >= $level) {
  11244. throw new SolverBugException(
  11245. "Trying to revert to invalid level ".(int) $newLevel." from level ".(int) $level."."
  11246. );
  11247. }
  11248. if (!$newRule) {
  11249. throw new SolverBugException(
  11250. "No rule was learned from analyzing $rule at level $level."
  11251. );
  11252. }
  11253. $level = $newLevel;
  11254. $this->revert($level);
  11255. $this->rules->add($newRule, RuleSet::TYPE_LEARNED);
  11256. $this->learnedWhy[spl_object_hash($newRule)] = $why;
  11257. $ruleNode = new RuleWatchNode($newRule);
  11258. $ruleNode->watch2OnHighest($this->decisions);
  11259. $this->watchGraph->insert($ruleNode);
  11260. $this->decisions->decide($learnLiteral, $level, $newRule);
  11261. }
  11262. return $level;
  11263. }
  11264. private function selectAndInstall($level, array $decisionQueue, Rule $rule)
  11265. {
  11266. $literals = $this->policy->selectPreferredPackages($this->pool, $decisionQueue, $rule->getRequiredPackage());
  11267. $selectedLiteral = array_shift($literals);
  11268. if (\count($literals)) {
  11269. $this->branches[] = array($literals, $level);
  11270. }
  11271. return $this->setPropagateLearn($level, $selectedLiteral, $rule);
  11272. }
  11273. protected function analyze($level, Rule $rule)
  11274. {
  11275. $analyzedRule = $rule;
  11276. $ruleLevel = 1;
  11277. $num = 0;
  11278. $l1num = 0;
  11279. $seen = array();
  11280. $learnedLiterals = array(null);
  11281. $decisionId = \count($this->decisions);
  11282. $this->learnedPool[] = array();
  11283. while (true) {
  11284. $this->learnedPool[\count($this->learnedPool) - 1][] = $rule;
  11285. foreach ($rule->getLiterals() as $literal) {
  11286. if ($rule instanceof MultiConflictRule && !$this->decisions->decided($literal)) {
  11287. continue;
  11288. }
  11289. if ($this->decisions->satisfy($literal)) {
  11290. continue;
  11291. }
  11292. if (isset($seen[abs($literal)])) {
  11293. continue;
  11294. }
  11295. $seen[abs($literal)] = true;
  11296. $l = $this->decisions->decisionLevel($literal);
  11297. if (1 === $l) {
  11298. $l1num++;
  11299. } elseif ($level === $l) {
  11300. $num++;
  11301. } else {
  11302. $learnedLiterals[] = $literal;
  11303. if ($l > $ruleLevel) {
  11304. $ruleLevel = $l;
  11305. }
  11306. }
  11307. }
  11308. unset($literal);
  11309. $l1retry = true;
  11310. while ($l1retry) {
  11311. $l1retry = false;
  11312. if (!$num && !--$l1num) {
  11313. break 2;
  11314. }
  11315. while (true) {
  11316. if ($decisionId <= 0) {
  11317. throw new SolverBugException(
  11318. "Reached invalid decision id $decisionId while looking through $rule for a literal present in the analyzed rule $analyzedRule."
  11319. );
  11320. }
  11321. $decisionId--;
  11322. $decision = $this->decisions->atOffset($decisionId);
  11323. $literal = $decision[Decisions::DECISION_LITERAL];
  11324. if (isset($seen[abs($literal)])) {
  11325. break;
  11326. }
  11327. }
  11328. unset($seen[abs($literal)]);
  11329. if ($num && 0 === --$num) {
  11330. if ($literal < 0) {
  11331. $this->testFlagLearnedPositiveLiteral = true;
  11332. }
  11333. $learnedLiterals[0] = -$literal;
  11334. if (!$l1num) {
  11335. break 2;
  11336. }
  11337. foreach ($learnedLiterals as $i => $learnedLiteral) {
  11338. if ($i !== 0) {
  11339. unset($seen[abs($learnedLiteral)]);
  11340. }
  11341. }
  11342. $l1num++;
  11343. $l1retry = true;
  11344. }
  11345. $decision = $this->decisions->atOffset($decisionId);
  11346. $rule = $decision[Decisions::DECISION_REASON];
  11347. if ($rule instanceof MultiConflictRule) {
  11348. foreach ($rule->getLiterals() as $literal) {
  11349. if (!isset($seen[abs($literal)]) && $this->decisions->satisfy(-$literal)) {
  11350. $this->learnedPool[\count($this->learnedPool) - 1][] = $rule;
  11351. $l = $this->decisions->decisionLevel($literal);
  11352. if (1 === $l) {
  11353. $l1num++;
  11354. } elseif ($level === $l) {
  11355. $num++;
  11356. } else {
  11357. $learnedLiterals[] = $literal;
  11358. if ($l > $ruleLevel) {
  11359. $ruleLevel = $l;
  11360. }
  11361. }
  11362. $seen[abs($literal)] = true;
  11363. break;
  11364. }
  11365. }
  11366. $l1retry = true;
  11367. }
  11368. }
  11369. $decision = $this->decisions->atOffset($decisionId);
  11370. $rule = $decision[Decisions::DECISION_REASON];
  11371. }
  11372. $why = \count($this->learnedPool) - 1;
  11373. if (!$learnedLiterals[0]) {
  11374. throw new SolverBugException(
  11375. "Did not find a learnable literal in analyzed rule $analyzedRule."
  11376. );
  11377. }
  11378. $newRule = new GenericRule($learnedLiterals, Rule::RULE_LEARNED, $why);
  11379. return array($learnedLiterals[0], $ruleLevel, $newRule, $why);
  11380. }
  11381. private function analyzeUnsolvableRule(Problem $problem, Rule $conflictRule)
  11382. {
  11383. if ($conflictRule->getType() == RuleSet::TYPE_LEARNED) {
  11384. $why = spl_object_hash($conflictRule);
  11385. $learnedWhy = $this->learnedWhy[$why];
  11386. $problemRules = $this->learnedPool[$learnedWhy];
  11387. foreach ($problemRules as $problemRule) {
  11388. $this->analyzeUnsolvableRule($problem, $problemRule);
  11389. }
  11390. return;
  11391. }
  11392. if ($conflictRule->getType() == RuleSet::TYPE_PACKAGE) {
  11393. return;
  11394. }
  11395. $problem->nextSection();
  11396. $problem->addRule($conflictRule);
  11397. }
  11398. private function analyzeUnsolvable(Rule $conflictRule)
  11399. {
  11400. $problem = new Problem();
  11401. $problem->addRule($conflictRule);
  11402. $this->analyzeUnsolvableRule($problem, $conflictRule);
  11403. $this->problems[] = $problem;
  11404. $seen = array();
  11405. $literals = $conflictRule->getLiterals();
  11406. foreach ($literals as $literal) {
  11407. if ($this->decisions->satisfy($literal)) {
  11408. continue;
  11409. }
  11410. $seen[abs($literal)] = true;
  11411. }
  11412. foreach ($this->decisions as $decision) {
  11413. $literal = $decision[Decisions::DECISION_LITERAL];
  11414. if (!isset($seen[abs($literal)])) {
  11415. continue;
  11416. }
  11417. $why = $decision[Decisions::DECISION_REASON];
  11418. $problem->addRule($why);
  11419. $this->analyzeUnsolvableRule($problem, $why);
  11420. $literals = $why->getLiterals();
  11421. foreach ($literals as $literal) {
  11422. if ($this->decisions->satisfy($literal)) {
  11423. continue;
  11424. }
  11425. $seen[abs($literal)] = true;
  11426. }
  11427. }
  11428. return 0;
  11429. }
  11430. private function enableDisableLearnedRules()
  11431. {
  11432. foreach ($this->rules->getIteratorFor(RuleSet::TYPE_LEARNED) as $rule) {
  11433. $why = $this->learnedWhy[spl_object_hash($rule)];
  11434. $problemRules = $this->learnedPool[$why];
  11435. $foundDisabled = false;
  11436. foreach ($problemRules as $problemRule) {
  11437. if ($problemRule->isDisabled()) {
  11438. $foundDisabled = true;
  11439. break;
  11440. }
  11441. }
  11442. if ($foundDisabled && $rule->isEnabled()) {
  11443. $rule->disable();
  11444. } elseif (!$foundDisabled && $rule->isDisabled()) {
  11445. $rule->enable();
  11446. }
  11447. }
  11448. }
  11449. private function runSat()
  11450. {
  11451. $this->propagateIndex = 0;
  11452. $level = 1;
  11453. $systemLevel = $level + 1;
  11454. while (true) {
  11455. if (1 === $level) {
  11456. $conflictRule = $this->propagate($level);
  11457. if (null !== $conflictRule) {
  11458. if ($this->analyzeUnsolvable($conflictRule)) {
  11459. continue;
  11460. }
  11461. return;
  11462. }
  11463. }
  11464. if ($level < $systemLevel) {
  11465. $iterator = $this->rules->getIteratorFor(RuleSet::TYPE_REQUEST);
  11466. foreach ($iterator as $rule) {
  11467. if ($rule->isEnabled()) {
  11468. $decisionQueue = array();
  11469. $noneSatisfied = true;
  11470. foreach ($rule->getLiterals() as $literal) {
  11471. if ($this->decisions->satisfy($literal)) {
  11472. $noneSatisfied = false;
  11473. break;
  11474. }
  11475. if ($literal > 0 && $this->decisions->undecided($literal)) {
  11476. $decisionQueue[] = $literal;
  11477. }
  11478. }
  11479. if ($noneSatisfied && \count($decisionQueue)) {
  11480. $prunedQueue = array();
  11481. foreach ($decisionQueue as $literal) {
  11482. if (isset($this->fixedMap[abs($literal)])) {
  11483. $prunedQueue[] = $literal;
  11484. }
  11485. }
  11486. if (!empty($prunedQueue)) {
  11487. $decisionQueue = $prunedQueue;
  11488. }
  11489. }
  11490. if ($noneSatisfied && \count($decisionQueue)) {
  11491. $oLevel = $level;
  11492. $level = $this->selectAndInstall($level, $decisionQueue, $rule);
  11493. if (0 === $level) {
  11494. return;
  11495. }
  11496. if ($level <= $oLevel) {
  11497. break;
  11498. }
  11499. }
  11500. }
  11501. }
  11502. $systemLevel = $level + 1;
  11503. $iterator->next();
  11504. if ($iterator->valid()) {
  11505. continue;
  11506. }
  11507. }
  11508. if ($level < $systemLevel) {
  11509. $systemLevel = $level;
  11510. }
  11511. $rulesCount = \count($this->rules);
  11512. $pass = 1;
  11513. $this->io->writeError('Looking at all rules.', true, IOInterface::DEBUG);
  11514. for ($i = 0, $n = 0; $n < $rulesCount; $i++, $n++) {
  11515. if ($i == $rulesCount) {
  11516. if (1 === $pass) {
  11517. $this->io->writeError("Something's changed, looking at all rules again (pass #$pass)", false, IOInterface::DEBUG);
  11518. } else {
  11519. $this->io->overwriteError("Something's changed, looking at all rules again (pass #$pass)", false, null, IOInterface::DEBUG);
  11520. }
  11521. $i = 0;
  11522. $pass++;
  11523. }
  11524. $rule = $this->rules->ruleById[$i];
  11525. $literals = $rule->getLiterals();
  11526. if ($rule->isDisabled()) {
  11527. continue;
  11528. }
  11529. $decisionQueue = array();
  11530. foreach ($literals as $literal) {
  11531. if ($literal <= 0) {
  11532. if (!$this->decisions->decidedInstall($literal)) {
  11533. continue 2;
  11534. }
  11535. } else {
  11536. if ($this->decisions->decidedInstall($literal)) {
  11537. continue 2;
  11538. }
  11539. if ($this->decisions->undecided($literal)) {
  11540. $decisionQueue[] = $literal;
  11541. }
  11542. }
  11543. }
  11544. if (\count($decisionQueue) < 2) {
  11545. continue;
  11546. }
  11547. $level = $this->selectAndInstall($level, $decisionQueue, $rule);
  11548. if (0 === $level) {
  11549. return;
  11550. }
  11551. $rulesCount = \count($this->rules);
  11552. $n = -1;
  11553. }
  11554. if ($level < $systemLevel) {
  11555. continue;
  11556. }
  11557. if (\count($this->branches)) {
  11558. $lastLiteral = null;
  11559. $lastLevel = null;
  11560. $lastBranchIndex = 0;
  11561. $lastBranchOffset = 0;
  11562. for ($i = \count($this->branches) - 1; $i >= 0; $i--) {
  11563. list($literals, $l) = $this->branches[$i];
  11564. foreach ($literals as $offset => $literal) {
  11565. if ($literal && $literal > 0 && $this->decisions->decisionLevel($literal) > $l + 1) {
  11566. $lastLiteral = $literal;
  11567. $lastBranchIndex = $i;
  11568. $lastBranchOffset = $offset;
  11569. $lastLevel = $l;
  11570. }
  11571. }
  11572. }
  11573. if ($lastLiteral) {
  11574. unset($this->branches[$lastBranchIndex][self::BRANCH_LITERALS][$lastBranchOffset]);
  11575. $level = $lastLevel;
  11576. $this->revert($level);
  11577. $why = $this->decisions->lastReason();
  11578. $level = $this->setPropagateLearn($level, $lastLiteral, $why);
  11579. if ($level == 0) {
  11580. return;
  11581. }
  11582. continue;
  11583. }
  11584. }
  11585. break;
  11586. }
  11587. }
  11588. }
  11589. <?php
  11590. namespace Composer\DependencyResolver;
  11591. class SolverBugException extends \RuntimeException
  11592. {
  11593. public function __construct($message)
  11594. {
  11595. parent::__construct(
  11596. $message."\nThis exception was most likely caused by a bug in Composer.\n".
  11597. "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"
  11598. );
  11599. }
  11600. }
  11601. <?php
  11602. namespace Composer\DependencyResolver;
  11603. use Composer\Util\IniHelper;
  11604. use Composer\Repository\RepositorySet;
  11605. class SolverProblemsException extends \RuntimeException
  11606. {
  11607. protected $problems;
  11608. protected $learnedPool;
  11609. public function __construct(array $problems, array $learnedPool)
  11610. {
  11611. $this->problems = $problems;
  11612. $this->learnedPool = $learnedPool;
  11613. parent::__construct('Failed resolving dependencies with '.count($problems).' problems, call getPrettyString to get formatted details', 2);
  11614. }
  11615. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, $isDevExtraction = false)
  11616. {
  11617. $installedMap = $request->getPresentMap(true);
  11618. $hasExtensionProblems = false;
  11619. $isCausedByLock = false;
  11620. $problems = array();
  11621. foreach ($this->problems as $problem) {
  11622. $problems[] = $problem->getPrettyString($repositorySet, $request, $pool, $isVerbose, $installedMap, $this->learnedPool)."\n";
  11623. if (!$hasExtensionProblems && $this->hasExtensionProblems($problem->getReasons())) {
  11624. $hasExtensionProblems = true;
  11625. }
  11626. $isCausedByLock |= $problem->isCausedByLock($repositorySet, $request, $pool);
  11627. }
  11628. $i = 1;
  11629. $text = "\n";
  11630. foreach (array_unique($problems) as $problem) {
  11631. $text .= " Problem ".($i++).$problem;
  11632. }
  11633. $hints = array();
  11634. if (!$isDevExtraction && (strpos($text, 'could not be found') || strpos($text, 'no matching package found'))) {
  11635. $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.";
  11636. }
  11637. if ($hasExtensionProblems) {
  11638. $hints[] = $this->createExtensionHint();
  11639. }
  11640. if ($isCausedByLock && !$isDevExtraction) {
  11641. $hints[] = "Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.";
  11642. }
  11643. if (strpos($text, 'found composer-plugin-api[2.0.0] but it does not match') && strpos($text, '- ocramius/package-versions')) {
  11644. $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+.";
  11645. }
  11646. if (!class_exists('PHPUnit\Framework\TestCase', false)) {
  11647. if (strpos($text, 'found composer-plugin-api[2.0.0] but it does not match')) {
  11648. $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.";
  11649. }
  11650. }
  11651. if ($hints) {
  11652. $text .= "\n" . implode("\n\n", $hints);
  11653. }
  11654. return $text;
  11655. }
  11656. public function getProblems()
  11657. {
  11658. return $this->problems;
  11659. }
  11660. private function createExtensionHint()
  11661. {
  11662. $paths = IniHelper::getAll();
  11663. if (count($paths) === 1 && empty($paths[0])) {
  11664. return '';
  11665. }
  11666. $text = "To enable extensions, verify that they are enabled in your .ini files:\n - ";
  11667. $text .= implode("\n - ", $paths);
  11668. $text .= "\nYou can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.";
  11669. return $text;
  11670. }
  11671. private function hasExtensionProblems(array $reasonSets)
  11672. {
  11673. foreach ($reasonSets as $reasonSet) {
  11674. foreach ($reasonSet as $rule) {
  11675. if (0 === strpos($rule->getRequiredPackage(), 'ext-')) {
  11676. return true;
  11677. }
  11678. }
  11679. }
  11680. return false;
  11681. }
  11682. }
  11683. <?php
  11684. namespace Composer\DependencyResolver;
  11685. use Composer\Package\AliasPackage;
  11686. use Composer\Package\Link;
  11687. use Composer\Package\PackageInterface;
  11688. use Composer\Repository\PlatformRepository;
  11689. class Transaction
  11690. {
  11691. protected $operations;
  11692. protected $presentPackages;
  11693. protected $resultPackageMap;
  11694. protected $resultPackagesByName = array();
  11695. public function __construct($presentPackages, $resultPackages)
  11696. {
  11697. $this->presentPackages = $presentPackages;
  11698. $this->setResultPackageMaps($resultPackages);
  11699. $this->operations = $this->calculateOperations();
  11700. }
  11701. public function getOperations()
  11702. {
  11703. return $this->operations;
  11704. }
  11705. private function setResultPackageMaps($resultPackages)
  11706. {
  11707. $packageSort = function (PackageInterface $a, PackageInterface $b) {
  11708. if ($a->getName() == $b->getName()) {
  11709. if ($a instanceof AliasPackage != $b instanceof AliasPackage) {
  11710. return $a instanceof AliasPackage ? -1 : 1;
  11711. }
  11712. return strcmp($b->getVersion(), $a->getVersion());
  11713. }
  11714. return strcmp($b->getName(), $a->getName());
  11715. };
  11716. $this->resultPackageMap = array();
  11717. foreach ($resultPackages as $package) {
  11718. $this->resultPackageMap[spl_object_hash($package)] = $package;
  11719. foreach ($package->getNames() as $name) {
  11720. $this->resultPackagesByName[$name][] = $package;
  11721. }
  11722. }
  11723. uasort($this->resultPackageMap, $packageSort);
  11724. foreach ($this->resultPackagesByName as $name => $packages) {
  11725. uasort($this->resultPackagesByName[$name], $packageSort);
  11726. }
  11727. }
  11728. protected function calculateOperations()
  11729. {
  11730. $operations = array();
  11731. $presentPackageMap = array();
  11732. $removeMap = array();
  11733. $presentAliasMap = array();
  11734. $removeAliasMap = array();
  11735. foreach ($this->presentPackages as $package) {
  11736. if ($package instanceof AliasPackage) {
  11737. $presentAliasMap[$package->getName().'::'.$package->getVersion()] = $package;
  11738. $removeAliasMap[$package->getName().'::'.$package->getVersion()] = $package;
  11739. } else {
  11740. $presentPackageMap[$package->getName()] = $package;
  11741. $removeMap[$package->getName()] = $package;
  11742. }
  11743. }
  11744. $stack = $this->getRootPackages();
  11745. $visited = array();
  11746. $processed = array();
  11747. while (!empty($stack)) {
  11748. $package = array_pop($stack);
  11749. if (isset($processed[spl_object_hash($package)])) {
  11750. continue;
  11751. }
  11752. if (!isset($visited[spl_object_hash($package)])) {
  11753. $visited[spl_object_hash($package)] = true;
  11754. $stack[] = $package;
  11755. if ($package instanceof AliasPackage) {
  11756. $stack[] = $package->getAliasOf();
  11757. } else {
  11758. foreach ($package->getRequires() as $link) {
  11759. $possibleRequires = $this->getProvidersInResult($link);
  11760. foreach ($possibleRequires as $require) {
  11761. $stack[] = $require;
  11762. }
  11763. }
  11764. }
  11765. } elseif (!isset($processed[spl_object_hash($package)])) {
  11766. $processed[spl_object_hash($package)] = true;
  11767. if ($package instanceof AliasPackage) {
  11768. $aliasKey = $package->getName().'::'.$package->getVersion();
  11769. if (isset($presentAliasMap[$aliasKey])) {
  11770. unset($removeAliasMap[$aliasKey]);
  11771. } else {
  11772. $operations[] = new Operation\MarkAliasInstalledOperation($package);
  11773. }
  11774. } else {
  11775. if (isset($presentPackageMap[$package->getName()])) {
  11776. $source = $presentPackageMap[$package->getName()];
  11777. if ($package->getVersion() != $presentPackageMap[$package->getName()]->getVersion() ||
  11778. $package->getDistReference() !== $presentPackageMap[$package->getName()]->getDistReference() ||
  11779. $package->getSourceReference() !== $presentPackageMap[$package->getName()]->getSourceReference()
  11780. ) {
  11781. $operations[] = new Operation\UpdateOperation($source, $package);
  11782. }
  11783. unset($removeMap[$package->getName()]);
  11784. } else {
  11785. $operations[] = new Operation\InstallOperation($package);
  11786. unset($removeMap[$package->getName()]);
  11787. }
  11788. }
  11789. }
  11790. }
  11791. foreach ($removeMap as $name => $package) {
  11792. array_unshift($operations, new Operation\UninstallOperation($package));
  11793. }
  11794. foreach ($removeAliasMap as $nameVersion => $package) {
  11795. $operations[] = new Operation\MarkAliasUninstalledOperation($package);
  11796. }
  11797. $operations = $this->movePluginsToFront($operations);
  11798. $operations = $this->moveUninstallsToFront($operations);
  11799. return $this->operations = $operations;
  11800. }
  11801. protected function getRootPackages()
  11802. {
  11803. $roots = $this->resultPackageMap;
  11804. foreach ($this->resultPackageMap as $packageHash => $package) {
  11805. if (!isset($roots[$packageHash])) {
  11806. continue;
  11807. }
  11808. foreach ($package->getRequires() as $link) {
  11809. $possibleRequires = $this->getProvidersInResult($link);
  11810. foreach ($possibleRequires as $require) {
  11811. if ($require !== $package) {
  11812. unset($roots[spl_object_hash($require)]);
  11813. }
  11814. }
  11815. }
  11816. }
  11817. return $roots;
  11818. }
  11819. protected function getProvidersInResult(Link $link)
  11820. {
  11821. if (!isset($this->resultPackagesByName[$link->getTarget()])) {
  11822. return array();
  11823. }
  11824. return $this->resultPackagesByName[$link->getTarget()];
  11825. }
  11826. private function movePluginsToFront(array $operations)
  11827. {
  11828. $pluginsNoDeps = array();
  11829. $pluginsWithDeps = array();
  11830. $pluginRequires = array();
  11831. foreach (array_reverse($operations, true) as $idx => $op) {
  11832. if ($op instanceof Operation\InstallOperation) {
  11833. $package = $op->getPackage();
  11834. } elseif ($op instanceof Operation\UpdateOperation) {
  11835. $package = $op->getTargetPackage();
  11836. } else {
  11837. continue;
  11838. }
  11839. $isPlugin = $package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer';
  11840. if ($isPlugin || count(array_intersect($package->getNames(), $pluginRequires))) {
  11841. $requires = array_filter(array_keys($package->getRequires()), function ($req) {
  11842. return !PlatformRepository::isPlatformPackage($req);
  11843. });
  11844. if ($isPlugin && !count($requires)) {
  11845. array_unshift($pluginsNoDeps, $op);
  11846. } else {
  11847. $pluginRequires = array_merge($pluginRequires, $requires);
  11848. array_unshift($pluginsWithDeps, $op);
  11849. }
  11850. unset($operations[$idx]);
  11851. }
  11852. }
  11853. return array_merge($pluginsNoDeps, $pluginsWithDeps, $operations);
  11854. }
  11855. private function moveUninstallsToFront(array $operations)
  11856. {
  11857. $uninstOps = array();
  11858. foreach ($operations as $idx => $op) {
  11859. if ($op instanceof Operation\UninstallOperation || $op instanceof Operation\MarkAliasUninstalledOperation) {
  11860. $uninstOps[] = $op;
  11861. unset($operations[$idx]);
  11862. }
  11863. }
  11864. return array_merge($uninstOps, $operations);
  11865. }
  11866. }
  11867. <?php
  11868. namespace Composer\Downloader;
  11869. use Composer\Package\PackageInterface;
  11870. use Symfony\Component\Finder\Finder;
  11871. use Composer\IO\IOInterface;
  11872. use Composer\Exception\IrrecoverableDownloadException;
  11873. use React\Promise\PromiseInterface;
  11874. use Composer\DependencyResolver\Operation\InstallOperation;
  11875. abstract class ArchiveDownloader extends FileDownloader
  11876. {
  11877. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
  11878. {
  11879. return parent::download($package, $path, $prevPackage, $output);
  11880. }
  11881. public function install(PackageInterface $package, $path, $output = true)
  11882. {
  11883. if ($output) {
  11884. $this->io->writeError(" - " . InstallOperation::format($package).": Extracting archive");
  11885. } else {
  11886. $this->io->writeError('Extracting archive', false);
  11887. }
  11888. $vendorDir = $this->config->get('vendor-dir');
  11889. if (false === strpos($this->filesystem->normalizePath($vendorDir), $this->filesystem->normalizePath($path).DIRECTORY_SEPARATOR)) {
  11890. $this->filesystem->emptyDirectory($path);
  11891. }
  11892. do {
  11893. $temporaryDir = $vendorDir.'/composer/'.substr(md5(uniqid('', true)), 0, 8);
  11894. } while (is_dir($temporaryDir));
  11895. $this->addCleanupPath($package, $temporaryDir);
  11896. $this->addCleanupPath($package, $path);
  11897. $this->filesystem->ensureDirectoryExists($temporaryDir);
  11898. $fileName = $this->getFileName($package, $path);
  11899. $filesystem = $this->filesystem;
  11900. $self = $this;
  11901. $cleanup = function () use ($path, $filesystem, $temporaryDir, $package, $self) {
  11902. $self->clearLastCacheWrite($package);
  11903. $filesystem->removeDirectory($path);
  11904. $filesystem->removeDirectory($temporaryDir);
  11905. $self->removeCleanupPath($package, $temporaryDir);
  11906. $self->removeCleanupPath($package, $path);
  11907. };
  11908. $promise = null;
  11909. try {
  11910. $promise = $this->extract($package, $fileName, $temporaryDir);
  11911. } catch (\Exception $e) {
  11912. $cleanup();
  11913. throw $e;
  11914. }
  11915. if (!$promise instanceof PromiseInterface) {
  11916. $promise = \React\Promise\resolve();
  11917. }
  11918. return $promise->then(function () use ($self, $package, $filesystem, $fileName, $temporaryDir, $path) {
  11919. $filesystem->unlink($fileName);
  11920. $getFolderContent = function ($dir) {
  11921. $finder = Finder::create()
  11922. ->ignoreVCS(false)
  11923. ->ignoreDotFiles(false)
  11924. ->notName('.DS_Store')
  11925. ->depth(0)
  11926. ->in($dir);
  11927. return iterator_to_array($finder);
  11928. };
  11929. $renameAsOne = false;
  11930. if (!file_exists($path) || ($filesystem->isDirEmpty($path) && $filesystem->removeDirectory($path))) {
  11931. $renameAsOne = true;
  11932. }
  11933. $contentDir = $getFolderContent($temporaryDir);
  11934. $singleDirAtTopLevel = 1 === count($contentDir) && is_dir(reset($contentDir));
  11935. if ($renameAsOne) {
  11936. if ($singleDirAtTopLevel) {
  11937. $extractedDir = (string) reset($contentDir);
  11938. } else {
  11939. $extractedDir = $temporaryDir;
  11940. }
  11941. $filesystem->rename($extractedDir, $path);
  11942. } else {
  11943. if ($singleDirAtTopLevel) {
  11944. $contentDir = $getFolderContent((string) reset($contentDir));
  11945. }
  11946. foreach ($contentDir as $file) {
  11947. $file = (string) $file;
  11948. $filesystem->rename($file, $path . '/' . basename($file));
  11949. }
  11950. }
  11951. $filesystem->removeDirectory($temporaryDir);
  11952. $self->removeCleanupPath($package, $temporaryDir);
  11953. $self->removeCleanupPath($package, $path);
  11954. }, function ($e) use ($cleanup) {
  11955. $cleanup();
  11956. throw $e;
  11957. });
  11958. }
  11959. abstract protected function extract(PackageInterface $package, $file, $path);
  11960. }
  11961. <?php
  11962. namespace Composer\Downloader;
  11963. use Composer\Package\PackageInterface;
  11964. interface ChangeReportInterface
  11965. {
  11966. public function getLocalChanges(PackageInterface $package, $path);
  11967. }
  11968. <?php
  11969. namespace Composer\Downloader;
  11970. use Composer\Package\PackageInterface;
  11971. use Composer\IO\IOInterface;
  11972. use Composer\Util\Filesystem;
  11973. use Composer\Exception\IrrecoverableDownloadException;
  11974. use React\Promise\PromiseInterface;
  11975. class DownloadManager
  11976. {
  11977. private $io;
  11978. private $preferDist = false;
  11979. private $preferSource;
  11980. private $packagePreferences = array();
  11981. private $filesystem;
  11982. private $downloaders = array();
  11983. public function __construct(IOInterface $io, $preferSource = false, Filesystem $filesystem = null)
  11984. {
  11985. $this->io = $io;
  11986. $this->preferSource = $preferSource;
  11987. $this->filesystem = $filesystem ?: new Filesystem();
  11988. }
  11989. public function setPreferSource($preferSource)
  11990. {
  11991. $this->preferSource = $preferSource;
  11992. return $this;
  11993. }
  11994. public function setPreferDist($preferDist)
  11995. {
  11996. $this->preferDist = $preferDist;
  11997. return $this;
  11998. }
  11999. public function setPreferences(array $preferences)
  12000. {
  12001. $this->packagePreferences = $preferences;
  12002. return $this;
  12003. }
  12004. public function setDownloader($type, DownloaderInterface $downloader)
  12005. {
  12006. $type = strtolower($type);
  12007. $this->downloaders[$type] = $downloader;
  12008. return $this;
  12009. }
  12010. public function getDownloader($type)
  12011. {
  12012. $type = strtolower($type);
  12013. if (!isset($this->downloaders[$type])) {
  12014. throw new \InvalidArgumentException(sprintf('Unknown downloader type: %s. Available types: %s.', $type, implode(', ', array_keys($this->downloaders))));
  12015. }
  12016. return $this->downloaders[$type];
  12017. }
  12018. public function getDownloaderForPackage(PackageInterface $package)
  12019. {
  12020. $installationSource = $package->getInstallationSource();
  12021. if ('metapackage' === $package->getType()) {
  12022. return;
  12023. }
  12024. if ('dist' === $installationSource) {
  12025. $downloader = $this->getDownloader($package->getDistType());
  12026. } elseif ('source' === $installationSource) {
  12027. $downloader = $this->getDownloader($package->getSourceType());
  12028. } else {
  12029. throw new \InvalidArgumentException(
  12030. 'Package '.$package.' does not have an installation source set'
  12031. );
  12032. }
  12033. if ($installationSource !== $downloader->getInstallationSource()) {
  12034. throw new \LogicException(sprintf(
  12035. 'Downloader "%s" is a %s type downloader and can not be used to download %s for package %s',
  12036. get_class($downloader),
  12037. $downloader->getInstallationSource(),
  12038. $installationSource,
  12039. $package
  12040. ));
  12041. }
  12042. return $downloader;
  12043. }
  12044. public function getDownloaderType(DownloaderInterface $downloader)
  12045. {
  12046. return array_search($downloader, $this->downloaders);
  12047. }
  12048. public function download(PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
  12049. {
  12050. $targetDir = $this->normalizeTargetDir($targetDir);
  12051. $this->filesystem->ensureDirectoryExists(dirname($targetDir));
  12052. $sources = $this->getAvailableSources($package, $prevPackage);
  12053. $io = $this->io;
  12054. $self = $this;
  12055. $download = function ($retry = false) use (&$sources, $io, $package, $self, $targetDir, &$download, $prevPackage) {
  12056. $source = array_shift($sources);
  12057. if ($retry) {
  12058. $io->writeError(' <warning>Now trying to download from ' . $source . '</warning>');
  12059. }
  12060. $package->setInstallationSource($source);
  12061. $downloader = $self->getDownloaderForPackage($package);
  12062. if (!$downloader) {
  12063. return \React\Promise\resolve();
  12064. }
  12065. $handleError = function ($e) use ($sources, $source, $package, $io, $download) {
  12066. if ($e instanceof \RuntimeException && !$e instanceof IrrecoverableDownloadException) {
  12067. if (!$sources) {
  12068. throw $e;
  12069. }
  12070. $io->writeError(
  12071. ' <warning>Failed to download '.
  12072. $package->getPrettyName().
  12073. ' from ' . $source . ': '.
  12074. $e->getMessage().'</warning>'
  12075. );
  12076. return $download(true);
  12077. }
  12078. throw $e;
  12079. };
  12080. try {
  12081. $result = $downloader->download($package, $targetDir, $prevPackage);
  12082. } catch (\Exception $e) {
  12083. return $handleError($e);
  12084. }
  12085. if (!$result instanceof PromiseInterface) {
  12086. return \React\Promise\resolve($result);
  12087. }
  12088. $res = $result->then(function ($res) {
  12089. return $res;
  12090. }, $handleError);
  12091. return $res;
  12092. };
  12093. return $download();
  12094. }
  12095. public function prepare($type, PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
  12096. {
  12097. $targetDir = $this->normalizeTargetDir($targetDir);
  12098. $downloader = $this->getDownloaderForPackage($package);
  12099. if ($downloader) {
  12100. return $downloader->prepare($type, $package, $targetDir, $prevPackage);
  12101. }
  12102. }
  12103. public function install(PackageInterface $package, $targetDir)
  12104. {
  12105. $targetDir = $this->normalizeTargetDir($targetDir);
  12106. $downloader = $this->getDownloaderForPackage($package);
  12107. if ($downloader) {
  12108. return $downloader->install($package, $targetDir);
  12109. }
  12110. }
  12111. public function update(PackageInterface $initial, PackageInterface $target, $targetDir)
  12112. {
  12113. $targetDir = $this->normalizeTargetDir($targetDir);
  12114. $downloader = $this->getDownloaderForPackage($target);
  12115. $initialDownloader = $this->getDownloaderForPackage($initial);
  12116. if (!$initialDownloader && !$downloader) {
  12117. return;
  12118. }
  12119. if (!$downloader) {
  12120. return $initialDownloader->remove($initial, $targetDir);
  12121. }
  12122. $initialType = $this->getDownloaderType($initialDownloader);
  12123. $targetType = $this->getDownloaderType($downloader);
  12124. if ($initialType === $targetType) {
  12125. try {
  12126. return $downloader->update($initial, $target, $targetDir);
  12127. } catch (\RuntimeException $e) {
  12128. if (!$this->io->isInteractive()) {
  12129. throw $e;
  12130. }
  12131. $this->io->writeError('<error> Update failed ('.$e->getMessage().')</error>');
  12132. if (!$this->io->askConfirmation(' Would you like to try reinstalling the package instead [<comment>yes</comment>]? ')) {
  12133. throw $e;
  12134. }
  12135. }
  12136. }
  12137. $promise = $initialDownloader->remove($initial, $targetDir);
  12138. if ($promise) {
  12139. $self = $this;
  12140. return $promise->then(function ($res) use ($self, $target, $targetDir) {
  12141. return $self->install($target, $targetDir);
  12142. });
  12143. }
  12144. return $this->install($target, $targetDir);
  12145. }
  12146. public function remove(PackageInterface $package, $targetDir)
  12147. {
  12148. $targetDir = $this->normalizeTargetDir($targetDir);
  12149. $downloader = $this->getDownloaderForPackage($package);
  12150. if ($downloader) {
  12151. return $downloader->remove($package, $targetDir);
  12152. }
  12153. }
  12154. public function cleanup($type, PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
  12155. {
  12156. $targetDir = $this->normalizeTargetDir($targetDir);
  12157. $downloader = $this->getDownloaderForPackage($package);
  12158. if ($downloader) {
  12159. return $downloader->cleanup($type, $package, $targetDir, $prevPackage);
  12160. }
  12161. }
  12162. protected function resolvePackageInstallPreference(PackageInterface $package)
  12163. {
  12164. foreach ($this->packagePreferences as $pattern => $preference) {
  12165. $pattern = '{^'.str_replace('\\*', '.*', preg_quote($pattern)).'$}i';
  12166. if (preg_match($pattern, $package->getName())) {
  12167. if ('dist' === $preference || (!$package->isDev() && 'auto' === $preference)) {
  12168. return 'dist';
  12169. }
  12170. return 'source';
  12171. }
  12172. }
  12173. return $package->isDev() ? 'source' : 'dist';
  12174. }
  12175. private function getAvailableSources(PackageInterface $package, PackageInterface $prevPackage = null)
  12176. {
  12177. $sourceType = $package->getSourceType();
  12178. $distType = $package->getDistType();
  12179. $sources = array();
  12180. if ($sourceType) {
  12181. $sources[] = 'source';
  12182. }
  12183. if ($distType) {
  12184. $sources[] = 'dist';
  12185. }
  12186. if (empty($sources)) {
  12187. throw new \InvalidArgumentException('Package '.$package.' must have a source or dist specified');
  12188. }
  12189. if (
  12190. $prevPackage
  12191. && in_array($prevPackage->getInstallationSource(), $sources, true)
  12192. && !(!$prevPackage->isDev() && $prevPackage->getInstallationSource() === 'dist' && $package->isDev())
  12193. ) {
  12194. $prevSource = $prevPackage->getInstallationSource();
  12195. usort($sources, function ($a, $b) use ($prevSource) {
  12196. return $a === $prevSource ? -1 : 1;
  12197. });
  12198. return $sources;
  12199. }
  12200. if (!$this->preferSource && ($this->preferDist || 'dist' === $this->resolvePackageInstallPreference($package))) {
  12201. $sources = array_reverse($sources);
  12202. }
  12203. return $sources;
  12204. }
  12205. private function normalizeTargetDir($dir)
  12206. {
  12207. if ($dir === '\\' || $dir === '/') {
  12208. return $dir;
  12209. }
  12210. return rtrim($dir, '\\/');
  12211. }
  12212. }
  12213. <?php
  12214. namespace Composer\Downloader;
  12215. use Composer\Package\PackageInterface;
  12216. use React\Promise\PromiseInterface;
  12217. interface DownloaderInterface
  12218. {
  12219. public function getInstallationSource();
  12220. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null);
  12221. public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null);
  12222. public function install(PackageInterface $package, $path);
  12223. public function update(PackageInterface $initial, PackageInterface $target, $path);
  12224. public function remove(PackageInterface $package, $path);
  12225. public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null);
  12226. }
  12227. <?php
  12228. namespace Composer\Downloader;
  12229. use Composer\Package\PackageInterface;
  12230. interface DvcsDownloaderInterface
  12231. {
  12232. public function getUnpushedChanges(PackageInterface $package, $path);
  12233. }
  12234. <?php
  12235. namespace Composer\Downloader;
  12236. use Composer\Config;
  12237. use Composer\Cache;
  12238. use Composer\Factory;
  12239. use Composer\IO\IOInterface;
  12240. use Composer\IO\NullIO;
  12241. use Composer\Package\Comparer\Comparer;
  12242. use Composer\DependencyResolver\Operation\UpdateOperation;
  12243. use Composer\DependencyResolver\Operation\InstallOperation;
  12244. use Composer\DependencyResolver\Operation\UninstallOperation;
  12245. use Composer\Package\PackageInterface;
  12246. use Composer\Package\Version\VersionParser;
  12247. use Composer\Plugin\PluginEvents;
  12248. use Composer\Plugin\PostFileDownloadEvent;
  12249. use Composer\Plugin\PreFileDownloadEvent;
  12250. use Composer\EventDispatcher\EventDispatcher;
  12251. use Composer\Util\Filesystem;
  12252. use Composer\Util\HttpDownloader;
  12253. use Composer\Util\Url as UrlUtil;
  12254. use Composer\Util\ProcessExecutor;
  12255. use Composer\Downloader\TransportException;
  12256. use React\Promise\PromiseInterface;
  12257. class FileDownloader implements DownloaderInterface, ChangeReportInterface
  12258. {
  12259. protected $io;
  12260. protected $config;
  12261. protected $httpDownloader;
  12262. protected $filesystem;
  12263. protected $cache;
  12264. protected $eventDispatcher;
  12265. protected $process;
  12266. public $lastCacheWrites = array();
  12267. private $additionalCleanupPaths = array();
  12268. public function __construct(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, Cache $cache = null, Filesystem $filesystem = null, ProcessExecutor $process = null)
  12269. {
  12270. $this->io = $io;
  12271. $this->config = $config;
  12272. $this->eventDispatcher = $eventDispatcher;
  12273. $this->httpDownloader = $httpDownloader;
  12274. $this->cache = $cache;
  12275. $this->process = $process ?: new ProcessExecutor($io);
  12276. $this->filesystem = $filesystem ?: new Filesystem($this->process);
  12277. if ($this->cache && $this->cache->gcIsNecessary()) {
  12278. $this->cache->gc($config->get('cache-files-ttl'), $config->get('cache-files-maxsize'));
  12279. }
  12280. }
  12281. public function getInstallationSource()
  12282. {
  12283. return 'dist';
  12284. }
  12285. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
  12286. {
  12287. if (!$package->getDistUrl()) {
  12288. throw new \InvalidArgumentException('The given package is missing url information');
  12289. }
  12290. $cacheKeyGenerator = function (PackageInterface $package, $key) {
  12291. $cacheKey = sha1($key);
  12292. return $package->getName().'/'.$cacheKey.'.'.$package->getDistType();
  12293. };
  12294. $retries = 3;
  12295. $urls = $package->getDistUrls();
  12296. foreach ($urls as $index => $url) {
  12297. $processedUrl = $this->processUrl($package, $url);
  12298. $urls[$index] = array(
  12299. 'base' => $url,
  12300. 'processed' => $processedUrl,
  12301. 'cacheKey' => $cacheKeyGenerator($package, $processedUrl)
  12302. );
  12303. }
  12304. $fileName = $this->getFileName($package, $path);
  12305. $this->filesystem->ensureDirectoryExists($path);
  12306. $this->filesystem->ensureDirectoryExists(dirname($fileName));
  12307. $io = $this->io;
  12308. $cache = $this->cache;
  12309. $httpDownloader = $this->httpDownloader;
  12310. $eventDispatcher = $this->eventDispatcher;
  12311. $filesystem = $this->filesystem;
  12312. $self = $this;
  12313. $accept = null;
  12314. $reject = null;
  12315. $download = function () use ($io, $output, $httpDownloader, $cache, $cacheKeyGenerator, $eventDispatcher, $package, $fileName, &$urls, &$accept, &$reject) {
  12316. $url = reset($urls);
  12317. $index = key($urls);
  12318. if ($eventDispatcher) {
  12319. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $httpDownloader, $url['processed'], 'package', $package);
  12320. $eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  12321. if ($preFileDownloadEvent->getCustomCacheKey() !== null) {
  12322. $url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getCustomCacheKey());
  12323. } else if ($preFileDownloadEvent->getProcessedUrl() !== $url['processed']) {
  12324. $url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getProcessedUrl());
  12325. }
  12326. $url['processed'] = $preFileDownloadEvent->getProcessedUrl();
  12327. }
  12328. $urls[$index] = $url;
  12329. $checksum = $package->getDistSha1Checksum();
  12330. $cacheKey = $url['cacheKey'];
  12331. if ($cache && (!$checksum || $checksum === $cache->sha1($cacheKey)) && $cache->copyTo($cacheKey, $fileName)) {
  12332. if ($output) {
  12333. $io->writeError(" - Loading <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>) from cache", true, IOInterface::VERY_VERBOSE);
  12334. }
  12335. $result = \React\Promise\resolve($fileName);
  12336. } else {
  12337. if ($output) {
  12338. $io->writeError(" - Downloading <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
  12339. }
  12340. $result = $httpDownloader->addCopy($url['processed'], $fileName, $package->getTransportOptions())
  12341. ->then($accept, $reject);
  12342. }
  12343. return $result->then(function ($result) use ($fileName, $checksum, $url, $package, $eventDispatcher) {
  12344. if (null === $result) {
  12345. return $fileName;
  12346. }
  12347. if (!file_exists($fileName)) {
  12348. throw new \UnexpectedValueException($url['base'].' could not be saved to '.$fileName.', make sure the'
  12349. .' directory is writable and you have internet connectivity');
  12350. }
  12351. if ($checksum && hash_file('sha1', $fileName) !== $checksum) {
  12352. throw new \UnexpectedValueException('The checksum verification of the file failed (downloaded from '.$url['base'].')');
  12353. }
  12354. if ($eventDispatcher) {
  12355. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, $fileName, $checksum, $url['processed'], $package);
  12356. $eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  12357. }
  12358. return $fileName;
  12359. });
  12360. };
  12361. $accept = function ($response) use ($cache, $package, $fileName, $self, &$urls) {
  12362. $url = reset($urls);
  12363. $cacheKey = $url['cacheKey'];
  12364. if ($cache && !$cache->isReadOnly()) {
  12365. $self->lastCacheWrites[$package->getName()] = $cacheKey;
  12366. $cache->copyFrom($cacheKey, $fileName);
  12367. }
  12368. $response->collect();
  12369. return $fileName;
  12370. };
  12371. $reject = function ($e) use ($io, &$urls, $download, $fileName, $package, &$retries, $filesystem, $self) {
  12372. if (file_exists($fileName)) {
  12373. $filesystem->unlink($fileName);
  12374. }
  12375. $self->clearLastCacheWrite($package);
  12376. if ($e instanceof TransportException) {
  12377. if ((0 !== $e->getCode() && !in_array($e->getCode(), array(500, 502, 503, 504))) || !$retries) {
  12378. $retries = 0;
  12379. }
  12380. }
  12381. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  12382. $retries = 0;
  12383. $urls = array();
  12384. }
  12385. if ($retries) {
  12386. usleep(500000);
  12387. $retries--;
  12388. return $download();
  12389. }
  12390. array_shift($urls);
  12391. if ($urls) {
  12392. if ($io->isDebug()) {
  12393. $io->writeError(' Failed downloading '.$package->getName().': ['.get_class($e).'] '.$e->getCode().': '.$e->getMessage());
  12394. $io->writeError(' Trying the next URL for '.$package->getName());
  12395. } elseif (count($urls)) {
  12396. $io->writeError(' Failed downloading '.$package->getName().', trying the next URL ('.$e->getCode().': '.$e->getMessage().')');
  12397. }
  12398. $retries = 3;
  12399. usleep(100000);
  12400. return $download();
  12401. }
  12402. throw $e;
  12403. };
  12404. return $download();
  12405. }
  12406. public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  12407. {
  12408. }
  12409. public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  12410. {
  12411. $fileName = $this->getFileName($package, $path);
  12412. if (file_exists($fileName)) {
  12413. $this->filesystem->unlink($fileName);
  12414. }
  12415. $dirsToCleanUp = array(
  12416. $this->config->get('vendor-dir').'/composer/',
  12417. $this->config->get('vendor-dir'),
  12418. $path,
  12419. );
  12420. if (isset($this->additionalCleanupPaths[$package->getName()])) {
  12421. foreach ($this->additionalCleanupPaths[$package->getName()] as $path) {
  12422. $this->filesystem->remove($path);
  12423. }
  12424. }
  12425. foreach ($dirsToCleanUp as $dir) {
  12426. if (is_dir($dir) && $this->filesystem->isDirEmpty($dir)) {
  12427. $this->filesystem->removeDirectory($dir);
  12428. }
  12429. }
  12430. }
  12431. public function install(PackageInterface $package, $path, $output = true)
  12432. {
  12433. if ($output) {
  12434. $this->io->writeError(" - " . InstallOperation::format($package));
  12435. }
  12436. $this->filesystem->emptyDirectory($path);
  12437. $this->filesystem->ensureDirectoryExists($path);
  12438. $this->filesystem->rename($this->getFileName($package, $path), $path . pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_BASENAME));
  12439. }
  12440. public function clearLastCacheWrite(PackageInterface $package)
  12441. {
  12442. if ($this->cache && isset($this->lastCacheWrites[$package->getName()])) {
  12443. $this->cache->remove($this->lastCacheWrites[$package->getName()]);
  12444. unset($this->lastCacheWrites[$package->getName()]);
  12445. }
  12446. }
  12447. public function addCleanupPath(PackageInterface $package, $path)
  12448. {
  12449. $this->additionalCleanupPaths[$package->getName()][] = $path;
  12450. }
  12451. public function removeCleanupPath(PackageInterface $package, $path)
  12452. {
  12453. if (isset($this->additionalCleanupPaths[$package->getName()])) {
  12454. $idx = array_search($path, $this->additionalCleanupPaths[$package->getName()]);
  12455. if (false !== $idx) {
  12456. unset($this->additionalCleanupPaths[$package->getName()][$idx]);
  12457. }
  12458. }
  12459. }
  12460. public function update(PackageInterface $initial, PackageInterface $target, $path)
  12461. {
  12462. $this->io->writeError(" - " . UpdateOperation::format($initial, $target) . ": ", false);
  12463. $promise = $this->remove($initial, $path, false);
  12464. if ($promise === null || !$promise instanceof PromiseInterface) {
  12465. $promise = \React\Promise\resolve();
  12466. }
  12467. $self = $this;
  12468. $io = $this->io;
  12469. return $promise->then(function () use ($self, $target, $path, $io) {
  12470. $promise = $self->install($target, $path, false);
  12471. $io->writeError('');
  12472. return $promise;
  12473. });
  12474. }
  12475. public function remove(PackageInterface $package, $path, $output = true)
  12476. {
  12477. if ($output) {
  12478. $this->io->writeError(" - " . UninstallOperation::format($package));
  12479. }
  12480. if (!$this->filesystem->removeDirectory($path)) {
  12481. throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
  12482. }
  12483. }
  12484. protected function getFileName(PackageInterface $package, $path)
  12485. {
  12486. 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), '.');
  12487. }
  12488. protected function processUrl(PackageInterface $package, $url)
  12489. {
  12490. if (!extension_loaded('openssl') && 0 === strpos($url, 'https:')) {
  12491. throw new \RuntimeException('You must enable the openssl extension to download files via https');
  12492. }
  12493. if ($package->getDistReference()) {
  12494. $url = UrlUtil::updateDistReference($this->config, $url, $package->getDistReference());
  12495. }
  12496. return $url;
  12497. }
  12498. public function getLocalChanges(PackageInterface $package, $targetDir)
  12499. {
  12500. $prevIO = $this->io;
  12501. $this->io = new NullIO;
  12502. $this->io->loadConfiguration($this->config);
  12503. $e = null;
  12504. $output = '';
  12505. try {
  12506. if (is_dir($targetDir.'_compare')) {
  12507. $this->filesystem->removeDirectory($targetDir.'_compare');
  12508. }
  12509. $this->download($package, $targetDir.'_compare', null, false);
  12510. $this->httpDownloader->wait();
  12511. $this->install($package, $targetDir.'_compare', false);
  12512. $this->process->wait();
  12513. $comparer = new Comparer();
  12514. $comparer->setSource($targetDir.'_compare');
  12515. $comparer->setUpdate($targetDir);
  12516. $comparer->doCompare();
  12517. $output = $comparer->getChanged(true, true);
  12518. $this->filesystem->removeDirectory($targetDir.'_compare');
  12519. } catch (\Exception $e) {
  12520. }
  12521. $this->io = $prevIO;
  12522. if ($e) {
  12523. throw $e;
  12524. }
  12525. return trim($output);
  12526. }
  12527. }
  12528. <?php
  12529. namespace Composer\Downloader;
  12530. class FilesystemException extends \Exception
  12531. {
  12532. public function __construct($message = '', $code = 0, \Exception $previous = null)
  12533. {
  12534. parent::__construct("Filesystem exception: \n".$message, $code, $previous);
  12535. }
  12536. }
  12537. <?php
  12538. namespace Composer\Downloader;
  12539. use Composer\Package\PackageInterface;
  12540. use Composer\Util\ProcessExecutor;
  12541. class FossilDownloader extends VcsDownloader
  12542. {
  12543. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  12544. {
  12545. }
  12546. protected function doInstall(PackageInterface $package, $path, $url)
  12547. {
  12548. $this->config->prohibitUrlByConfig($url, $this->io);
  12549. $url = ProcessExecutor::escape($url);
  12550. $ref = ProcessExecutor::escape($package->getSourceReference());
  12551. $repoFile = $path . '.fossil';
  12552. $this->io->writeError("Cloning ".$package->getSourceReference());
  12553. $command = sprintf('fossil clone %s %s', $url, ProcessExecutor::escape($repoFile));
  12554. if (0 !== $this->process->execute($command, $ignoredOutput)) {
  12555. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12556. }
  12557. $command = sprintf('fossil open %s --nested', ProcessExecutor::escape($repoFile));
  12558. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  12559. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12560. }
  12561. $command = sprintf('fossil update %s', $ref);
  12562. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  12563. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12564. }
  12565. }
  12566. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  12567. {
  12568. $this->config->prohibitUrlByConfig($url, $this->io);
  12569. $ref = ProcessExecutor::escape($target->getSourceReference());
  12570. $this->io->writeError(" Updating to ".$target->getSourceReference());
  12571. if (!$this->hasMetadataRepository($path)) {
  12572. throw new \RuntimeException('The .fslckout file is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  12573. }
  12574. $command = sprintf('fossil pull && fossil up %s', $ref);
  12575. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  12576. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12577. }
  12578. }
  12579. public function getLocalChanges(PackageInterface $package, $path)
  12580. {
  12581. if (!$this->hasMetadataRepository($path)) {
  12582. return null;
  12583. }
  12584. $this->process->execute('fossil changes', $output, realpath($path));
  12585. return trim($output) ?: null;
  12586. }
  12587. protected function getCommitLogs($fromReference, $toReference, $path)
  12588. {
  12589. $command = sprintf('fossil timeline -t ci -W 0 -n 0 before %s', ProcessExecutor::escape($toReference));
  12590. if (0 !== $this->process->execute($command, $output, realpath($path))) {
  12591. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12592. }
  12593. $log = '';
  12594. $match = '/\d\d:\d\d:\d\d\s+\[' . $toReference . '\]/';
  12595. foreach ($this->process->splitLines($output) as $line) {
  12596. if (preg_match($match, $line)) {
  12597. break;
  12598. }
  12599. $log .= $line;
  12600. }
  12601. return $log;
  12602. }
  12603. protected function hasMetadataRepository($path)
  12604. {
  12605. return is_file($path . '/.fslckout') || is_file($path . '/_FOSSIL_');
  12606. }
  12607. }
  12608. <?php
  12609. namespace Composer\Downloader;
  12610. use Composer\Config;
  12611. use Composer\IO\IOInterface;
  12612. use Composer\Package\PackageInterface;
  12613. use Composer\Util\Filesystem;
  12614. use Composer\Util\Git as GitUtil;
  12615. use Composer\Util\Url;
  12616. use Composer\Util\Platform;
  12617. use Composer\Util\ProcessExecutor;
  12618. use Composer\Cache;
  12619. class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
  12620. {
  12621. private $hasStashedChanges = array();
  12622. private $hasDiscardedChanges = array();
  12623. private $gitUtil;
  12624. private $cachedPackages = array();
  12625. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, Filesystem $fs = null)
  12626. {
  12627. parent::__construct($io, $config, $process, $fs);
  12628. $this->gitUtil = new GitUtil($this->io, $this->config, $this->process, $this->filesystem);
  12629. }
  12630. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  12631. {
  12632. GitUtil::cleanEnv();
  12633. $cachePath = $this->config->get('cache-vcs-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $url).'/';
  12634. $gitVersion = GitUtil::getVersion($this->process);
  12635. if ($gitVersion && version_compare($gitVersion, '2.3.0-rc0', '>=') && Cache::isUsable($cachePath)) {
  12636. $this->io->writeError(" - Syncing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>) into cache");
  12637. $this->io->writeError(sprintf(' Cloning to cache at %s', ProcessExecutor::escape($cachePath)), true, IOInterface::DEBUG);
  12638. $ref = $package->getSourceReference();
  12639. if ($this->gitUtil->fetchRefOrSyncMirror($url, $cachePath, $ref) && is_dir($cachePath)) {
  12640. $this->cachedPackages[$package->getId()][$ref] = true;
  12641. }
  12642. }
  12643. }
  12644. protected function doInstall(PackageInterface $package, $path, $url)
  12645. {
  12646. GitUtil::cleanEnv();
  12647. $path = $this->normalizePath($path);
  12648. $cachePath = $this->config->get('cache-vcs-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $url).'/';
  12649. $ref = $package->getSourceReference();
  12650. $flag = Platform::isWindows() ? '/D ' : '';
  12651. if (!empty($this->cachedPackages[$package->getId()][$ref])) {
  12652. $msg = "Cloning ".$this->getShortHash($ref).' from cache';
  12653. $command =
  12654. 'git clone --no-checkout %cachePath% %path% --dissociate --reference %cachePath% '
  12655. . '&& cd '.$flag.'%path% '
  12656. . '&& git remote set-url origin %sanitizedUrl% && git remote add composer %sanitizedUrl%';
  12657. } else {
  12658. $msg = "Cloning ".$this->getShortHash($ref);
  12659. $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%';
  12660. if (getenv('COMPOSER_DISABLE_NETWORK')) {
  12661. throw new \RuntimeException('The required git reference for '.$package->getName().' is not in cache and network is disabled, aborting');
  12662. }
  12663. }
  12664. $this->io->writeError($msg);
  12665. $commandCallable = function ($url) use ($path, $command, $cachePath) {
  12666. return str_replace(
  12667. array('%url%', '%path%', '%cachePath%', '%sanitizedUrl%'),
  12668. array(
  12669. ProcessExecutor::escape($url),
  12670. ProcessExecutor::escape($path),
  12671. ProcessExecutor::escape($cachePath),
  12672. ProcessExecutor::escape(preg_replace('{://([^@]+?):(.+?)@}', '://', $url)),
  12673. ),
  12674. $command
  12675. );
  12676. };
  12677. $this->gitUtil->runCommand($commandCallable, $url, $path, true);
  12678. if ($url !== $package->getSourceUrl()) {
  12679. $this->updateOriginUrl($path, $package->getSourceUrl());
  12680. } else {
  12681. $this->setPushUrl($path, $url);
  12682. }
  12683. if ($newRef = $this->updateToCommit($path, $ref, $package->getPrettyVersion(), $package->getReleaseDate())) {
  12684. if ($package->getDistReference() === $package->getSourceReference()) {
  12685. $package->setDistReference($newRef);
  12686. }
  12687. $package->setSourceReference($newRef);
  12688. }
  12689. }
  12690. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  12691. {
  12692. GitUtil::cleanEnv();
  12693. $path = $this->normalizePath($path);
  12694. if (!$this->hasMetadataRepository($path)) {
  12695. throw new \RuntimeException('The .git directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  12696. }
  12697. $cachePath = $this->config->get('cache-vcs-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $url).'/';
  12698. $ref = $target->getSourceReference();
  12699. if (!empty($this->cachedPackages[$target->getId()][$ref])) {
  12700. $msg = "Checking out ".$this->getShortHash($ref).' from cache';
  12701. $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%';
  12702. } else {
  12703. $msg = "Checking out ".$this->getShortHash($ref);
  12704. $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%';
  12705. if (getenv('COMPOSER_DISABLE_NETWORK')) {
  12706. throw new \RuntimeException('The required git reference for '.$target->getName().' is not in cache and network is disabled, aborting');
  12707. }
  12708. }
  12709. $this->io->writeError($msg);
  12710. $commandCallable = function ($url) use ($ref, $command, $cachePath) {
  12711. return str_replace(
  12712. array('%url%', '%ref%', '%cachePath%', '%sanitizedUrl%'),
  12713. array(
  12714. ProcessExecutor::escape($url),
  12715. ProcessExecutor::escape($ref.'^{commit}'),
  12716. ProcessExecutor::escape($cachePath),
  12717. ProcessExecutor::escape(preg_replace('{://([^@]+?):(.+?)@}', '://', $url)),
  12718. ),
  12719. $command
  12720. );
  12721. };
  12722. $this->gitUtil->runCommand($commandCallable, $url, $path);
  12723. if ($newRef = $this->updateToCommit($path, $ref, $target->getPrettyVersion(), $target->getReleaseDate())) {
  12724. if ($target->getDistReference() === $target->getSourceReference()) {
  12725. $target->setDistReference($newRef);
  12726. }
  12727. $target->setSourceReference($newRef);
  12728. }
  12729. $updateOriginUrl = false;
  12730. if (
  12731. 0 === $this->process->execute('git remote -v', $output, $path)
  12732. && preg_match('{^origin\s+(?P<url>\S+)}m', $output, $originMatch)
  12733. && preg_match('{^composer\s+(?P<url>\S+)}m', $output, $composerMatch)
  12734. ) {
  12735. if ($originMatch['url'] === $composerMatch['url'] && $composerMatch['url'] !== $target->getSourceUrl()) {
  12736. $updateOriginUrl = true;
  12737. }
  12738. }
  12739. if ($updateOriginUrl) {
  12740. $this->updateOriginUrl($path, $target->getSourceUrl());
  12741. }
  12742. }
  12743. public function getLocalChanges(PackageInterface $package, $path)
  12744. {
  12745. GitUtil::cleanEnv();
  12746. if (!$this->hasMetadataRepository($path)) {
  12747. return;
  12748. }
  12749. $command = 'git status --porcelain --untracked-files=no';
  12750. if (0 !== $this->process->execute($command, $output, $path)) {
  12751. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12752. }
  12753. return trim($output) ?: null;
  12754. }
  12755. public function getUnpushedChanges(PackageInterface $package, $path)
  12756. {
  12757. GitUtil::cleanEnv();
  12758. $path = $this->normalizePath($path);
  12759. if (!$this->hasMetadataRepository($path)) {
  12760. return;
  12761. }
  12762. $command = 'git show-ref --head -d';
  12763. if (0 !== $this->process->execute($command, $output, $path)) {
  12764. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12765. }
  12766. $refs = trim($output);
  12767. if (!preg_match('{^([a-f0-9]+) HEAD$}mi', $refs, $match)) {
  12768. return;
  12769. }
  12770. $headRef = $match[1];
  12771. if (!preg_match_all('{^'.$headRef.' refs/heads/(.+)$}mi', $refs, $matches)) {
  12772. return;
  12773. }
  12774. $branch = $matches[1][0];
  12775. $unpushedChanges = null;
  12776. for ($i = 0; $i <= 1; $i++) {
  12777. foreach ($matches[1] as $candidate) {
  12778. if (preg_match('{^[a-f0-9]+ refs/remotes/((?:composer|origin)/'.preg_quote($candidate).')$}mi', $refs, $match)) {
  12779. $branch = $candidate;
  12780. $remoteBranch = $match[1];
  12781. break;
  12782. }
  12783. }
  12784. if (!isset($remoteBranch)) {
  12785. $unpushedChanges = 'Branch ' . $branch . ' could not be found on the origin remote and appears to be unpushed';
  12786. } else {
  12787. $command = sprintf('git diff --name-status %s...%s --', $remoteBranch, $branch);
  12788. if (0 !== $this->process->execute($command, $output, $path)) {
  12789. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12790. }
  12791. $unpushedChanges = trim($output) ?: null;
  12792. }
  12793. if ($unpushedChanges && $i === 0) {
  12794. $this->process->execute('git fetch composer && git fetch origin', $output, $path);
  12795. }
  12796. if (!$unpushedChanges) {
  12797. break;
  12798. }
  12799. }
  12800. return $unpushedChanges;
  12801. }
  12802. protected function cleanChanges(PackageInterface $package, $path, $update)
  12803. {
  12804. GitUtil::cleanEnv();
  12805. $path = $this->normalizePath($path);
  12806. $unpushed = $this->getUnpushedChanges($package, $path);
  12807. if ($unpushed && ($this->io->isInteractive() || $this->config->get('discard-changes') !== true)) {
  12808. throw new \RuntimeException('Source directory ' . $path . ' has unpushed changes on the current branch: '."\n".$unpushed);
  12809. }
  12810. if (!$changes = $this->getLocalChanges($package, $path)) {
  12811. return;
  12812. }
  12813. if (!$this->io->isInteractive()) {
  12814. $discardChanges = $this->config->get('discard-changes');
  12815. if (true === $discardChanges) {
  12816. return $this->discardChanges($path);
  12817. }
  12818. if ('stash' === $discardChanges) {
  12819. if (!$update) {
  12820. return parent::cleanChanges($package, $path, $update);
  12821. }
  12822. return $this->stashChanges($path);
  12823. }
  12824. return parent::cleanChanges($package, $path, $update);
  12825. }
  12826. $changes = array_map(function ($elem) {
  12827. return ' '.$elem;
  12828. }, preg_split('{\s*\r?\n\s*}', $changes));
  12829. $this->io->writeError(' <error>'.$package->getPrettyName().' has modified files:</error>');
  12830. $this->io->writeError(array_slice($changes, 0, 10));
  12831. if (count($changes) > 10) {
  12832. $this->io->writeError(' <info>' . (count($changes) - 10) . ' more files modified, choose "v" to view the full list</info>');
  12833. }
  12834. while (true) {
  12835. switch ($this->io->ask(' <info>Discard changes [y,n,v,d,'.($update ? 's,' : '').'?]?</info> ', '?')) {
  12836. case 'y':
  12837. $this->discardChanges($path);
  12838. break 2;
  12839. case 's':
  12840. if (!$update) {
  12841. goto help;
  12842. }
  12843. $this->stashChanges($path);
  12844. break 2;
  12845. case 'n':
  12846. throw new \RuntimeException('Update aborted');
  12847. case 'v':
  12848. $this->io->writeError($changes);
  12849. break;
  12850. case 'd':
  12851. $this->viewDiff($path);
  12852. break;
  12853. case '?':
  12854. default:
  12855. help:
  12856. $this->io->writeError(array(
  12857. ' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
  12858. ' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
  12859. ' v - view modified files',
  12860. ' d - view local modifications (diff)',
  12861. ));
  12862. if ($update) {
  12863. $this->io->writeError(' s - stash changes and try to reapply them after the update');
  12864. }
  12865. $this->io->writeError(' ? - print help');
  12866. break;
  12867. }
  12868. }
  12869. }
  12870. protected function reapplyChanges($path)
  12871. {
  12872. $path = $this->normalizePath($path);
  12873. if (!empty($this->hasStashedChanges[$path])) {
  12874. unset($this->hasStashedChanges[$path]);
  12875. $this->io->writeError(' <info>Re-applying stashed changes</info>');
  12876. if (0 !== $this->process->execute('git stash pop', $output, $path)) {
  12877. throw new \RuntimeException("Failed to apply stashed changes:\n\n".$this->process->getErrorOutput());
  12878. }
  12879. }
  12880. unset($this->hasDiscardedChanges[$path]);
  12881. }
  12882. protected function updateToCommit($path, $reference, $branch, $date)
  12883. {
  12884. $force = !empty($this->hasDiscardedChanges[$path]) || !empty($this->hasStashedChanges[$path]) ? '-f ' : '';
  12885. $template = 'git checkout '.$force.'%s -- && git reset --hard %1$s --';
  12886. $branch = preg_replace('{(?:^dev-|(?:\.x)?-dev$)}i', '', $branch);
  12887. $branches = null;
  12888. if (0 === $this->process->execute('git branch -r', $output, $path)) {
  12889. $branches = $output;
  12890. }
  12891. $gitRef = $reference;
  12892. if (!preg_match('{^[a-f0-9]{40}$}', $reference)
  12893. && $branches
  12894. && preg_match('{^\s+composer/'.preg_quote($reference).'$}m', $branches)
  12895. ) {
  12896. $command = sprintf('git checkout '.$force.'-B %s %s -- && git reset --hard %2$s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$reference));
  12897. if (0 === $this->process->execute($command, $output, $path)) {
  12898. return null;
  12899. }
  12900. }
  12901. if (preg_match('{^[a-f0-9]{40}$}', $reference)) {
  12902. if (!preg_match('{^\s+composer/'.preg_quote($branch).'$}m', $branches) && preg_match('{^\s+composer/v'.preg_quote($branch).'$}m', $branches)) {
  12903. $branch = 'v' . $branch;
  12904. }
  12905. $command = sprintf('git checkout %s --', ProcessExecutor::escape($branch));
  12906. $fallbackCommand = sprintf('git checkout '.$force.'-B %s %s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$branch));
  12907. if (0 === $this->process->execute($command, $output, $path)
  12908. || 0 === $this->process->execute($fallbackCommand, $output, $path)
  12909. ) {
  12910. $command = sprintf('git reset --hard %s --', ProcessExecutor::escape($reference));
  12911. if (0 === $this->process->execute($command, $output, $path)) {
  12912. return null;
  12913. }
  12914. }
  12915. }
  12916. $command = sprintf($template, ProcessExecutor::escape($gitRef));
  12917. if (0 === $this->process->execute($command, $output, $path)) {
  12918. return null;
  12919. }
  12920. if (false !== strpos($this->process->getErrorOutput(), $reference)) {
  12921. $this->io->writeError(' <warning>'.$reference.' is gone (history was rewritten?)</warning>');
  12922. }
  12923. throw new \RuntimeException(Url::sanitize('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()));
  12924. }
  12925. protected function updateOriginUrl($path, $url)
  12926. {
  12927. $this->process->execute(sprintf('git remote set-url origin %s', ProcessExecutor::escape($url)), $output, $path);
  12928. $this->setPushUrl($path, $url);
  12929. }
  12930. protected function setPushUrl($path, $url)
  12931. {
  12932. if (preg_match('{^(?:https?|git)://'.GitUtil::getGitHubDomainsRegex($this->config).'/([^/]+)/([^/]+?)(?:\.git)?$}', $url, $match)) {
  12933. $protocols = $this->config->get('github-protocols');
  12934. $pushUrl = 'git@'.$match[1].':'.$match[2].'/'.$match[3].'.git';
  12935. if (!in_array('ssh', $protocols, true)) {
  12936. $pushUrl = 'https://' . $match[1] . '/'.$match[2].'/'.$match[3].'.git';
  12937. }
  12938. $cmd = sprintf('git remote set-url --push origin %s', ProcessExecutor::escape($pushUrl));
  12939. $this->process->execute($cmd, $ignoredOutput, $path);
  12940. }
  12941. }
  12942. protected function getCommitLogs($fromReference, $toReference, $path)
  12943. {
  12944. $path = $this->normalizePath($path);
  12945. $command = sprintf('git log %s..%s --pretty=format:"%%h - %%an: %%s"'.GitUtil::getNoShowSignatureFlag($this->process), ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
  12946. if (0 !== $this->process->execute($command, $output, $path)) {
  12947. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12948. }
  12949. return $output;
  12950. }
  12951. protected function discardChanges($path)
  12952. {
  12953. $path = $this->normalizePath($path);
  12954. if (0 !== $this->process->execute('git clean -df && git reset --hard', $output, $path)) {
  12955. throw new \RuntimeException("Could not reset changes\n\n:".$this->process->getErrorOutput());
  12956. }
  12957. $this->hasDiscardedChanges[$path] = true;
  12958. }
  12959. protected function stashChanges($path)
  12960. {
  12961. $path = $this->normalizePath($path);
  12962. if (0 !== $this->process->execute('git stash --include-untracked', $output, $path)) {
  12963. throw new \RuntimeException("Could not stash changes\n\n:".$this->process->getErrorOutput());
  12964. }
  12965. $this->hasStashedChanges[$path] = true;
  12966. }
  12967. protected function viewDiff($path)
  12968. {
  12969. $path = $this->normalizePath($path);
  12970. if (0 !== $this->process->execute('git diff HEAD', $output, $path)) {
  12971. throw new \RuntimeException("Could not view diff\n\n:".$this->process->getErrorOutput());
  12972. }
  12973. $this->io->writeError($output);
  12974. }
  12975. protected function normalizePath($path)
  12976. {
  12977. if (Platform::isWindows() && strlen($path) > 0) {
  12978. $basePath = $path;
  12979. $removed = array();
  12980. while (!is_dir($basePath) && $basePath !== '\\') {
  12981. array_unshift($removed, basename($basePath));
  12982. $basePath = dirname($basePath);
  12983. }
  12984. if ($basePath === '\\') {
  12985. return $path;
  12986. }
  12987. $path = rtrim(realpath($basePath) . '/' . implode('/', $removed), '/');
  12988. }
  12989. return $path;
  12990. }
  12991. protected function hasMetadataRepository($path)
  12992. {
  12993. $path = $this->normalizePath($path);
  12994. return is_dir($path.'/.git');
  12995. }
  12996. protected function getShortHash($reference)
  12997. {
  12998. if (!$this->io->isVerbose() && preg_match('{^[0-9a-f]{40}$}', $reference)) {
  12999. return substr($reference, 0, 10);
  13000. }
  13001. return $reference;
  13002. }
  13003. }
  13004. <?php
  13005. namespace Composer\Downloader;
  13006. use Composer\Config;
  13007. use Composer\Cache;
  13008. use Composer\EventDispatcher\EventDispatcher;
  13009. use Composer\Package\PackageInterface;
  13010. use Composer\Util\Platform;
  13011. use Composer\Util\ProcessExecutor;
  13012. use Composer\Util\HttpDownloader;
  13013. use Composer\IO\IOInterface;
  13014. use Composer\Util\Filesystem;
  13015. class GzipDownloader extends ArchiveDownloader
  13016. {
  13017. protected function extract(PackageInterface $package, $file, $path)
  13018. {
  13019. $filename = pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_FILENAME);
  13020. $targetFilepath = $path . DIRECTORY_SEPARATOR . $filename;
  13021. if (!Platform::isWindows()) {
  13022. $command = 'gzip -cd ' . ProcessExecutor::escape($file) . ' > ' . ProcessExecutor::escape($targetFilepath);
  13023. if (0 === $this->process->execute($command, $ignoredOutput)) {
  13024. return;
  13025. }
  13026. if (extension_loaded('zlib')) {
  13027. $this->extractUsingExt($file, $targetFilepath);
  13028. return;
  13029. }
  13030. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  13031. throw new \RuntimeException($processError);
  13032. }
  13033. $this->extractUsingExt($file, $targetFilepath);
  13034. }
  13035. private function extractUsingExt($file, $targetFilepath)
  13036. {
  13037. $archiveFile = gzopen($file, 'rb');
  13038. $targetFile = fopen($targetFilepath, 'wb');
  13039. while ($string = gzread($archiveFile, 4096)) {
  13040. fwrite($targetFile, $string, Platform::strlen($string));
  13041. }
  13042. gzclose($archiveFile);
  13043. fclose($targetFile);
  13044. }
  13045. }
  13046. <?php
  13047. namespace Composer\Downloader;
  13048. use Composer\Package\PackageInterface;
  13049. use Composer\Util\ProcessExecutor;
  13050. use Composer\Util\Hg as HgUtils;
  13051. class HgDownloader extends VcsDownloader
  13052. {
  13053. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  13054. {
  13055. }
  13056. protected function doInstall(PackageInterface $package, $path, $url)
  13057. {
  13058. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  13059. $cloneCommand = function ($url) use ($path) {
  13060. return sprintf('hg clone %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($path));
  13061. };
  13062. $hgUtils->runCommand($cloneCommand, $url, $path);
  13063. $ref = ProcessExecutor::escape($package->getSourceReference());
  13064. $command = sprintf('hg up %s', $ref);
  13065. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  13066. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13067. }
  13068. }
  13069. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  13070. {
  13071. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  13072. $ref = $target->getSourceReference();
  13073. $this->io->writeError(" Updating to ".$target->getSourceReference());
  13074. if (!$this->hasMetadataRepository($path)) {
  13075. throw new \RuntimeException('The .hg directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  13076. }
  13077. $command = function ($url) use ($ref) {
  13078. return sprintf('hg pull %s && hg up %s', ProcessExecutor::escape($url), ProcessExecutor::escape($ref));
  13079. };
  13080. $hgUtils->runCommand($command, $url, $path);
  13081. }
  13082. public function getLocalChanges(PackageInterface $package, $path)
  13083. {
  13084. if (!is_dir($path.'/.hg')) {
  13085. return null;
  13086. }
  13087. $this->process->execute('hg st', $output, realpath($path));
  13088. return trim($output) ?: null;
  13089. }
  13090. protected function getCommitLogs($fromReference, $toReference, $path)
  13091. {
  13092. $command = sprintf('hg log -r %s:%s --style compact', ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
  13093. if (0 !== $this->process->execute($command, $output, realpath($path))) {
  13094. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13095. }
  13096. return $output;
  13097. }
  13098. protected function hasMetadataRepository($path)
  13099. {
  13100. return is_dir($path . '/.hg');
  13101. }
  13102. }
  13103. <?php
  13104. namespace Composer\Downloader;
  13105. class MaxFileSizeExceededException extends TransportException
  13106. {
  13107. }
  13108. <?php
  13109. namespace Composer\Downloader;
  13110. use Composer\Package\Archiver\ArchivableFilesFinder;
  13111. use Composer\Package\Dumper\ArrayDumper;
  13112. use Composer\Package\PackageInterface;
  13113. use Composer\Package\Version\VersionGuesser;
  13114. use Composer\Package\Version\VersionParser;
  13115. use Composer\Util\Platform;
  13116. use Composer\IO\IOInterface;
  13117. use Composer\Config;
  13118. use Composer\Cache;
  13119. use Composer\Util\HttpDownloader;
  13120. use Composer\Util\ProcessExecutor;
  13121. use Composer\Util\Filesystem;
  13122. use Composer\EventDispatcher\EventDispatcher;
  13123. use Symfony\Component\Filesystem\Exception\IOException;
  13124. use Symfony\Component\Filesystem\Filesystem as SymfonyFilesystem;
  13125. use Composer\DependencyResolver\Operation\UpdateOperation;
  13126. use Composer\DependencyResolver\Operation\InstallOperation;
  13127. use Composer\DependencyResolver\Operation\UninstallOperation;
  13128. class PathDownloader extends FileDownloader implements VcsCapableDownloaderInterface
  13129. {
  13130. const STRATEGY_SYMLINK = 10;
  13131. const STRATEGY_MIRROR = 20;
  13132. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
  13133. {
  13134. $url = $package->getDistUrl();
  13135. $realUrl = realpath($url);
  13136. if (false === $realUrl || !file_exists($realUrl) || !is_dir($realUrl)) {
  13137. throw new \RuntimeException(sprintf(
  13138. 'Source path "%s" is not found for package %s',
  13139. $url,
  13140. $package->getName()
  13141. ));
  13142. }
  13143. if (realpath($path) === $realUrl) {
  13144. return;
  13145. }
  13146. if (strpos(realpath($path) . DIRECTORY_SEPARATOR, $realUrl . DIRECTORY_SEPARATOR) === 0) {
  13147. throw new \RuntimeException(sprintf(
  13148. 'Package %s cannot install to "%s" inside its source at "%s"',
  13149. $package->getName(),
  13150. realpath($path),
  13151. $realUrl
  13152. ));
  13153. }
  13154. }
  13155. public function install(PackageInterface $package, $path, $output = true)
  13156. {
  13157. $url = $package->getDistUrl();
  13158. $realUrl = realpath($url);
  13159. if (realpath($path) === $realUrl) {
  13160. if ($output) {
  13161. $this->io->writeError(" - " . InstallOperation::format($package).': Source already present');
  13162. } else {
  13163. $this->io->writeError('Source already present', false);
  13164. }
  13165. return;
  13166. }
  13167. $transportOptions = $package->getTransportOptions() + array('symlink' => null, 'relative' => true);
  13168. $currentStrategy = self::STRATEGY_SYMLINK;
  13169. $allowedStrategies = array(self::STRATEGY_SYMLINK, self::STRATEGY_MIRROR);
  13170. $mirrorPathRepos = getenv('COMPOSER_MIRROR_PATH_REPOS');
  13171. if ($mirrorPathRepos) {
  13172. $currentStrategy = self::STRATEGY_MIRROR;
  13173. }
  13174. if (true === $transportOptions['symlink']) {
  13175. $currentStrategy = self::STRATEGY_SYMLINK;
  13176. $allowedStrategies = array(self::STRATEGY_SYMLINK);
  13177. } elseif (false === $transportOptions['symlink']) {
  13178. $currentStrategy = self::STRATEGY_MIRROR;
  13179. $allowedStrategies = array(self::STRATEGY_MIRROR);
  13180. }
  13181. if (Platform::isWindows() && self::STRATEGY_SYMLINK === $currentStrategy && !$this->safeJunctions()) {
  13182. $currentStrategy = self::STRATEGY_MIRROR;
  13183. $allowedStrategies = array(self::STRATEGY_MIRROR);
  13184. }
  13185. $symfonyFilesystem = new SymfonyFilesystem();
  13186. $this->filesystem->removeDirectory($path);
  13187. if ($output) {
  13188. $this->io->writeError(" - " . InstallOperation::format($package).': ', false);
  13189. }
  13190. $isFallback = false;
  13191. if (self::STRATEGY_SYMLINK == $currentStrategy) {
  13192. try {
  13193. if (Platform::isWindows()) {
  13194. $this->io->writeError(sprintf('Junctioning from %s', $url), false);
  13195. $this->filesystem->junction($realUrl, $path);
  13196. } else {
  13197. $absolutePath = $path;
  13198. if (!$this->filesystem->isAbsolutePath($absolutePath)) {
  13199. $absolutePath = getcwd() . DIRECTORY_SEPARATOR . $path;
  13200. }
  13201. $shortestPath = $this->filesystem->findShortestPath($absolutePath, $realUrl);
  13202. $path = rtrim($path, "/");
  13203. $this->io->writeError(sprintf('Symlinking from %s', $url), false);
  13204. if ($transportOptions['relative']) {
  13205. $symfonyFilesystem->symlink($shortestPath, $path);
  13206. } else {
  13207. $symfonyFilesystem->symlink($realUrl, $path);
  13208. }
  13209. }
  13210. } catch (IOException $e) {
  13211. if (in_array(self::STRATEGY_MIRROR, $allowedStrategies)) {
  13212. $this->io->writeError('');
  13213. $this->io->writeError(' <error>Symlink failed, fallback to use mirroring!</error>');
  13214. $currentStrategy = self::STRATEGY_MIRROR;
  13215. $isFallback = true;
  13216. } else {
  13217. throw new \RuntimeException(sprintf('Symlink from "%s" to "%s" failed!', $realUrl, $path));
  13218. }
  13219. }
  13220. }
  13221. if (self::STRATEGY_MIRROR == $currentStrategy) {
  13222. $realUrl = $this->filesystem->normalizePath($realUrl);
  13223. $this->io->writeError(sprintf('%sMirroring from %s', $isFallback ? ' ' : '', $url), false);
  13224. $iterator = new ArchivableFilesFinder($realUrl, array());
  13225. $symfonyFilesystem->mirror($realUrl, $path, $iterator);
  13226. }
  13227. if ($output) {
  13228. $this->io->writeError('');
  13229. }
  13230. }
  13231. public function remove(PackageInterface $package, $path, $output = true)
  13232. {
  13233. $realUrl = realpath($package->getDistUrl());
  13234. if (realpath($path) === $realUrl) {
  13235. if ($output) {
  13236. $this->io->writeError(" - " . UninstallOperation::format($package).", source is still present in $path");
  13237. }
  13238. return;
  13239. }
  13240. if (Platform::isWindows() && $this->filesystem->isJunction($path)) {
  13241. if ($output) {
  13242. $this->io->writeError(" - " . UninstallOperation::format($package).", source is still present in $path");
  13243. }
  13244. if (!$this->filesystem->removeJunction($path)) {
  13245. $this->io->writeError(" <warning>Could not remove junction at " . $path . " - is another process locking it?</warning>");
  13246. throw new \RuntimeException('Could not reliably remove junction for package ' . $package->getName());
  13247. }
  13248. } else {
  13249. parent::remove($package, $path, $output);
  13250. }
  13251. }
  13252. public function getVcsReference(PackageInterface $package, $path)
  13253. {
  13254. $parser = new VersionParser;
  13255. $guesser = new VersionGuesser($this->config, $this->process, $parser);
  13256. $dumper = new ArrayDumper;
  13257. $packageConfig = $dumper->dump($package);
  13258. if ($packageVersion = $guesser->guessVersion($packageConfig, $path)) {
  13259. return $packageVersion['commit'];
  13260. }
  13261. }
  13262. private function safeJunctions()
  13263. {
  13264. return function_exists('proc_open') &&
  13265. (PHP_WINDOWS_VERSION_MAJOR > 6 ||
  13266. (PHP_WINDOWS_VERSION_MAJOR === 6 && PHP_WINDOWS_VERSION_MINOR >= 1));
  13267. }
  13268. }
  13269. <?php
  13270. namespace Composer\Downloader;
  13271. use Composer\Package\PackageInterface;
  13272. use Composer\Repository\VcsRepository;
  13273. use Composer\Util\Perforce;
  13274. class PerforceDownloader extends VcsDownloader
  13275. {
  13276. protected $perforce;
  13277. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  13278. {
  13279. }
  13280. public function doInstall(PackageInterface $package, $path, $url)
  13281. {
  13282. $ref = $package->getSourceReference();
  13283. $label = $this->getLabelFromSourceReference($ref);
  13284. $this->io->writeError('Cloning ' . $ref);
  13285. $this->initPerforce($package, $path, $url);
  13286. $this->perforce->setStream($ref);
  13287. $this->perforce->p4Login();
  13288. $this->perforce->writeP4ClientSpec();
  13289. $this->perforce->connectClient();
  13290. $this->perforce->syncCodeBase($label);
  13291. $this->perforce->cleanupClientSpec();
  13292. }
  13293. private function getLabelFromSourceReference($ref)
  13294. {
  13295. $pos = strpos($ref, '@');
  13296. if (false !== $pos) {
  13297. return substr($ref, $pos + 1);
  13298. }
  13299. return null;
  13300. }
  13301. public function initPerforce(PackageInterface $package, $path, $url)
  13302. {
  13303. if (!empty($this->perforce)) {
  13304. $this->perforce->initializePath($path);
  13305. return;
  13306. }
  13307. $repository = $package->getRepository();
  13308. $repoConfig = null;
  13309. if ($repository instanceof VcsRepository) {
  13310. $repoConfig = $this->getRepoConfig($repository);
  13311. }
  13312. $this->perforce = Perforce::create($repoConfig, $url, $path, $this->process, $this->io);
  13313. }
  13314. private function getRepoConfig(VcsRepository $repository)
  13315. {
  13316. return $repository->getRepoConfig();
  13317. }
  13318. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  13319. {
  13320. $this->doInstall($target, $path, $url);
  13321. }
  13322. public function getLocalChanges(PackageInterface $package, $path)
  13323. {
  13324. $this->io->writeError('Perforce driver does not check for local changes before overriding');
  13325. }
  13326. protected function getCommitLogs($fromReference, $toReference, $path)
  13327. {
  13328. return $this->perforce->getCommitLogs($fromReference, $toReference);
  13329. }
  13330. public function setPerforce($perforce)
  13331. {
  13332. $this->perforce = $perforce;
  13333. }
  13334. protected function hasMetadataRepository($path)
  13335. {
  13336. return true;
  13337. }
  13338. }
  13339. <?php
  13340. namespace Composer\Downloader;
  13341. use Composer\Package\PackageInterface;
  13342. class PharDownloader extends ArchiveDownloader
  13343. {
  13344. protected function extract(PackageInterface $package, $file, $path)
  13345. {
  13346. $archive = new \Phar($file);
  13347. $archive->extractTo($path, null, true);
  13348. }
  13349. }
  13350. <?php
  13351. namespace Composer\Downloader;
  13352. use Composer\Config;
  13353. use Composer\Cache;
  13354. use Composer\EventDispatcher\EventDispatcher;
  13355. use Composer\Util\IniHelper;
  13356. use Composer\Util\Platform;
  13357. use Composer\Util\ProcessExecutor;
  13358. use Composer\Util\HttpDownloader;
  13359. use Composer\Util\Filesystem;
  13360. use Composer\IO\IOInterface;
  13361. use Composer\Package\PackageInterface;
  13362. use RarArchive;
  13363. class RarDownloader extends ArchiveDownloader
  13364. {
  13365. protected function extract(PackageInterface $package, $file, $path)
  13366. {
  13367. $processError = null;
  13368. if (!Platform::isWindows()) {
  13369. $command = 'unrar x ' . ProcessExecutor::escape($file) . ' ' . ProcessExecutor::escape($path) . ' >/dev/null && chmod -R u+w ' . ProcessExecutor::escape($path);
  13370. if (0 === $this->process->execute($command, $ignoredOutput)) {
  13371. return;
  13372. }
  13373. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  13374. }
  13375. if (!class_exists('RarArchive')) {
  13376. $iniMessage = IniHelper::getMessage();
  13377. $error = "Could not decompress the archive, enable the PHP rar extension or install unrar.\n"
  13378. . $iniMessage . "\n" . $processError;
  13379. if (!Platform::isWindows()) {
  13380. $error = "Could not decompress the archive, enable the PHP rar extension.\n" . $iniMessage;
  13381. }
  13382. throw new \RuntimeException($error);
  13383. }
  13384. $rarArchive = RarArchive::open($file);
  13385. if (false === $rarArchive) {
  13386. throw new \UnexpectedValueException('Could not open RAR archive: ' . $file);
  13387. }
  13388. $entries = $rarArchive->getEntries();
  13389. if (false === $entries) {
  13390. throw new \RuntimeException('Could not retrieve RAR archive entries');
  13391. }
  13392. foreach ($entries as $entry) {
  13393. if (false === $entry->extract($path)) {
  13394. throw new \RuntimeException('Could not extract entry');
  13395. }
  13396. }
  13397. $rarArchive->close();
  13398. }
  13399. }
  13400. <?php
  13401. namespace Composer\Downloader;
  13402. use Composer\Package\PackageInterface;
  13403. use Composer\Util\Svn as SvnUtil;
  13404. use Composer\Repository\VcsRepository;
  13405. use Composer\Util\ProcessExecutor;
  13406. class SvnDownloader extends VcsDownloader
  13407. {
  13408. protected $cacheCredentials = true;
  13409. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  13410. {
  13411. }
  13412. protected function doInstall(PackageInterface $package, $path, $url)
  13413. {
  13414. SvnUtil::cleanEnv();
  13415. $ref = $package->getSourceReference();
  13416. $repo = $package->getRepository();
  13417. if ($repo instanceof VcsRepository) {
  13418. $repoConfig = $repo->getRepoConfig();
  13419. if (array_key_exists('svn-cache-credentials', $repoConfig)) {
  13420. $this->cacheCredentials = (bool) $repoConfig['svn-cache-credentials'];
  13421. }
  13422. }
  13423. $this->io->writeError(" Checking out ".$package->getSourceReference());
  13424. $this->execute($package, $url, "svn co", sprintf("%s/%s", $url, $ref), null, $path);
  13425. }
  13426. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  13427. {
  13428. SvnUtil::cleanEnv();
  13429. $ref = $target->getSourceReference();
  13430. if (!$this->hasMetadataRepository($path)) {
  13431. throw new \RuntimeException('The .svn directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  13432. }
  13433. $util = new SvnUtil($url, $this->io, $this->config, $this->process);
  13434. $flags = "";
  13435. if (version_compare($util->binaryVersion(), '1.7.0', '>=')) {
  13436. $flags .= ' --ignore-ancestry';
  13437. }
  13438. $this->io->writeError(" Checking out " . $ref);
  13439. $this->execute($target, $url, "svn switch" . $flags, sprintf("%s/%s", $url, $ref), $path);
  13440. }
  13441. public function getLocalChanges(PackageInterface $package, $path)
  13442. {
  13443. if (!$this->hasMetadataRepository($path)) {
  13444. return null;
  13445. }
  13446. $this->process->execute('svn status --ignore-externals', $output, $path);
  13447. return preg_match('{^ *[^X ] +}m', $output) ? $output : null;
  13448. }
  13449. protected function execute(PackageInterface $package, $baseUrl, $command, $url, $cwd = null, $path = null)
  13450. {
  13451. $util = new SvnUtil($baseUrl, $this->io, $this->config, $this->process);
  13452. $util->setCacheCredentials($this->cacheCredentials);
  13453. try {
  13454. return $util->execute($command, $url, $cwd, $path, $this->io->isVerbose());
  13455. } catch (\RuntimeException $e) {
  13456. throw new \RuntimeException(
  13457. $package->getPrettyName().' could not be downloaded, '.$e->getMessage()
  13458. );
  13459. }
  13460. }
  13461. protected function cleanChanges(PackageInterface $package, $path, $update)
  13462. {
  13463. if (!$changes = $this->getLocalChanges($package, $path)) {
  13464. return;
  13465. }
  13466. if (!$this->io->isInteractive()) {
  13467. if (true === $this->config->get('discard-changes')) {
  13468. return $this->discardChanges($path);
  13469. }
  13470. return parent::cleanChanges($package, $path, $update);
  13471. }
  13472. $changes = array_map(function ($elem) {
  13473. return ' '.$elem;
  13474. }, preg_split('{\s*\r?\n\s*}', $changes));
  13475. $countChanges = count($changes);
  13476. $this->io->writeError(sprintf(' <error>'.$package->getPrettyName().' has modified file%s:</error>', $countChanges === 1 ? '' : 's'));
  13477. $this->io->writeError(array_slice($changes, 0, 10));
  13478. if ($countChanges > 10) {
  13479. $remainingChanges = $countChanges - 10;
  13480. $this->io->writeError(
  13481. sprintf(
  13482. ' <info>'.$remainingChanges.' more file%s modified, choose "v" to view the full list</info>',
  13483. $remainingChanges === 1 ? '' : 's'
  13484. )
  13485. );
  13486. }
  13487. while (true) {
  13488. switch ($this->io->ask(' <info>Discard changes [y,n,v,?]?</info> ', '?')) {
  13489. case 'y':
  13490. $this->discardChanges($path);
  13491. break 2;
  13492. case 'n':
  13493. throw new \RuntimeException('Update aborted');
  13494. case 'v':
  13495. $this->io->writeError($changes);
  13496. break;
  13497. case '?':
  13498. default:
  13499. $this->io->writeError(array(
  13500. ' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
  13501. ' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
  13502. ' v - view modified files',
  13503. ' ? - print help',
  13504. ));
  13505. break;
  13506. }
  13507. }
  13508. }
  13509. protected function getCommitLogs($fromReference, $toReference, $path)
  13510. {
  13511. if (preg_match('{@(\d+)$}', $fromReference) && preg_match('{@(\d+)$}', $toReference)) {
  13512. $command = sprintf('svn info --non-interactive --xml %s', ProcessExecutor::escape($path));
  13513. if (0 !== $this->process->execute($command, $output, $path)) {
  13514. throw new \RuntimeException(
  13515. 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()
  13516. );
  13517. }
  13518. $urlPattern = '#<url>(.*)</url>#';
  13519. if (preg_match($urlPattern, $output, $matches)) {
  13520. $baseUrl = $matches[1];
  13521. } else {
  13522. throw new \RuntimeException(
  13523. 'Unable to determine svn url for path '. $path
  13524. );
  13525. }
  13526. $fromRevision = preg_replace('{.*@(\d+)$}', '$1', $fromReference);
  13527. $toRevision = preg_replace('{.*@(\d+)$}', '$1', $toReference);
  13528. $command = sprintf('svn log -r%s:%s --incremental', ProcessExecutor::escape($fromRevision), ProcessExecutor::escape($toRevision));
  13529. $util = new SvnUtil($baseUrl, $this->io, $this->config, $this->process);
  13530. $util->setCacheCredentials($this->cacheCredentials);
  13531. try {
  13532. return $util->executeLocal($command, $path, null, $this->io->isVerbose());
  13533. } catch (\RuntimeException $e) {
  13534. throw new \RuntimeException(
  13535. 'Failed to execute ' . $command . "\n\n".$e->getMessage()
  13536. );
  13537. }
  13538. }
  13539. return "Could not retrieve changes between $fromReference and $toReference due to missing revision information";
  13540. }
  13541. protected function discardChanges($path)
  13542. {
  13543. if (0 !== $this->process->execute('svn revert -R .', $output, $path)) {
  13544. throw new \RuntimeException("Could not reset changes\n\n:".$this->process->getErrorOutput());
  13545. }
  13546. }
  13547. protected function hasMetadataRepository($path)
  13548. {
  13549. return is_dir($path.'/.svn');
  13550. }
  13551. }
  13552. <?php
  13553. namespace Composer\Downloader;
  13554. use Composer\Package\PackageInterface;
  13555. class TarDownloader extends ArchiveDownloader
  13556. {
  13557. protected function extract(PackageInterface $package, $file, $path)
  13558. {
  13559. $archive = new \PharData($file);
  13560. $archive->extractTo($path, null, true);
  13561. }
  13562. }
  13563. <?php
  13564. namespace Composer\Downloader;
  13565. class TransportException extends \RuntimeException
  13566. {
  13567. protected $headers;
  13568. protected $response;
  13569. protected $statusCode;
  13570. public function setHeaders($headers)
  13571. {
  13572. $this->headers = $headers;
  13573. }
  13574. public function getHeaders()
  13575. {
  13576. return $this->headers;
  13577. }
  13578. public function setResponse($response)
  13579. {
  13580. $this->response = $response;
  13581. }
  13582. public function getResponse()
  13583. {
  13584. return $this->response;
  13585. }
  13586. public function setStatusCode($statusCode)
  13587. {
  13588. $this->statusCode = $statusCode;
  13589. }
  13590. public function getStatusCode()
  13591. {
  13592. return $this->statusCode;
  13593. }
  13594. }
  13595. <?php
  13596. namespace Composer\Downloader;
  13597. use Composer\Package\PackageInterface;
  13598. interface VcsCapableDownloaderInterface
  13599. {
  13600. public function getVcsReference(PackageInterface $package, $path);
  13601. }
  13602. <?php
  13603. namespace Composer\Downloader;
  13604. use Composer\Config;
  13605. use Composer\Package\Dumper\ArrayDumper;
  13606. use Composer\Package\PackageInterface;
  13607. use Composer\Package\Version\VersionGuesser;
  13608. use Composer\Package\Version\VersionParser;
  13609. use Composer\Util\ProcessExecutor;
  13610. use Composer\IO\IOInterface;
  13611. use Composer\Util\Filesystem;
  13612. use React\Promise\PromiseInterface;
  13613. use Composer\DependencyResolver\Operation\UpdateOperation;
  13614. use Composer\DependencyResolver\Operation\InstallOperation;
  13615. use Composer\DependencyResolver\Operation\UninstallOperation;
  13616. abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterface, VcsCapableDownloaderInterface
  13617. {
  13618. protected $io;
  13619. protected $config;
  13620. protected $process;
  13621. protected $filesystem;
  13622. protected $hasCleanedChanges = array();
  13623. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, Filesystem $fs = null)
  13624. {
  13625. $this->io = $io;
  13626. $this->config = $config;
  13627. $this->process = $process ?: new ProcessExecutor($io);
  13628. $this->filesystem = $fs ?: new Filesystem($this->process);
  13629. }
  13630. public function getInstallationSource()
  13631. {
  13632. return 'source';
  13633. }
  13634. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null)
  13635. {
  13636. if (!$package->getSourceReference()) {
  13637. throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
  13638. }
  13639. $urls = $this->prepareUrls($package->getSourceUrls());
  13640. while ($url = array_shift($urls)) {
  13641. try {
  13642. return $this->doDownload($package, $path, $url, $prevPackage);
  13643. } catch (\Exception $e) {
  13644. if ($e instanceof \PHPUnit\Framework\Exception) {
  13645. throw $e;
  13646. }
  13647. if ($this->io->isDebug()) {
  13648. $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
  13649. } elseif (count($urls)) {
  13650. $this->io->writeError(' Failed, trying the next URL');
  13651. }
  13652. if (!count($urls)) {
  13653. throw $e;
  13654. }
  13655. }
  13656. }
  13657. }
  13658. public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  13659. {
  13660. if ($type === 'update') {
  13661. $this->cleanChanges($prevPackage, $path, true);
  13662. $this->hasCleanedChanges[$prevPackage->getUniqueName()] = true;
  13663. } elseif ($type === 'install') {
  13664. $this->filesystem->emptyDirectory($path);
  13665. } elseif ($type === 'uninstall') {
  13666. $this->cleanChanges($package, $path, false);
  13667. }
  13668. }
  13669. public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  13670. {
  13671. if ($type === 'update' && isset($this->hasCleanedChanges[$prevPackage->getUniqueName()])) {
  13672. $this->reapplyChanges($path);
  13673. unset($this->hasCleanedChanges[$prevPackage->getUniqueName()]);
  13674. }
  13675. }
  13676. public function install(PackageInterface $package, $path)
  13677. {
  13678. if (!$package->getSourceReference()) {
  13679. throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
  13680. }
  13681. $this->io->writeError(" - " . InstallOperation::format($package).': ', false);
  13682. $urls = $this->prepareUrls($package->getSourceUrls());
  13683. while ($url = array_shift($urls)) {
  13684. try {
  13685. $this->doInstall($package, $path, $url);
  13686. break;
  13687. } catch (\Exception $e) {
  13688. if ($e instanceof \PHPUnit\Framework\Exception) {
  13689. throw $e;
  13690. }
  13691. if ($this->io->isDebug()) {
  13692. $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
  13693. } elseif (count($urls)) {
  13694. $this->io->writeError(' Failed, trying the next URL');
  13695. }
  13696. if (!count($urls)) {
  13697. throw $e;
  13698. }
  13699. }
  13700. }
  13701. }
  13702. public function update(PackageInterface $initial, PackageInterface $target, $path)
  13703. {
  13704. if (!$target->getSourceReference()) {
  13705. throw new \InvalidArgumentException('Package '.$target->getPrettyName().' is missing reference information');
  13706. }
  13707. $this->io->writeError(" - " . UpdateOperation::format($initial, $target).': ', false);
  13708. $urls = $this->prepareUrls($target->getSourceUrls());
  13709. $exception = null;
  13710. while ($url = array_shift($urls)) {
  13711. try {
  13712. $this->doUpdate($initial, $target, $path, $url);
  13713. $exception = null;
  13714. break;
  13715. } catch (\Exception $exception) {
  13716. if ($exception instanceof \PHPUnit\Framework\Exception) {
  13717. throw $exception;
  13718. }
  13719. if ($this->io->isDebug()) {
  13720. $this->io->writeError('Failed: ['.get_class($exception).'] '.$exception->getMessage());
  13721. } elseif (count($urls)) {
  13722. $this->io->writeError(' Failed, trying the next URL');
  13723. }
  13724. }
  13725. }
  13726. if (!$exception && $this->io->isVerbose() && $this->hasMetadataRepository($path)) {
  13727. $message = 'Pulling in changes:';
  13728. $logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path);
  13729. if (!trim($logs)) {
  13730. $message = 'Rolling back changes:';
  13731. $logs = $this->getCommitLogs($target->getSourceReference(), $initial->getSourceReference(), $path);
  13732. }
  13733. if (trim($logs)) {
  13734. $logs = implode("\n", array_map(function ($line) {
  13735. return ' ' . $line;
  13736. }, explode("\n", $logs)));
  13737. $logs = str_replace('<', '\<', $logs);
  13738. $this->io->writeError(' '.$message);
  13739. $this->io->writeError($logs);
  13740. }
  13741. }
  13742. if (!$urls && $exception) {
  13743. throw $exception;
  13744. }
  13745. }
  13746. public function remove(PackageInterface $package, $path)
  13747. {
  13748. $this->io->writeError(" - " . UninstallOperation::format($package));
  13749. if (!$this->filesystem->removeDirectory($path)) {
  13750. throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
  13751. }
  13752. }
  13753. public function getVcsReference(PackageInterface $package, $path)
  13754. {
  13755. $parser = new VersionParser;
  13756. $guesser = new VersionGuesser($this->config, $this->process, $parser);
  13757. $dumper = new ArrayDumper;
  13758. $packageConfig = $dumper->dump($package);
  13759. if ($packageVersion = $guesser->guessVersion($packageConfig, $path)) {
  13760. return $packageVersion['commit'];
  13761. }
  13762. }
  13763. protected function cleanChanges(PackageInterface $package, $path, $update)
  13764. {
  13765. if (null !== $this->getLocalChanges($package, $path)) {
  13766. throw new \RuntimeException('Source directory ' . $path . ' has uncommitted changes.');
  13767. }
  13768. }
  13769. protected function reapplyChanges($path)
  13770. {
  13771. }
  13772. abstract protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null);
  13773. abstract protected function doInstall(PackageInterface $package, $path, $url);
  13774. abstract protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url);
  13775. abstract protected function getCommitLogs($fromReference, $toReference, $path);
  13776. abstract protected function hasMetadataRepository($path);
  13777. private function prepareUrls(array $urls)
  13778. {
  13779. foreach ($urls as $index => $url) {
  13780. if (Filesystem::isLocalPath($url)) {
  13781. $fileProtocol = 'file://';
  13782. $isFileProtocol = false;
  13783. if (0 === strpos($url, $fileProtocol)) {
  13784. $url = substr($url, strlen($fileProtocol));
  13785. $isFileProtocol = true;
  13786. }
  13787. if (false !== strpos($url, '%')) {
  13788. $url = rawurldecode($url);
  13789. }
  13790. $urls[$index] = realpath($url);
  13791. if ($isFileProtocol) {
  13792. $urls[$index] = $fileProtocol . $urls[$index];
  13793. }
  13794. }
  13795. }
  13796. return $urls;
  13797. }
  13798. }
  13799. <?php
  13800. namespace Composer\Downloader;
  13801. use Composer\Config;
  13802. use Composer\Cache;
  13803. use Composer\EventDispatcher\EventDispatcher;
  13804. use Composer\Package\PackageInterface;
  13805. use Composer\Util\ProcessExecutor;
  13806. use Composer\Util\HttpDownloader;
  13807. use Composer\IO\IOInterface;
  13808. use Composer\Util\Filesystem;
  13809. class XzDownloader extends ArchiveDownloader
  13810. {
  13811. protected function extract(PackageInterface $package, $file, $path)
  13812. {
  13813. $command = 'tar -xJf ' . ProcessExecutor::escape($file) . ' -C ' . ProcessExecutor::escape($path);
  13814. if (0 === $this->process->execute($command, $ignoredOutput)) {
  13815. return;
  13816. }
  13817. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  13818. throw new \RuntimeException($processError);
  13819. }
  13820. }
  13821. <?php
  13822. namespace Composer\Downloader;
  13823. use Composer\Config;
  13824. use Composer\Cache;
  13825. use Composer\EventDispatcher\EventDispatcher;
  13826. use Composer\Package\PackageInterface;
  13827. use Composer\Util\IniHelper;
  13828. use Composer\Util\Platform;
  13829. use Composer\Util\ProcessExecutor;
  13830. use Composer\Util\Filesystem;
  13831. use Composer\Util\HttpDownloader;
  13832. use Composer\IO\IOInterface;
  13833. use Symfony\Component\Process\ExecutableFinder;
  13834. use ZipArchive;
  13835. class ZipDownloader extends ArchiveDownloader
  13836. {
  13837. protected static $hasSystemUnzip;
  13838. private static $hasZipArchive;
  13839. private static $isWindows;
  13840. private $zipArchiveObject;
  13841. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
  13842. {
  13843. if (null === self::$hasSystemUnzip) {
  13844. $finder = new ExecutableFinder;
  13845. self::$hasSystemUnzip = (bool) $finder->find('unzip');
  13846. }
  13847. if (null === self::$hasZipArchive) {
  13848. self::$hasZipArchive = class_exists('ZipArchive');
  13849. }
  13850. if (!self::$hasZipArchive && !self::$hasSystemUnzip) {
  13851. $iniMessage = IniHelper::getMessage();
  13852. $error = "The zip extension and unzip command are both missing, skipping.\n" . $iniMessage;
  13853. throw new \RuntimeException($error);
  13854. }
  13855. if (null === self::$isWindows) {
  13856. self::$isWindows = Platform::isWindows();
  13857. if (!self::$isWindows && !self::$hasSystemUnzip) {
  13858. $this->io->writeError("<warning>As there is no 'unzip' command installed zip files are being unpacked using the PHP zip extension.</warning>");
  13859. $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>");
  13860. $this->io->writeError("<warning>Installing 'unzip' may remediate them.</warning>");
  13861. }
  13862. }
  13863. return parent::download($package, $path, $prevPackage, $output);
  13864. }
  13865. private function extractWithSystemUnzip(PackageInterface $package, $file, $path, $isLastChance, $async = false)
  13866. {
  13867. if (!self::$hasZipArchive) {
  13868. $isLastChance = true;
  13869. }
  13870. if (!self::$hasSystemUnzip && !$isLastChance) {
  13871. return $this->extractWithZipArchive($package, $file, $path, true);
  13872. }
  13873. $overwrite = $isLastChance ? '-o' : '';
  13874. $command = 'unzip -qq '.$overwrite.' '.ProcessExecutor::escape($file).' -d '.ProcessExecutor::escape($path);
  13875. if ($async) {
  13876. $self = $this;
  13877. $io = $this->io;
  13878. $tryFallback = function ($processError) use ($isLastChance, $io, $self, $file, $path, $package) {
  13879. if ($isLastChance) {
  13880. throw $processError;
  13881. }
  13882. if (!is_file($file)) {
  13883. $io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  13884. $io->writeError(' <warning>This most likely is due to a custom installer plugin not handling the returned Promise from the downloader</warning>');
  13885. $io->writeError(' <warning>See https://github.com/composer/installers/commit/5006d0c28730ade233a8f42ec31ac68fb1c5c9bb for an example fix</warning>');
  13886. } else {
  13887. $io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  13888. $io->writeError(' The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)');
  13889. $io->writeError(' Unzip with unzip command failed, falling back to ZipArchive class');
  13890. }
  13891. return $self->extractWithZipArchive($package, $file, $path, true);
  13892. };
  13893. try {
  13894. $promise = $this->process->executeAsync($command);
  13895. return $promise->then(function ($process) use ($tryFallback, $command, $package, $file) {
  13896. if (!$process->isSuccessful()) {
  13897. $output = $process->getErrorOutput();
  13898. $output = str_replace(', '.$file.'.zip or '.$file.'.ZIP', '', $output);
  13899. return $tryFallback(new \RuntimeException('Failed to extract '.$package->getName().': ('.$process->getExitCode().') '.$command."\n\n".$output));
  13900. }
  13901. });
  13902. } catch (\Exception $e) {
  13903. return $tryFallback($e);
  13904. } catch (\Throwable $e) {
  13905. return $tryFallback($e);
  13906. }
  13907. }
  13908. $processError = null;
  13909. try {
  13910. if (0 === $exitCode = $this->process->execute($command, $ignoredOutput)) {
  13911. return \React\Promise\resolve();
  13912. }
  13913. $processError = new \RuntimeException('Failed to execute ('.$exitCode.') '.$command."\n\n".$this->process->getErrorOutput());
  13914. } catch (\Exception $e) {
  13915. $processError = $e;
  13916. }
  13917. if ($isLastChance) {
  13918. throw $processError;
  13919. }
  13920. $this->io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  13921. $this->io->writeError(' The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)');
  13922. $this->io->writeError(' Unzip with unzip command failed, falling back to ZipArchive class');
  13923. return $this->extractWithZipArchive($package, $file, $path, true);
  13924. }
  13925. public function extractWithZipArchive(PackageInterface $package, $file, $path, $isLastChance)
  13926. {
  13927. if (!self::$hasSystemUnzip) {
  13928. $isLastChance = true;
  13929. }
  13930. if (!self::$hasZipArchive && !$isLastChance) {
  13931. return $this->extractWithSystemUnzip($package, $file, $path, true);
  13932. }
  13933. $processError = null;
  13934. $zipArchive = $this->zipArchiveObject ?: new ZipArchive();
  13935. try {
  13936. if (true === ($retval = $zipArchive->open($file))) {
  13937. $extractResult = $zipArchive->extractTo($path);
  13938. if (true === $extractResult) {
  13939. $zipArchive->close();
  13940. return \React\Promise\resolve();
  13941. }
  13942. $processError = new \RuntimeException(rtrim("There was an error extracting the ZIP file, it is either corrupted or using an invalid format.\n"));
  13943. } else {
  13944. $processError = new \UnexpectedValueException(rtrim($this->getErrorMessage($retval, $file)."\n"), $retval);
  13945. }
  13946. } catch (\ErrorException $e) {
  13947. $processError = new \RuntimeException('The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems): '.$e->getMessage(), 0, $e);
  13948. } catch (\Exception $e) {
  13949. $processError = $e;
  13950. } catch (\Throwable $e) {
  13951. $processError = $e;
  13952. }
  13953. if ($isLastChance) {
  13954. throw $processError;
  13955. }
  13956. $this->io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  13957. $this->io->writeError(' Unzip with ZipArchive class failed, falling back to unzip command');
  13958. return $this->extractWithSystemUnzip($package, $file, $path, true);
  13959. }
  13960. public function extract(PackageInterface $package, $file, $path)
  13961. {
  13962. if (self::$isWindows) {
  13963. return $this->extractWithZipArchive($package, $file, $path, false);
  13964. }
  13965. return $this->extractWithSystemUnzip($package, $file, $path, false, true);
  13966. }
  13967. protected function getErrorMessage($retval, $file)
  13968. {
  13969. switch ($retval) {
  13970. case ZipArchive::ER_EXISTS:
  13971. return sprintf("File '%s' already exists.", $file);
  13972. case ZipArchive::ER_INCONS:
  13973. return sprintf("Zip archive '%s' is inconsistent.", $file);
  13974. case ZipArchive::ER_INVAL:
  13975. return sprintf("Invalid argument (%s)", $file);
  13976. case ZipArchive::ER_MEMORY:
  13977. return sprintf("Malloc failure (%s)", $file);
  13978. case ZipArchive::ER_NOENT:
  13979. return sprintf("No such zip file: '%s'", $file);
  13980. case ZipArchive::ER_NOZIP:
  13981. return sprintf("'%s' is not a zip archive.", $file);
  13982. case ZipArchive::ER_OPEN:
  13983. return sprintf("Can't open zip file: %s", $file);
  13984. case ZipArchive::ER_READ:
  13985. return sprintf("Zip read error (%s)", $file);
  13986. case ZipArchive::ER_SEEK:
  13987. return sprintf("Zip seek error (%s)", $file);
  13988. default:
  13989. return sprintf("'%s' is not a valid zip archive, got error code: %s", $file, $retval);
  13990. }
  13991. }
  13992. }
  13993. <?php
  13994. namespace Composer\EventDispatcher;
  13995. class Event
  13996. {
  13997. protected $name;
  13998. protected $args;
  13999. protected $flags;
  14000. private $propagationStopped = false;
  14001. public function __construct($name, array $args = array(), array $flags = array())
  14002. {
  14003. $this->name = $name;
  14004. $this->args = $args;
  14005. $this->flags = $flags;
  14006. }
  14007. public function getName()
  14008. {
  14009. return $this->name;
  14010. }
  14011. public function getArguments()
  14012. {
  14013. return $this->args;
  14014. }
  14015. public function getFlags()
  14016. {
  14017. return $this->flags;
  14018. }
  14019. public function isPropagationStopped()
  14020. {
  14021. return $this->propagationStopped;
  14022. }
  14023. public function stopPropagation()
  14024. {
  14025. $this->propagationStopped = true;
  14026. }
  14027. }
  14028. <?php
  14029. namespace Composer\EventDispatcher;
  14030. use Composer\DependencyResolver\Transaction;
  14031. use Composer\Installer\InstallerEvent;
  14032. use Composer\IO\IOInterface;
  14033. use Composer\Composer;
  14034. use Composer\DependencyResolver\Operation\OperationInterface;
  14035. use Composer\Repository\RepositoryInterface;
  14036. use Composer\Script;
  14037. use Composer\Installer\PackageEvent;
  14038. use Composer\Installer\BinaryInstaller;
  14039. use Composer\Util\ProcessExecutor;
  14040. use Composer\Script\Event as ScriptEvent;
  14041. use Composer\ClassLoader;
  14042. use Symfony\Component\Process\PhpExecutableFinder;
  14043. class EventDispatcher
  14044. {
  14045. protected $composer;
  14046. protected $io;
  14047. protected $loader;
  14048. protected $process;
  14049. protected $listeners = array();
  14050. private $eventStack;
  14051. public function __construct(Composer $composer, IOInterface $io, ProcessExecutor $process = null)
  14052. {
  14053. $this->composer = $composer;
  14054. $this->io = $io;
  14055. $this->process = $process ?: new ProcessExecutor($io);
  14056. $this->eventStack = array();
  14057. }
  14058. public function dispatch($eventName, Event $event = null)
  14059. {
  14060. if (null === $event) {
  14061. $event = new Event($eventName);
  14062. }
  14063. return $this->doDispatch($event);
  14064. }
  14065. public function dispatchScript($eventName, $devMode = false, $additionalArgs = array(), $flags = array())
  14066. {
  14067. return $this->doDispatch(new Script\Event($eventName, $this->composer, $this->io, $devMode, $additionalArgs, $flags));
  14068. }
  14069. public function dispatchPackageEvent($eventName, $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation)
  14070. {
  14071. return $this->doDispatch(new PackageEvent($eventName, $this->composer, $this->io, $devMode, $localRepo, $operations, $operation));
  14072. }
  14073. public function dispatchInstallerEvent($eventName, $devMode, $executeOperations, Transaction $transaction)
  14074. {
  14075. return $this->doDispatch(new InstallerEvent($eventName, $this->composer, $this->io, $devMode, $executeOperations, $transaction));
  14076. }
  14077. protected function doDispatch(Event $event)
  14078. {
  14079. if (getenv('COMPOSER_DEBUG_EVENTS')) {
  14080. $details = null;
  14081. if ($event instanceof PackageEvent) {
  14082. $details = (string) $event->getOperation();
  14083. }
  14084. $this->io->writeError('Dispatching <info>'.$event->getName().'</info>'.($details ? ' ('.$details.')' : '').' event');
  14085. }
  14086. $listeners = $this->getListeners($event);
  14087. $this->pushEvent($event);
  14088. $return = 0;
  14089. foreach ($listeners as $callable) {
  14090. $this->ensureBinDirIsInPath();
  14091. if (!is_string($callable)) {
  14092. if (!is_callable($callable)) {
  14093. $className = is_object($callable[0]) ? get_class($callable[0]) : $callable[0];
  14094. throw new \RuntimeException('Subscriber '.$className.'::'.$callable[1].' for event '.$event->getName().' is not callable, make sure the function is defined and public');
  14095. }
  14096. if (is_array($callable) && (is_string($callable[0]) || is_object($callable[0])) && is_string($callable[1])) {
  14097. $this->io->writeError(sprintf('> %s: %s', $event->getName(), (is_object($callable[0]) ? get_class($callable[0]) : $callable[0]).'->'.$callable[1] ), true, IOInterface::VERBOSE);
  14098. }
  14099. $return = false === call_user_func($callable, $event) ? 1 : 0;
  14100. } elseif ($this->isComposerScript($callable)) {
  14101. $this->io->writeError(sprintf('> %s: %s', $event->getName(), $callable), true, IOInterface::VERBOSE);
  14102. $script = explode(' ', substr($callable, 1));
  14103. $scriptName = $script[0];
  14104. unset($script[0]);
  14105. $args = array_merge($script, $event->getArguments());
  14106. $flags = $event->getFlags();
  14107. if (strpos($callable, '@composer ') === 0) {
  14108. $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . ' ' . implode(' ', $args);
  14109. if (0 !== ($exitCode = $this->executeTty($exec))) {
  14110. $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  14111. throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
  14112. }
  14113. } else {
  14114. if (!$this->getListeners(new Event($scriptName))) {
  14115. $this->io->writeError(sprintf('<warning>You made a reference to a non-existent script %s</warning>', $callable), true, IOInterface::QUIET);
  14116. }
  14117. try {
  14118. $scriptEvent = new Script\Event($scriptName, $event->getComposer(), $event->getIO(), $event->isDevMode(), $args, $flags);
  14119. $scriptEvent->setOriginatingEvent($event);
  14120. $return = $this->dispatch($scriptName, $scriptEvent);
  14121. } catch (ScriptExecutionException $e) {
  14122. $this->io->writeError(sprintf('<error>Script %s was called via %s</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  14123. throw $e;
  14124. }
  14125. }
  14126. } elseif ($this->isPhpScript($callable)) {
  14127. $className = substr($callable, 0, strpos($callable, '::'));
  14128. $methodName = substr($callable, strpos($callable, '::') + 2);
  14129. if (!class_exists($className)) {
  14130. $this->io->writeError('<warning>Class '.$className.' is not autoloadable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  14131. continue;
  14132. }
  14133. if (!is_callable($callable)) {
  14134. $this->io->writeError('<warning>Method '.$callable.' is not callable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  14135. continue;
  14136. }
  14137. try {
  14138. $return = false === $this->executeEventPhpScript($className, $methodName, $event) ? 1 : 0;
  14139. } catch (\Exception $e) {
  14140. $message = "Script %s handling the %s event terminated with an exception";
  14141. $this->io->writeError('<error>'.sprintf($message, $callable, $event->getName()).'</error>', true, IOInterface::QUIET);
  14142. throw $e;
  14143. }
  14144. } else {
  14145. $args = implode(' ', array_map(array('Composer\Util\ProcessExecutor', 'escape'), $event->getArguments()));
  14146. $exec = $callable . ($args === '' ? '' : ' '.$args);
  14147. if ($this->io->isVerbose()) {
  14148. $this->io->writeError(sprintf('> %s: %s', $event->getName(), $exec));
  14149. } else {
  14150. $this->io->writeError(sprintf('> %s', $exec));
  14151. }
  14152. $possibleLocalBinaries = $this->composer->getPackage()->getBinaries();
  14153. if ($possibleLocalBinaries) {
  14154. foreach ($possibleLocalBinaries as $localExec) {
  14155. if (preg_match('{\b'.preg_quote($callable).'$}', $localExec)) {
  14156. $caller = BinaryInstaller::determineBinaryCaller($localExec);
  14157. $exec = preg_replace('{^'.preg_quote($callable).'}', $caller . ' ' . $localExec, $exec);
  14158. break;
  14159. }
  14160. }
  14161. }
  14162. if (strpos($exec, '@putenv ') === 0) {
  14163. putenv(substr($exec, 8));
  14164. continue;
  14165. }
  14166. if (strpos($exec, '@php ') === 0) {
  14167. $exec = $this->getPhpExecCommand() . ' ' . substr($exec, 5);
  14168. } else {
  14169. $finder = new PhpExecutableFinder();
  14170. $phpPath = $finder->find(false);
  14171. if ($phpPath) {
  14172. $_SERVER['PHP_BINARY'] = $phpPath;
  14173. putenv('PHP_BINARY=' . $_SERVER['PHP_BINARY']);
  14174. }
  14175. }
  14176. if (strpos($exec, 'composer ') === 0) {
  14177. $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . substr($exec, 8);
  14178. }
  14179. if (0 !== ($exitCode = $this->executeTty($exec))) {
  14180. $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  14181. throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
  14182. }
  14183. }
  14184. if ($event->isPropagationStopped()) {
  14185. break;
  14186. }
  14187. }
  14188. $this->popEvent();
  14189. return $return;
  14190. }
  14191. protected function executeTty($exec)
  14192. {
  14193. if ($this->io->isInteractive()) {
  14194. return $this->process->executeTty($exec);
  14195. }
  14196. return $this->process->execute($exec);
  14197. }
  14198. protected function getPhpExecCommand()
  14199. {
  14200. $finder = new PhpExecutableFinder();
  14201. $phpPath = $finder->find(false);
  14202. if (!$phpPath) {
  14203. throw new \RuntimeException('Failed to locate PHP binary to execute '.$phpPath);
  14204. }
  14205. $phpArgs = $finder->findArguments();
  14206. $phpArgs = $phpArgs ? ' ' . implode(' ', $phpArgs) : '';
  14207. $allowUrlFOpenFlag = ' -d allow_url_fopen=' . ProcessExecutor::escape(ini_get('allow_url_fopen'));
  14208. $disableFunctionsFlag = ' -d disable_functions=' . ProcessExecutor::escape(ini_get('disable_functions'));
  14209. $memoryLimitFlag = ' -d memory_limit=' . ProcessExecutor::escape(ini_get('memory_limit'));
  14210. return ProcessExecutor::escape($phpPath) . $phpArgs . $allowUrlFOpenFlag . $disableFunctionsFlag . $memoryLimitFlag;
  14211. }
  14212. protected function executeEventPhpScript($className, $methodName, Event $event)
  14213. {
  14214. if ($this->io->isVerbose()) {
  14215. $this->io->writeError(sprintf('> %s: %s::%s', $event->getName(), $className, $methodName));
  14216. } else {
  14217. $this->io->writeError(sprintf('> %s::%s', $className, $methodName));
  14218. }
  14219. return $className::$methodName($event);
  14220. }
  14221. public function addListener($eventName, $listener, $priority = 0)
  14222. {
  14223. $this->listeners[$eventName][$priority][] = $listener;
  14224. }
  14225. public function removeListener($listener)
  14226. {
  14227. foreach ($this->listeners as $eventName => $priorities) {
  14228. foreach ($priorities as $priority => $listeners) {
  14229. foreach ($listeners as $index => $candidate) {
  14230. if ($listener === $candidate || (is_array($candidate) && is_object($listener) && $candidate[0] === $listener)) {
  14231. unset($this->listeners[$eventName][$priority][$index]);
  14232. }
  14233. }
  14234. }
  14235. }
  14236. }
  14237. public function addSubscriber(EventSubscriberInterface $subscriber)
  14238. {
  14239. foreach ($subscriber->getSubscribedEvents() as $eventName => $params) {
  14240. if (is_string($params)) {
  14241. $this->addListener($eventName, array($subscriber, $params));
  14242. } elseif (is_string($params[0])) {
  14243. $this->addListener($eventName, array($subscriber, $params[0]), isset($params[1]) ? $params[1] : 0);
  14244. } else {
  14245. foreach ($params as $listener) {
  14246. $this->addListener($eventName, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0);
  14247. }
  14248. }
  14249. }
  14250. }
  14251. protected function getListeners(Event $event)
  14252. {
  14253. $scriptListeners = $this->getScriptListeners($event);
  14254. if (!isset($this->listeners[$event->getName()][0])) {
  14255. $this->listeners[$event->getName()][0] = array();
  14256. }
  14257. krsort($this->listeners[$event->getName()]);
  14258. $listeners = $this->listeners;
  14259. $listeners[$event->getName()][0] = array_merge($listeners[$event->getName()][0], $scriptListeners);
  14260. return call_user_func_array('array_merge', $listeners[$event->getName()]);
  14261. }
  14262. public function hasEventListeners(Event $event)
  14263. {
  14264. $listeners = $this->getListeners($event);
  14265. return count($listeners) > 0;
  14266. }
  14267. protected function getScriptListeners(Event $event)
  14268. {
  14269. $package = $this->composer->getPackage();
  14270. $scripts = $package->getScripts();
  14271. if (empty($scripts[$event->getName()])) {
  14272. return array();
  14273. }
  14274. if ($this->loader) {
  14275. $this->loader->unregister();
  14276. }
  14277. $generator = $this->composer->getAutoloadGenerator();
  14278. if ($event instanceof ScriptEvent) {
  14279. $generator->setDevMode($event->isDevMode());
  14280. }
  14281. $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
  14282. $packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $package, $packages);
  14283. $map = $generator->parseAutoloads($packageMap, $package);
  14284. $this->loader = $generator->createLoader($map);
  14285. $this->loader->register();
  14286. return $scripts[$event->getName()];
  14287. }
  14288. protected function isPhpScript($callable)
  14289. {
  14290. return false === strpos($callable, ' ') && false !== strpos($callable, '::');
  14291. }
  14292. protected function isComposerScript($callable)
  14293. {
  14294. return strpos($callable, '@') === 0 && strpos($callable, '@php ') !== 0 && strpos($callable, '@putenv ') !== 0;
  14295. }
  14296. protected function pushEvent(Event $event)
  14297. {
  14298. $eventName = $event->getName();
  14299. if (in_array($eventName, $this->eventStack)) {
  14300. throw new \RuntimeException(sprintf("Circular call to script handler '%s' detected", $eventName));
  14301. }
  14302. return array_push($this->eventStack, $eventName);
  14303. }
  14304. protected function popEvent()
  14305. {
  14306. return array_pop($this->eventStack);
  14307. }
  14308. private function ensureBinDirIsInPath()
  14309. {
  14310. $pathStr = 'PATH';
  14311. if (!isset($_SERVER[$pathStr]) && isset($_SERVER['Path'])) {
  14312. $pathStr = 'Path';
  14313. }
  14314. $binDir = $this->composer->getConfig()->get('bin-dir');
  14315. if (is_dir($binDir)) {
  14316. $binDir = realpath($binDir);
  14317. if (isset($_SERVER[$pathStr]) && !preg_match('{(^|'.PATH_SEPARATOR.')'.preg_quote($binDir).'($|'.PATH_SEPARATOR.')}', $_SERVER[$pathStr])) {
  14318. $_SERVER[$pathStr] = $binDir.PATH_SEPARATOR.getenv($pathStr);
  14319. putenv($pathStr.'='.$_SERVER[$pathStr]);
  14320. }
  14321. }
  14322. }
  14323. }
  14324. <?php
  14325. namespace Composer\EventDispatcher;
  14326. interface EventSubscriberInterface
  14327. {
  14328. public static function getSubscribedEvents();
  14329. }
  14330. <?php
  14331. namespace Composer\EventDispatcher;
  14332. class ScriptExecutionException extends \RuntimeException
  14333. {
  14334. }
  14335. <?php
  14336. namespace Composer\Exception;
  14337. class IrrecoverableDownloadException extends \RuntimeException
  14338. {
  14339. }
  14340. <?php
  14341. namespace Composer\Exception;
  14342. class NoSslException extends \RuntimeException
  14343. {
  14344. }
  14345. <?php
  14346. namespace Composer;
  14347. use Composer\Config\JsonConfigSource;
  14348. use Composer\Json\JsonFile;
  14349. use Composer\IO\IOInterface;
  14350. use Composer\Package\Archiver;
  14351. use Composer\Package\Version\VersionGuesser;
  14352. use Composer\Package\RootPackageInterface;
  14353. use Composer\Repository\RepositoryManager;
  14354. use Composer\Repository\RepositoryFactory;
  14355. use Composer\Repository\WritableRepositoryInterface;
  14356. use Composer\Util\Filesystem;
  14357. use Composer\Util\Platform;
  14358. use Composer\Util\ProcessExecutor;
  14359. use Composer\Util\HttpDownloader;
  14360. use Composer\Util\Loop;
  14361. use Composer\Util\Silencer;
  14362. use Composer\Plugin\PluginEvents;
  14363. use Composer\EventDispatcher\Event;
  14364. use Seld\JsonLint\DuplicateKeyException;
  14365. use Symfony\Component\Console\Formatter\OutputFormatter;
  14366. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  14367. use Symfony\Component\Console\Output\ConsoleOutput;
  14368. use Composer\EventDispatcher\EventDispatcher;
  14369. use Composer\Autoload\AutoloadGenerator;
  14370. use Composer\Package\Version\VersionParser;
  14371. use Composer\Downloader\TransportException;
  14372. use Seld\JsonLint\JsonParser;
  14373. class Factory
  14374. {
  14375. protected static function getHomeDir()
  14376. {
  14377. $home = getenv('COMPOSER_HOME');
  14378. if ($home) {
  14379. return $home;
  14380. }
  14381. if (Platform::isWindows()) {
  14382. if (!getenv('APPDATA')) {
  14383. throw new \RuntimeException('The APPDATA or COMPOSER_HOME environment variable must be set for composer to run correctly');
  14384. }
  14385. return rtrim(strtr(getenv('APPDATA'), '\\', '/'), '/') . '/Composer';
  14386. }
  14387. $userDir = self::getUserDir();
  14388. $dirs = array();
  14389. if (self::useXdg()) {
  14390. $xdgConfig = getenv('XDG_CONFIG_HOME');
  14391. if (!$xdgConfig) {
  14392. $xdgConfig = $userDir . '/.config';
  14393. }
  14394. $dirs[] = $xdgConfig . '/composer';
  14395. }
  14396. $dirs[] = $userDir . '/.composer';
  14397. foreach ($dirs as $dir) {
  14398. if (is_dir($dir)) {
  14399. return $dir;
  14400. }
  14401. }
  14402. return $dirs[0];
  14403. }
  14404. protected static function getCacheDir($home)
  14405. {
  14406. $cacheDir = getenv('COMPOSER_CACHE_DIR');
  14407. if ($cacheDir) {
  14408. return $cacheDir;
  14409. }
  14410. $homeEnv = getenv('COMPOSER_HOME');
  14411. if ($homeEnv) {
  14412. return $homeEnv . '/cache';
  14413. }
  14414. if (Platform::isWindows()) {
  14415. if ($cacheDir = getenv('LOCALAPPDATA')) {
  14416. $cacheDir .= '/Composer';
  14417. } else {
  14418. $cacheDir = $home . '/cache';
  14419. }
  14420. return rtrim(strtr($cacheDir, '\\', '/'), '/');
  14421. }
  14422. $userDir = self::getUserDir();
  14423. if ($home === $userDir . '/.composer' && is_dir($home . '/cache')) {
  14424. return $home . '/cache';
  14425. }
  14426. if (self::useXdg()) {
  14427. $xdgCache = getenv('XDG_CACHE_HOME') ?: $userDir . '/.cache';
  14428. return $xdgCache . '/composer';
  14429. }
  14430. return $home . '/cache';
  14431. }
  14432. protected static function getDataDir($home)
  14433. {
  14434. $homeEnv = getenv('COMPOSER_HOME');
  14435. if ($homeEnv) {
  14436. return $homeEnv;
  14437. }
  14438. if (Platform::isWindows()) {
  14439. return strtr($home, '\\', '/');
  14440. }
  14441. $userDir = self::getUserDir();
  14442. if ($home !== $userDir . '/.composer' && self::useXdg()) {
  14443. $xdgData = getenv('XDG_DATA_HOME') ?: $userDir . '/.local/share';
  14444. return $xdgData . '/composer';
  14445. }
  14446. return $home;
  14447. }
  14448. public static function createConfig(IOInterface $io = null, $cwd = null)
  14449. {
  14450. $cwd = $cwd ?: getcwd();
  14451. $config = new Config(true, $cwd);
  14452. $home = self::getHomeDir();
  14453. $config->merge(array('config' => array(
  14454. 'home' => $home,
  14455. 'cache-dir' => self::getCacheDir($home),
  14456. 'data-dir' => self::getDataDir($home),
  14457. )));
  14458. $file = new JsonFile($config->get('home').'/config.json');
  14459. if ($file->exists()) {
  14460. if ($io && $io->isDebug()) {
  14461. $io->writeError('Loading config file ' . $file->getPath());
  14462. }
  14463. $config->merge($file->read());
  14464. }
  14465. $config->setConfigSource(new JsonConfigSource($file));
  14466. $htaccessProtect = (bool) $config->get('htaccess-protect');
  14467. if ($htaccessProtect) {
  14468. $dirs = array($config->get('home'), $config->get('cache-dir'), $config->get('data-dir'));
  14469. foreach ($dirs as $dir) {
  14470. if (!file_exists($dir . '/.htaccess')) {
  14471. if (!is_dir($dir)) {
  14472. Silencer::call('mkdir', $dir, 0777, true);
  14473. }
  14474. Silencer::call('file_put_contents', $dir . '/.htaccess', 'Deny from all');
  14475. }
  14476. }
  14477. }
  14478. $file = new JsonFile($config->get('home').'/auth.json');
  14479. if ($file->exists()) {
  14480. if ($io && $io->isDebug()) {
  14481. $io->writeError('Loading config file ' . $file->getPath());
  14482. }
  14483. $config->merge(array('config' => $file->read()));
  14484. }
  14485. $config->setAuthConfigSource(new JsonConfigSource($file, true));
  14486. if ($composerAuthEnv = getenv('COMPOSER_AUTH')) {
  14487. $authData = json_decode($composerAuthEnv, true);
  14488. if (null === $authData) {
  14489. throw new \UnexpectedValueException('COMPOSER_AUTH environment variable is malformed, should be a valid JSON object');
  14490. }
  14491. if ($io && $io->isDebug()) {
  14492. $io->writeError('Loading auth config from COMPOSER_AUTH');
  14493. }
  14494. $config->merge(array('config' => $authData));
  14495. }
  14496. return $config;
  14497. }
  14498. public static function getComposerFile()
  14499. {
  14500. return trim(getenv('COMPOSER')) ?: './composer.json';
  14501. }
  14502. public static function getLockFile($composerFile)
  14503. {
  14504. return "json" === pathinfo($composerFile, PATHINFO_EXTENSION)
  14505. ? substr($composerFile, 0, -4).'lock'
  14506. : $composerFile . '.lock';
  14507. }
  14508. public static function createAdditionalStyles()
  14509. {
  14510. return array(
  14511. 'highlight' => new OutputFormatterStyle('red'),
  14512. 'warning' => new OutputFormatterStyle('black', 'yellow'),
  14513. );
  14514. }
  14515. public static function createOutput()
  14516. {
  14517. $styles = self::createAdditionalStyles();
  14518. $formatter = new OutputFormatter(false, $styles);
  14519. return new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, null, $formatter);
  14520. }
  14521. public function createComposer(IOInterface $io, $localConfig = null, $disablePlugins = false, $cwd = null, $fullLoad = true)
  14522. {
  14523. $cwd = $cwd ?: getcwd();
  14524. if (null === $localConfig) {
  14525. $localConfig = static::getComposerFile();
  14526. }
  14527. if (is_string($localConfig)) {
  14528. $composerFile = $localConfig;
  14529. $file = new JsonFile($localConfig, null, $io);
  14530. if (!$file->exists()) {
  14531. if ($localConfig === './composer.json' || $localConfig === 'composer.json') {
  14532. $message = 'Composer could not find a composer.json file in '.$cwd;
  14533. } else {
  14534. $message = 'Composer could not find the config file: '.$localConfig;
  14535. }
  14536. $instructions = 'To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section';
  14537. throw new \InvalidArgumentException($message.PHP_EOL.$instructions);
  14538. }
  14539. $file->validateSchema(JsonFile::LAX_SCHEMA);
  14540. $jsonParser = new JsonParser;
  14541. try {
  14542. $jsonParser->parse(file_get_contents($localConfig), JsonParser::DETECT_KEY_CONFLICTS);
  14543. } catch (DuplicateKeyException $e) {
  14544. $details = $e->getDetails();
  14545. $io->writeError('<warning>Key '.$details['key'].' is a duplicate in '.$localConfig.' at line '.$details['line'].'</warning>');
  14546. }
  14547. $localConfig = $file->read();
  14548. }
  14549. $config = static::createConfig($io, $cwd);
  14550. $config->merge($localConfig);
  14551. if (isset($composerFile)) {
  14552. $io->writeError('Loading config file ' . $composerFile, true, IOInterface::DEBUG);
  14553. $config->setConfigSource(new JsonConfigSource(new JsonFile(realpath($composerFile), null, $io)));
  14554. $localAuthFile = new JsonFile(dirname(realpath($composerFile)) . '/auth.json', null, $io);
  14555. if ($localAuthFile->exists()) {
  14556. $io->writeError('Loading config file ' . $localAuthFile->getPath(), true, IOInterface::DEBUG);
  14557. $config->merge(array('config' => $localAuthFile->read()));
  14558. $config->setAuthConfigSource(new JsonConfigSource($localAuthFile, true));
  14559. }
  14560. }
  14561. $vendorDir = $config->get('vendor-dir');
  14562. $composer = new Composer();
  14563. $composer->setConfig($config);
  14564. if ($fullLoad) {
  14565. $io->loadConfiguration($config);
  14566. }
  14567. $httpDownloader = self::createHttpDownloader($io, $config);
  14568. $process = new ProcessExecutor($io);
  14569. $loop = new Loop($httpDownloader, $process);
  14570. $composer->setLoop($loop);
  14571. $dispatcher = new EventDispatcher($composer, $io, $process);
  14572. $composer->setEventDispatcher($dispatcher);
  14573. $rm = RepositoryFactory::manager($io, $config, $httpDownloader, $dispatcher, $process);
  14574. $composer->setRepositoryManager($rm);
  14575. if (!$fullLoad && !isset($localConfig['version'])) {
  14576. $localConfig['version'] = '1.0.0';
  14577. }
  14578. $parser = new VersionParser;
  14579. $guesser = new VersionGuesser($config, $process, $parser);
  14580. $loader = $this->loadRootPackage($rm, $config, $parser, $guesser, $io);
  14581. $package = $loader->load($localConfig, 'Composer\Package\RootPackage', $cwd);
  14582. $composer->setPackage($package);
  14583. $this->addLocalRepository($io, $rm, $vendorDir, $package);
  14584. $im = $this->createInstallationManager($loop, $io, $dispatcher);
  14585. $composer->setInstallationManager($im);
  14586. if ($fullLoad) {
  14587. $dm = $this->createDownloadManager($io, $config, $httpDownloader, $process, $dispatcher);
  14588. $composer->setDownloadManager($dm);
  14589. $generator = new AutoloadGenerator($dispatcher, $io);
  14590. $composer->setAutoloadGenerator($generator);
  14591. $am = $this->createArchiveManager($config, $dm, $loop);
  14592. $composer->setArchiveManager($am);
  14593. }
  14594. $this->createDefaultInstallers($im, $composer, $io, $process);
  14595. if ($fullLoad) {
  14596. $globalComposer = null;
  14597. if (realpath($config->get('home')) !== $cwd) {
  14598. $globalComposer = $this->createGlobalComposer($io, $config, $disablePlugins);
  14599. }
  14600. $pm = $this->createPluginManager($io, $composer, $globalComposer, $disablePlugins);
  14601. $composer->setPluginManager($pm);
  14602. $pm->loadInstalledPlugins();
  14603. }
  14604. if ($fullLoad && isset($composerFile)) {
  14605. $lockFile = self::getLockFile($composerFile);
  14606. $locker = new Package\Locker($io, new JsonFile($lockFile, null, $io), $im, file_get_contents($composerFile), $process);
  14607. $composer->setLocker($locker);
  14608. }
  14609. if ($fullLoad) {
  14610. $initEvent = new Event(PluginEvents::INIT);
  14611. $composer->getEventDispatcher()->dispatch($initEvent->getName(), $initEvent);
  14612. if ($rm->getLocalRepository()) {
  14613. $this->purgePackages($rm->getLocalRepository(), $im);
  14614. }
  14615. }
  14616. return $composer;
  14617. }
  14618. public static function createGlobal(IOInterface $io, $disablePlugins = false)
  14619. {
  14620. $factory = new static();
  14621. return $factory->createGlobalComposer($io, static::createConfig($io), $disablePlugins, true);
  14622. }
  14623. protected function addLocalRepository(IOInterface $io, RepositoryManager $rm, $vendorDir, RootPackageInterface $rootPackage)
  14624. {
  14625. $rm->setLocalRepository(new Repository\InstalledFilesystemRepository(new JsonFile($vendorDir.'/composer/installed.json', null, $io), true, $rootPackage));
  14626. }
  14627. protected function createGlobalComposer(IOInterface $io, Config $config, $disablePlugins, $fullLoad = false)
  14628. {
  14629. $composer = null;
  14630. try {
  14631. $composer = $this->createComposer($io, $config->get('home') . '/composer.json', $disablePlugins, $config->get('home'), $fullLoad);
  14632. } catch (\Exception $e) {
  14633. $io->writeError('Failed to initialize global composer: '.$e->getMessage(), true, IOInterface::DEBUG);
  14634. }
  14635. return $composer;
  14636. }
  14637. public function createDownloadManager(IOInterface $io, Config $config, HttpDownloader $httpDownloader, ProcessExecutor $process, EventDispatcher $eventDispatcher = null)
  14638. {
  14639. $cache = null;
  14640. if ($config->get('cache-files-ttl') > 0) {
  14641. $cache = new Cache($io, $config->get('cache-files-dir'), 'a-z0-9_./');
  14642. $cache->setReadOnly($config->get('cache-read-only'));
  14643. }
  14644. $fs = new Filesystem($process);
  14645. $dm = new Downloader\DownloadManager($io, false, $fs);
  14646. switch ($preferred = $config->get('preferred-install')) {
  14647. case 'dist':
  14648. $dm->setPreferDist(true);
  14649. break;
  14650. case 'source':
  14651. $dm->setPreferSource(true);
  14652. break;
  14653. case 'auto':
  14654. default:
  14655. break;
  14656. }
  14657. if (is_array($preferred)) {
  14658. $dm->setPreferences($preferred);
  14659. }
  14660. $dm->setDownloader('git', new Downloader\GitDownloader($io, $config, $process, $fs));
  14661. $dm->setDownloader('svn', new Downloader\SvnDownloader($io, $config, $process, $fs));
  14662. $dm->setDownloader('fossil', new Downloader\FossilDownloader($io, $config, $process, $fs));
  14663. $dm->setDownloader('hg', new Downloader\HgDownloader($io, $config, $process, $fs));
  14664. $dm->setDownloader('perforce', new Downloader\PerforceDownloader($io, $config, $process, $fs));
  14665. $dm->setDownloader('zip', new Downloader\ZipDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14666. $dm->setDownloader('rar', new Downloader\RarDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14667. $dm->setDownloader('tar', new Downloader\TarDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14668. $dm->setDownloader('gzip', new Downloader\GzipDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14669. $dm->setDownloader('xz', new Downloader\XzDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14670. $dm->setDownloader('phar', new Downloader\PharDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14671. $dm->setDownloader('file', new Downloader\FileDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14672. $dm->setDownloader('path', new Downloader\PathDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14673. return $dm;
  14674. }
  14675. public function createArchiveManager(Config $config, Downloader\DownloadManager $dm, Loop $loop)
  14676. {
  14677. $am = new Archiver\ArchiveManager($dm, $loop);
  14678. $am->addArchiver(new Archiver\ZipArchiver);
  14679. $am->addArchiver(new Archiver\PharArchiver);
  14680. return $am;
  14681. }
  14682. protected function createPluginManager(IOInterface $io, Composer $composer, Composer $globalComposer = null, $disablePlugins = false)
  14683. {
  14684. return new Plugin\PluginManager($io, $composer, $globalComposer, $disablePlugins);
  14685. }
  14686. public function createInstallationManager(Loop $loop, IOInterface $io, EventDispatcher $eventDispatcher = null)
  14687. {
  14688. return new Installer\InstallationManager($loop, $io, $eventDispatcher);
  14689. }
  14690. protected function createDefaultInstallers(Installer\InstallationManager $im, Composer $composer, IOInterface $io, ProcessExecutor $process = null)
  14691. {
  14692. $fs = new Filesystem($process);
  14693. $binaryInstaller = new Installer\BinaryInstaller($io, rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $fs);
  14694. $im->addInstaller(new Installer\LibraryInstaller($io, $composer, null, $fs, $binaryInstaller));
  14695. $im->addInstaller(new Installer\PluginInstaller($io, $composer, $fs, $binaryInstaller));
  14696. $im->addInstaller(new Installer\MetapackageInstaller($io));
  14697. }
  14698. protected function purgePackages(WritableRepositoryInterface $repo, Installer\InstallationManager $im)
  14699. {
  14700. foreach ($repo->getPackages() as $package) {
  14701. if (!$im->isPackageInstalled($repo, $package)) {
  14702. $repo->removePackage($package);
  14703. }
  14704. }
  14705. }
  14706. protected function loadRootPackage(RepositoryManager $rm, Config $config, VersionParser $parser, VersionGuesser $guesser, IOInterface $io)
  14707. {
  14708. return new Package\Loader\RootPackageLoader($rm, $config, $parser, $guesser, $io);
  14709. }
  14710. public static function create(IOInterface $io, $config = null, $disablePlugins = false)
  14711. {
  14712. $factory = new static();
  14713. return $factory->createComposer($io, $config, $disablePlugins);
  14714. }
  14715. public static function createHttpDownloader(IOInterface $io, Config $config, $options = array())
  14716. {
  14717. static $warned = false;
  14718. $disableTls = false;
  14719. if (isset($_SERVER['argv']) && in_array('disable-tls', $_SERVER['argv']) && (in_array('conf', $_SERVER['argv']) || in_array('config', $_SERVER['argv']))) {
  14720. $warned = true;
  14721. $disableTls = !extension_loaded('openssl');
  14722. } elseif ($config && $config->get('disable-tls') === true) {
  14723. if (!$warned) {
  14724. $io->writeError('<warning>You are running Composer with SSL/TLS protection disabled.</warning>');
  14725. }
  14726. $warned = true;
  14727. $disableTls = true;
  14728. } elseif (!extension_loaded('openssl')) {
  14729. throw new Exception\NoSslException('The openssl extension is required for SSL/TLS protection but is not available. '
  14730. . '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.');
  14731. }
  14732. $httpDownloaderOptions = array();
  14733. if ($disableTls === false) {
  14734. if ($config && $config->get('cafile')) {
  14735. $httpDownloaderOptions['ssl']['cafile'] = $config->get('cafile');
  14736. }
  14737. if ($config && $config->get('capath')) {
  14738. $httpDownloaderOptions['ssl']['capath'] = $config->get('capath');
  14739. }
  14740. $httpDownloaderOptions = array_replace_recursive($httpDownloaderOptions, $options);
  14741. }
  14742. try {
  14743. $httpDownloader = new HttpDownloader($io, $config, $httpDownloaderOptions, $disableTls);
  14744. } catch (TransportException $e) {
  14745. if (false !== strpos($e->getMessage(), 'cafile')) {
  14746. $io->write('<error>Unable to locate a valid CA certificate file. You must set a valid \'cafile\' option.</error>');
  14747. $io->write('<error>A valid CA certificate file is required for SSL/TLS protection.</error>');
  14748. if (PHP_VERSION_ID < 50600) {
  14749. $io->write('<error>It is recommended you upgrade to PHP 5.6+ which can detect your system CA file automatically.</error>');
  14750. }
  14751. $io->write('<error>You can disable this error, at your own risk, by setting the \'disable-tls\' option to true.</error>');
  14752. }
  14753. throw $e;
  14754. }
  14755. return $httpDownloader;
  14756. }
  14757. private static function useXdg()
  14758. {
  14759. foreach (array_keys($_SERVER) as $key) {
  14760. if (strpos($key, 'XDG_') === 0) {
  14761. return true;
  14762. }
  14763. }
  14764. if (is_dir('/etc/xdg')) {
  14765. return true;
  14766. }
  14767. return false;
  14768. }
  14769. private static function getUserDir()
  14770. {
  14771. $home = getenv('HOME');
  14772. if (!$home) {
  14773. throw new \RuntimeException('The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly');
  14774. }
  14775. return rtrim(strtr($home, '\\', '/'), '/');
  14776. }
  14777. }
  14778. <?php
  14779. namespace Composer\IO;
  14780. use Composer\Config;
  14781. use Composer\Util\ProcessExecutor;
  14782. use Psr\Log\LogLevel;
  14783. abstract class BaseIO implements IOInterface
  14784. {
  14785. protected $authentications = array();
  14786. public function getAuthentications()
  14787. {
  14788. return $this->authentications;
  14789. }
  14790. public function resetAuthentications()
  14791. {
  14792. $this->authentications = array();
  14793. }
  14794. public function hasAuthentication($repositoryName)
  14795. {
  14796. return isset($this->authentications[$repositoryName]);
  14797. }
  14798. public function getAuthentication($repositoryName)
  14799. {
  14800. if (isset($this->authentications[$repositoryName])) {
  14801. return $this->authentications[$repositoryName];
  14802. }
  14803. return array('username' => null, 'password' => null);
  14804. }
  14805. public function setAuthentication($repositoryName, $username, $password = null)
  14806. {
  14807. $this->authentications[$repositoryName] = array('username' => $username, 'password' => $password);
  14808. }
  14809. public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL)
  14810. {
  14811. $this->write($messages, $newline, $verbosity);
  14812. }
  14813. public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL)
  14814. {
  14815. $this->writeError($messages, $newline, $verbosity);
  14816. }
  14817. protected function checkAndSetAuthentication($repositoryName, $username, $password = null)
  14818. {
  14819. if ($this->hasAuthentication($repositoryName)) {
  14820. $auth = $this->getAuthentication($repositoryName);
  14821. if ($auth['username'] === $username && $auth['password'] === $password) {
  14822. return;
  14823. }
  14824. $this->writeError(
  14825. sprintf(
  14826. "<warning>Warning: You should avoid overwriting already defined auth settings for %s.</warning>",
  14827. $repositoryName
  14828. )
  14829. );
  14830. }
  14831. $this->setAuthentication($repositoryName, $username, $password);
  14832. }
  14833. public function loadConfiguration(Config $config)
  14834. {
  14835. $bitbucketOauth = $config->get('bitbucket-oauth') ?: array();
  14836. $githubOauth = $config->get('github-oauth') ?: array();
  14837. $gitlabOauth = $config->get('gitlab-oauth') ?: array();
  14838. $gitlabToken = $config->get('gitlab-token') ?: array();
  14839. $httpBasic = $config->get('http-basic') ?: array();
  14840. $bearerToken = $config->get('bearer') ?: array();
  14841. foreach ($bitbucketOauth as $domain => $cred) {
  14842. $this->checkAndSetAuthentication($domain, $cred['consumer-key'], $cred['consumer-secret']);
  14843. }
  14844. foreach ($githubOauth as $domain => $token) {
  14845. if (!preg_match('{^[.a-z0-9]+$}', $token)) {
  14846. throw new \UnexpectedValueException('Your github oauth token for '.$domain.' contains invalid characters: "'.$token.'"');
  14847. }
  14848. $this->checkAndSetAuthentication($domain, $token, 'x-oauth-basic');
  14849. }
  14850. foreach ($gitlabOauth as $domain => $token) {
  14851. $this->checkAndSetAuthentication($domain, $token, 'oauth2');
  14852. }
  14853. foreach ($gitlabToken as $domain => $token) {
  14854. $username = is_array($token) && array_key_exists("username", $token) ? $token["username"] : $token;
  14855. $password = is_array($token) && array_key_exists("token", $token) ? $token["token"] : 'private-token';
  14856. $this->checkAndSetAuthentication($domain, $username, $password);
  14857. }
  14858. foreach ($httpBasic as $domain => $cred) {
  14859. $this->checkAndSetAuthentication($domain, $cred['username'], $cred['password']);
  14860. }
  14861. foreach ($bearerToken as $domain => $token) {
  14862. $this->checkAndSetAuthentication($domain, $token, 'bearer');
  14863. }
  14864. ProcessExecutor::setTimeout((int) $config->get('process-timeout'));
  14865. }
  14866. public function emergency($message, array $context = array())
  14867. {
  14868. return $this->log(LogLevel::EMERGENCY, $message, $context);
  14869. }
  14870. public function alert($message, array $context = array())
  14871. {
  14872. return $this->log(LogLevel::ALERT, $message, $context);
  14873. }
  14874. public function critical($message, array $context = array())
  14875. {
  14876. return $this->log(LogLevel::CRITICAL, $message, $context);
  14877. }
  14878. public function error($message, array $context = array())
  14879. {
  14880. return $this->log(LogLevel::ERROR, $message, $context);
  14881. }
  14882. public function warning($message, array $context = array())
  14883. {
  14884. return $this->log(LogLevel::WARNING, $message, $context);
  14885. }
  14886. public function notice($message, array $context = array())
  14887. {
  14888. return $this->log(LogLevel::NOTICE, $message, $context);
  14889. }
  14890. public function info($message, array $context = array())
  14891. {
  14892. return $this->log(LogLevel::INFO, $message, $context);
  14893. }
  14894. public function debug($message, array $context = array())
  14895. {
  14896. return $this->log(LogLevel::DEBUG, $message, $context);
  14897. }
  14898. public function log($level, $message, array $context = array())
  14899. {
  14900. if (in_array($level, array(LogLevel::EMERGENCY, LogLevel::ALERT, LogLevel::CRITICAL, LogLevel::ERROR))) {
  14901. $this->writeError('<error>'.$message.'</error>');
  14902. } elseif ($level === LogLevel::WARNING) {
  14903. $this->writeError('<warning>'.$message.'</warning>');
  14904. } elseif ($level === LogLevel::NOTICE) {
  14905. $this->writeError('<info>'.$message.'</info>', true, self::VERBOSE);
  14906. } elseif ($level === LogLevel::INFO) {
  14907. $this->writeError('<info>'.$message.'</info>', true, self::VERY_VERBOSE);
  14908. } else {
  14909. $this->writeError($message, true, self::DEBUG);
  14910. }
  14911. }
  14912. }
  14913. <?php
  14914. namespace Composer\IO;
  14915. use Symfony\Component\Console\Helper\QuestionHelper;
  14916. use Symfony\Component\Console\Output\StreamOutput;
  14917. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  14918. use Symfony\Component\Console\Input\StreamableInputInterface;
  14919. use Symfony\Component\Console\Input\StringInput;
  14920. use Symfony\Component\Console\Helper\HelperSet;
  14921. class BufferIO extends ConsoleIO
  14922. {
  14923. public function __construct($input = '', $verbosity = StreamOutput::VERBOSITY_NORMAL, OutputFormatterInterface $formatter = null)
  14924. {
  14925. $input = new StringInput($input);
  14926. $input->setInteractive(false);
  14927. $output = new StreamOutput(fopen('php://memory', 'rw'), $verbosity, $formatter ? $formatter->isDecorated() : false, $formatter);
  14928. parent::__construct($input, $output, new HelperSet(array(
  14929. new QuestionHelper(),
  14930. )));
  14931. }
  14932. public function getOutput()
  14933. {
  14934. fseek($this->output->getStream(), 0);
  14935. $output = stream_get_contents($this->output->getStream());
  14936. $output = preg_replace_callback("{(?<=^|\n|\x08)(.+?)(\x08+)}", function ($matches) {
  14937. $pre = strip_tags($matches[1]);
  14938. if (strlen($pre) === strlen($matches[2])) {
  14939. return '';
  14940. }
  14941. return rtrim($matches[1])."\n";
  14942. }, $output);
  14943. return $output;
  14944. }
  14945. public function setUserInputs(array $inputs)
  14946. {
  14947. if (!$this->input instanceof StreamableInputInterface) {
  14948. throw new \RuntimeException('Setting the user inputs requires at least the version 3.2 of the symfony/console component.');
  14949. }
  14950. $this->input->setStream($this->createStream($inputs));
  14951. $this->input->setInteractive(true);
  14952. }
  14953. private function createStream(array $inputs)
  14954. {
  14955. $stream = fopen('php://memory', 'r+');
  14956. foreach ($inputs as $input) {
  14957. fwrite($stream, $input.PHP_EOL);
  14958. }
  14959. rewind($stream);
  14960. return $stream;
  14961. }
  14962. }
  14963. <?php
  14964. namespace Composer\IO;
  14965. use Composer\Question\StrictConfirmationQuestion;
  14966. use Symfony\Component\Console\Helper\HelperSet;
  14967. use Symfony\Component\Console\Helper\ProgressBar;
  14968. use Symfony\Component\Console\Input\InputInterface;
  14969. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  14970. use Symfony\Component\Console\Output\OutputInterface;
  14971. use Symfony\Component\Console\Question\ChoiceQuestion;
  14972. use Symfony\Component\Console\Question\Question;
  14973. class ConsoleIO extends BaseIO
  14974. {
  14975. protected $input;
  14976. protected $output;
  14977. protected $helperSet;
  14978. protected $lastMessage;
  14979. protected $lastMessageErr;
  14980. private $startTime;
  14981. private $verbosityMap;
  14982. public function __construct(InputInterface $input, OutputInterface $output, HelperSet $helperSet)
  14983. {
  14984. $this->input = $input;
  14985. $this->output = $output;
  14986. $this->helperSet = $helperSet;
  14987. $this->verbosityMap = array(
  14988. self::QUIET => OutputInterface::VERBOSITY_QUIET,
  14989. self::NORMAL => OutputInterface::VERBOSITY_NORMAL,
  14990. self::VERBOSE => OutputInterface::VERBOSITY_VERBOSE,
  14991. self::VERY_VERBOSE => OutputInterface::VERBOSITY_VERY_VERBOSE,
  14992. self::DEBUG => OutputInterface::VERBOSITY_DEBUG,
  14993. );
  14994. }
  14995. public function enableDebugging($startTime)
  14996. {
  14997. $this->startTime = $startTime;
  14998. }
  14999. public function isInteractive()
  15000. {
  15001. return $this->input->isInteractive();
  15002. }
  15003. public function isDecorated()
  15004. {
  15005. return $this->output->isDecorated();
  15006. }
  15007. public function isVerbose()
  15008. {
  15009. return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE;
  15010. }
  15011. public function isVeryVerbose()
  15012. {
  15013. return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE;
  15014. }
  15015. public function isDebug()
  15016. {
  15017. return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG;
  15018. }
  15019. public function write($messages, $newline = true, $verbosity = self::NORMAL)
  15020. {
  15021. $this->doWrite($messages, $newline, false, $verbosity);
  15022. }
  15023. public function writeError($messages, $newline = true, $verbosity = self::NORMAL)
  15024. {
  15025. $this->doWrite($messages, $newline, true, $verbosity);
  15026. }
  15027. public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL)
  15028. {
  15029. $this->doWrite($messages, $newline, false, $verbosity, true);
  15030. }
  15031. public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL)
  15032. {
  15033. $this->doWrite($messages, $newline, true, $verbosity, true);
  15034. }
  15035. private function doWrite($messages, $newline, $stderr, $verbosity, $raw = false)
  15036. {
  15037. $sfVerbosity = $this->verbosityMap[$verbosity];
  15038. if ($sfVerbosity > $this->output->getVerbosity()) {
  15039. return;
  15040. }
  15041. if (OutputInterface::VERBOSITY_QUIET === 0) {
  15042. $sfVerbosity = OutputInterface::OUTPUT_NORMAL;
  15043. }
  15044. if ($raw) {
  15045. if ($sfVerbosity === OutputInterface::OUTPUT_NORMAL) {
  15046. $sfVerbosity = OutputInterface::OUTPUT_RAW;
  15047. } else {
  15048. $sfVerbosity |= OutputInterface::OUTPUT_RAW;
  15049. }
  15050. }
  15051. if (null !== $this->startTime) {
  15052. $memoryUsage = memory_get_usage() / 1024 / 1024;
  15053. $timeSpent = microtime(true) - $this->startTime;
  15054. $messages = array_map(function ($message) use ($memoryUsage, $timeSpent) {
  15055. return sprintf('[%.1fMiB/%.2fs] %s', $memoryUsage, $timeSpent, $message);
  15056. }, (array) $messages);
  15057. }
  15058. if (true === $stderr && $this->output instanceof ConsoleOutputInterface) {
  15059. $this->output->getErrorOutput()->write($messages, $newline, $sfVerbosity);
  15060. $this->lastMessageErr = implode($newline ? "\n" : '', (array) $messages);
  15061. return;
  15062. }
  15063. $this->output->write($messages, $newline, $sfVerbosity);
  15064. $this->lastMessage = implode($newline ? "\n" : '', (array) $messages);
  15065. }
  15066. public function overwrite($messages, $newline = true, $size = null, $verbosity = self::NORMAL)
  15067. {
  15068. $this->doOverwrite($messages, $newline, $size, false, $verbosity);
  15069. }
  15070. public function overwriteError($messages, $newline = true, $size = null, $verbosity = self::NORMAL)
  15071. {
  15072. $this->doOverwrite($messages, $newline, $size, true, $verbosity);
  15073. }
  15074. private function doOverwrite($messages, $newline, $size, $stderr, $verbosity)
  15075. {
  15076. $messages = implode($newline ? "\n" : '', (array) $messages);
  15077. if (!isset($size)) {
  15078. $size = strlen(strip_tags($stderr ? $this->lastMessageErr : $this->lastMessage));
  15079. }
  15080. $this->doWrite(str_repeat("\x08", $size), false, $stderr, $verbosity);
  15081. $this->doWrite($messages, false, $stderr, $verbosity);
  15082. $fill = $size - strlen(strip_tags($messages));
  15083. if ($fill > 0) {
  15084. $this->doWrite(str_repeat(' ', $fill), false, $stderr, $verbosity);
  15085. $this->doWrite(str_repeat("\x08", $fill), false, $stderr, $verbosity);
  15086. }
  15087. if ($newline) {
  15088. $this->doWrite('', true, $stderr, $verbosity);
  15089. }
  15090. if ($stderr) {
  15091. $this->lastMessageErr = $messages;
  15092. } else {
  15093. $this->lastMessage = $messages;
  15094. }
  15095. }
  15096. public function getProgressBar($max = 0)
  15097. {
  15098. return new ProgressBar($this->getErrorOutput(), $max);
  15099. }
  15100. public function ask($question, $default = null)
  15101. {
  15102. $helper = $this->helperSet->get('question');
  15103. $question = new Question($question, $default);
  15104. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  15105. }
  15106. public function askConfirmation($question, $default = true)
  15107. {
  15108. $helper = $this->helperSet->get('question');
  15109. $question = new StrictConfirmationQuestion($question, $default);
  15110. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  15111. }
  15112. public function askAndValidate($question, $validator, $attempts = null, $default = null)
  15113. {
  15114. $helper = $this->helperSet->get('question');
  15115. $question = new Question($question, $default);
  15116. $question->setValidator($validator);
  15117. $question->setMaxAttempts($attempts);
  15118. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  15119. }
  15120. public function askAndHideAnswer($question)
  15121. {
  15122. $helper = $this->helperSet->get('question');
  15123. $question = new Question($question);
  15124. $question->setHidden(true);
  15125. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  15126. }
  15127. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  15128. {
  15129. $helper = $this->helperSet->get('question');
  15130. $question = new ChoiceQuestion($question, $choices, $default);
  15131. $question->setMaxAttempts($attempts ?: null);
  15132. $question->setErrorMessage($errorMessage);
  15133. $question->setMultiselect($multiselect);
  15134. $result = $helper->ask($this->input, $this->getErrorOutput(), $question);
  15135. if (!is_array($result)) {
  15136. return (string) array_search($result, $choices, true);
  15137. }
  15138. $results = array();
  15139. foreach ($choices as $index => $choice) {
  15140. if (in_array($choice, $result, true)) {
  15141. $results[] = (string) $index;
  15142. }
  15143. }
  15144. return $results;
  15145. }
  15146. private function getErrorOutput()
  15147. {
  15148. if ($this->output instanceof ConsoleOutputInterface) {
  15149. return $this->output->getErrorOutput();
  15150. }
  15151. return $this->output;
  15152. }
  15153. }
  15154. <?php
  15155. namespace Composer\IO;
  15156. use Composer\Config;
  15157. use Psr\Log\LoggerInterface;
  15158. interface IOInterface extends LoggerInterface
  15159. {
  15160. const QUIET = 1;
  15161. const NORMAL = 2;
  15162. const VERBOSE = 4;
  15163. const VERY_VERBOSE = 8;
  15164. const DEBUG = 16;
  15165. public function isInteractive();
  15166. public function isVerbose();
  15167. public function isVeryVerbose();
  15168. public function isDebug();
  15169. public function isDecorated();
  15170. public function write($messages, $newline = true, $verbosity = self::NORMAL);
  15171. public function writeError($messages, $newline = true, $verbosity = self::NORMAL);
  15172. public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL);
  15173. public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL);
  15174. public function overwrite($messages, $newline = true, $size = null, $verbosity = self::NORMAL);
  15175. public function overwriteError($messages, $newline = true, $size = null, $verbosity = self::NORMAL);
  15176. public function ask($question, $default = null);
  15177. public function askConfirmation($question, $default = true);
  15178. public function askAndValidate($question, $validator, $attempts = null, $default = null);
  15179. public function askAndHideAnswer($question);
  15180. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false);
  15181. public function getAuthentications();
  15182. public function hasAuthentication($repositoryName);
  15183. public function getAuthentication($repositoryName);
  15184. public function setAuthentication($repositoryName, $username, $password = null);
  15185. public function loadConfiguration(Config $config);
  15186. }
  15187. <?php
  15188. namespace Composer\IO;
  15189. class NullIO extends BaseIO
  15190. {
  15191. public function isInteractive()
  15192. {
  15193. return false;
  15194. }
  15195. public function isVerbose()
  15196. {
  15197. return false;
  15198. }
  15199. public function isVeryVerbose()
  15200. {
  15201. return false;
  15202. }
  15203. public function isDebug()
  15204. {
  15205. return false;
  15206. }
  15207. public function isDecorated()
  15208. {
  15209. return false;
  15210. }
  15211. public function write($messages, $newline = true, $verbosity = self::NORMAL)
  15212. {
  15213. }
  15214. public function writeError($messages, $newline = true, $verbosity = self::NORMAL)
  15215. {
  15216. }
  15217. public function overwrite($messages, $newline = true, $size = 80, $verbosity = self::NORMAL)
  15218. {
  15219. }
  15220. public function overwriteError($messages, $newline = true, $size = 80, $verbosity = self::NORMAL)
  15221. {
  15222. }
  15223. public function ask($question, $default = null)
  15224. {
  15225. return $default;
  15226. }
  15227. public function askConfirmation($question, $default = true)
  15228. {
  15229. return $default;
  15230. }
  15231. public function askAndValidate($question, $validator, $attempts = false, $default = null)
  15232. {
  15233. return $default;
  15234. }
  15235. public function askAndHideAnswer($question)
  15236. {
  15237. return null;
  15238. }
  15239. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  15240. {
  15241. return $default;
  15242. }
  15243. }
  15244. <?php
  15245. namespace Composer;
  15246. use Composer\Semver\VersionParser;
  15247. class InstalledVersions
  15248. {
  15249. private static $installed;
  15250. public static function getInstalledPackages()
  15251. {
  15252. return array_keys(self::$installed['versions']);
  15253. }
  15254. public static function isInstalled($packageName)
  15255. {
  15256. return isset(self::$installed['versions'][$packageName]);
  15257. }
  15258. public static function satisfies(VersionParser $parser, $packageName, $constraint)
  15259. {
  15260. $constraint = $parser->parseConstraints($constraint);
  15261. $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
  15262. return $provided->matches($constraint);
  15263. }
  15264. public static function getVersionRanges($packageName)
  15265. {
  15266. if (!isset(self::$installed['versions'][$packageName])) {
  15267. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  15268. }
  15269. $ranges = array();
  15270. if (isset(self::$installed['versions'][$packageName]['pretty_version'])) {
  15271. $ranges[] = self::$installed['versions'][$packageName]['pretty_version'];
  15272. }
  15273. if (array_key_exists('aliases', self::$installed['versions'][$packageName])) {
  15274. $ranges = array_merge($ranges, self::$installed['versions'][$packageName]['aliases']);
  15275. }
  15276. if (array_key_exists('replaced', self::$installed['versions'][$packageName])) {
  15277. $ranges = array_merge($ranges, self::$installed['versions'][$packageName]['replaced']);
  15278. }
  15279. if (array_key_exists('provided', self::$installed['versions'][$packageName])) {
  15280. $ranges = array_merge($ranges, self::$installed['versions'][$packageName]['provided']);
  15281. }
  15282. return implode(' || ', $ranges);
  15283. }
  15284. public static function getVersion($packageName)
  15285. {
  15286. if (!isset(self::$installed['versions'][$packageName])) {
  15287. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  15288. }
  15289. if (!isset(self::$installed['versions'][$packageName]['version'])) {
  15290. return null;
  15291. }
  15292. return self::$installed['versions'][$packageName]['version'];
  15293. }
  15294. public static function getPrettyVersion($packageName)
  15295. {
  15296. if (!isset(self::$installed['versions'][$packageName])) {
  15297. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  15298. }
  15299. if (!isset(self::$installed['versions'][$packageName]['pretty_version'])) {
  15300. return null;
  15301. }
  15302. return self::$installed['versions'][$packageName]['pretty_version'];
  15303. }
  15304. public static function getReference($packageName)
  15305. {
  15306. if (!isset(self::$installed['versions'][$packageName])) {
  15307. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  15308. }
  15309. if (!isset(self::$installed['versions'][$packageName]['reference'])) {
  15310. return null;
  15311. }
  15312. return self::$installed['versions'][$packageName]['reference'];
  15313. }
  15314. public static function getRootPackage()
  15315. {
  15316. return self::$installed['root'];
  15317. }
  15318. public static function getRawData()
  15319. {
  15320. return self::$installed;
  15321. }
  15322. public static function reload($data)
  15323. {
  15324. self::$installed = $data;
  15325. }
  15326. }
  15327. <?php
  15328. namespace Composer;
  15329. use Composer\Autoload\AutoloadGenerator;
  15330. use Composer\Console\GithubActionError;
  15331. use Composer\DependencyResolver\DefaultPolicy;
  15332. use Composer\DependencyResolver\LocalRepoTransaction;
  15333. use Composer\DependencyResolver\LockTransaction;
  15334. use Composer\DependencyResolver\Operation\UpdateOperation;
  15335. use Composer\DependencyResolver\Operation\InstallOperation;
  15336. use Composer\DependencyResolver\Operation\UninstallOperation;
  15337. use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
  15338. use Composer\DependencyResolver\Operation\OperationInterface;
  15339. use Composer\DependencyResolver\PolicyInterface;
  15340. use Composer\DependencyResolver\Pool;
  15341. use Composer\DependencyResolver\Request;
  15342. use Composer\DependencyResolver\Rule;
  15343. use Composer\DependencyResolver\Solver;
  15344. use Composer\DependencyResolver\SolverProblemsException;
  15345. use Composer\Downloader\DownloadManager;
  15346. use Composer\EventDispatcher\EventDispatcher;
  15347. use Composer\Installer\InstallationManager;
  15348. use Composer\Installer\InstallerEvents;
  15349. use Composer\Installer\NoopInstaller;
  15350. use Composer\Installer\SuggestedPackagesReporter;
  15351. use Composer\IO\IOInterface;
  15352. use Composer\Package\AliasPackage;
  15353. use Composer\Package\RootAliasPackage;
  15354. use Composer\Package\BasePackage;
  15355. use Composer\Package\CompletePackage;
  15356. use Composer\Package\CompletePackageInterface;
  15357. use Composer\Package\Link;
  15358. use Composer\Package\LinkConstraint\VersionConstraint;
  15359. use Composer\Package\Loader\ArrayLoader;
  15360. use Composer\Package\Dumper\ArrayDumper;
  15361. use Composer\Package\Version\VersionParser;
  15362. use Composer\Package\Package;
  15363. use Composer\Repository\ArrayRepository;
  15364. use Composer\Repository\RepositorySet;
  15365. use Composer\Semver\Constraint\Constraint;
  15366. use Composer\Package\Locker;
  15367. use Composer\Package\PackageInterface;
  15368. use Composer\Package\RootPackageInterface;
  15369. use Composer\Repository\CompositeRepository;
  15370. use Composer\Repository\InstalledArrayRepository;
  15371. use Composer\Repository\InstalledRepository;
  15372. use Composer\Repository\RootPackageRepository;
  15373. use Composer\Repository\PlatformRepository;
  15374. use Composer\Repository\RepositoryInterface;
  15375. use Composer\Repository\RepositoryManager;
  15376. use Composer\Repository\WritableRepositoryInterface;
  15377. use Composer\Script\ScriptEvents;
  15378. class Installer
  15379. {
  15380. protected $io;
  15381. protected $config;
  15382. protected $package;
  15383. protected $fixedRootPackage;
  15384. protected $downloadManager;
  15385. protected $repositoryManager;
  15386. protected $locker;
  15387. protected $installationManager;
  15388. protected $eventDispatcher;
  15389. protected $autoloadGenerator;
  15390. protected $preferSource = false;
  15391. protected $preferDist = false;
  15392. protected $optimizeAutoloader = false;
  15393. protected $classMapAuthoritative = false;
  15394. protected $apcuAutoloader = false;
  15395. protected $apcuAutoloaderPrefix;
  15396. protected $devMode = false;
  15397. protected $dryRun = false;
  15398. protected $verbose = false;
  15399. protected $update = false;
  15400. protected $install = true;
  15401. protected $dumpAutoloader = true;
  15402. protected $runScripts = true;
  15403. protected $ignorePlatformReqs = false;
  15404. protected $preferStable = false;
  15405. protected $preferLowest = false;
  15406. protected $writeLock;
  15407. protected $executeOperations = true;
  15408. protected $updateMirrors = false;
  15409. protected $updateAllowList;
  15410. protected $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  15411. protected $suggestedPackagesReporter;
  15412. protected $additionalFixedRepository;
  15413. public function __construct(IOInterface $io, Config $config, RootPackageInterface $package, DownloadManager $downloadManager, RepositoryManager $repositoryManager, Locker $locker, InstallationManager $installationManager, EventDispatcher $eventDispatcher, AutoloadGenerator $autoloadGenerator)
  15414. {
  15415. $this->io = $io;
  15416. $this->config = $config;
  15417. $this->package = $package;
  15418. $this->downloadManager = $downloadManager;
  15419. $this->repositoryManager = $repositoryManager;
  15420. $this->locker = $locker;
  15421. $this->installationManager = $installationManager;
  15422. $this->eventDispatcher = $eventDispatcher;
  15423. $this->autoloadGenerator = $autoloadGenerator;
  15424. $this->writeLock = $config->get('lock');
  15425. }
  15426. public function run()
  15427. {
  15428. gc_collect_cycles();
  15429. gc_disable();
  15430. if ($this->updateAllowList && $this->updateMirrors) {
  15431. throw new \RuntimeException("The installer options updateMirrors and updateAllowList are mutually exclusive.");
  15432. }
  15433. $isFreshInstall = $this->repositoryManager->getLocalRepository()->isFresh();
  15434. if (!$this->update && !$this->locker->isLocked()) {
  15435. $this->io->writeError('<warning>No lock file found. Updating dependencies instead of installing from lock file. Use composer update over composer install if you do not have a lock file.</warning>');
  15436. $this->update = true;
  15437. }
  15438. if ($this->dryRun) {
  15439. $this->verbose = true;
  15440. $this->runScripts = false;
  15441. $this->executeOperations = false;
  15442. $this->writeLock = false;
  15443. $this->dumpAutoloader = false;
  15444. $this->mockLocalRepositories($this->repositoryManager);
  15445. }
  15446. if ($this->update && !$this->install) {
  15447. $this->dumpAutoloader = false;
  15448. }
  15449. if ($this->runScripts) {
  15450. $_SERVER['COMPOSER_DEV_MODE'] = $this->devMode ? '1' : '0';
  15451. putenv('COMPOSER_DEV_MODE='.$_SERVER['COMPOSER_DEV_MODE']);
  15452. $eventName = $this->update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD;
  15453. $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
  15454. }
  15455. $this->downloadManager->setPreferSource($this->preferSource);
  15456. $this->downloadManager->setPreferDist($this->preferDist);
  15457. $localRepo = $this->repositoryManager->getLocalRepository();
  15458. if (!$this->suggestedPackagesReporter) {
  15459. $this->suggestedPackagesReporter = new SuggestedPackagesReporter($this->io);
  15460. }
  15461. try {
  15462. if ($this->update) {
  15463. $res = $this->doUpdate($localRepo, $this->install);
  15464. } else {
  15465. $res = $this->doInstall($localRepo);
  15466. }
  15467. if ($res !== 0) {
  15468. return $res;
  15469. }
  15470. } catch (\Exception $e) {
  15471. if ($this->executeOperations && $this->install && $this->config->get('notify-on-install')) {
  15472. $this->installationManager->notifyInstalls($this->io);
  15473. }
  15474. throw $e;
  15475. }
  15476. if ($this->executeOperations && $this->install && $this->config->get('notify-on-install')) {
  15477. $this->installationManager->notifyInstalls($this->io);
  15478. }
  15479. if ($this->update) {
  15480. $installedRepo = new InstalledRepository(array(
  15481. $this->locker->getLockedRepository($this->devMode),
  15482. $this->createPlatformRepo(false),
  15483. new RootPackageRepository(clone $this->package),
  15484. ));
  15485. if ($isFreshInstall) {
  15486. $this->suggestedPackagesReporter->addSuggestionsFromPackage($this->package);
  15487. }
  15488. $this->suggestedPackagesReporter->outputMinimalistic($installedRepo);
  15489. }
  15490. $lockedRepository = $this->locker->getLockedRepository(true);
  15491. foreach ($lockedRepository->getPackages() as $package) {
  15492. if (!$package instanceof CompletePackage || !$package->isAbandoned()) {
  15493. continue;
  15494. }
  15495. $replacement = is_string($package->getReplacementPackage())
  15496. ? 'Use ' . $package->getReplacementPackage() . ' instead'
  15497. : 'No replacement was suggested';
  15498. $this->io->writeError(
  15499. sprintf(
  15500. "<warning>Package %s is abandoned, you should avoid using it. %s.</warning>",
  15501. $package->getPrettyName(),
  15502. $replacement
  15503. )
  15504. );
  15505. }
  15506. if ($this->dumpAutoloader) {
  15507. if ($this->optimizeAutoloader) {
  15508. $this->io->writeError('<info>Generating optimized autoload files</info>');
  15509. } else {
  15510. $this->io->writeError('<info>Generating autoload files</info>');
  15511. }
  15512. $this->autoloadGenerator->setDevMode($this->devMode);
  15513. $this->autoloadGenerator->setClassMapAuthoritative($this->classMapAuthoritative);
  15514. $this->autoloadGenerator->setApcu($this->apcuAutoloader, $this->apcuAutoloaderPrefix);
  15515. $this->autoloadGenerator->setRunScripts($this->runScripts);
  15516. $this->autoloadGenerator->setIgnorePlatformRequirements($this->ignorePlatformReqs);
  15517. $this->autoloadGenerator->dump($this->config, $localRepo, $this->package, $this->installationManager, 'composer', $this->optimizeAutoloader);
  15518. }
  15519. if ($this->install && $this->executeOperations) {
  15520. foreach ($localRepo->getPackages() as $package) {
  15521. $this->installationManager->ensureBinariesPresence($package);
  15522. }
  15523. }
  15524. $fundingCount = 0;
  15525. foreach ($localRepo->getPackages() as $package) {
  15526. if ($package instanceof CompletePackageInterface && !$package instanceof AliasPackage && $package->getFunding()) {
  15527. $fundingCount++;
  15528. }
  15529. }
  15530. if ($fundingCount) {
  15531. $this->io->writeError(array(
  15532. sprintf(
  15533. "<info>%d package%s you are using %s looking for funding.</info>",
  15534. $fundingCount,
  15535. 1 === $fundingCount ? '' : 's',
  15536. 1 === $fundingCount ? 'is' : 'are'
  15537. ),
  15538. '<info>Use the `composer fund` command to find out more!</info>',
  15539. ));
  15540. }
  15541. if ($this->runScripts) {
  15542. $eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD;
  15543. $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
  15544. }
  15545. if (!defined('HHVM_VERSION')) {
  15546. gc_enable();
  15547. }
  15548. return 0;
  15549. }
  15550. protected function doUpdate(RepositoryInterface $localRepo, $doInstall)
  15551. {
  15552. $platformRepo = $this->createPlatformRepo(true);
  15553. $aliases = $this->getRootAliases(true);
  15554. $lockedRepository = null;
  15555. if ($this->locker->isLocked()) {
  15556. $lockedRepository = $this->locker->getLockedRepository(true);
  15557. }
  15558. if ($this->updateAllowList) {
  15559. if (!$lockedRepository) {
  15560. $this->io->writeError('<error>Cannot update only a partial set of packages without a lock file present.</error>', true, IOInterface::QUIET);
  15561. return 1;
  15562. }
  15563. }
  15564. $this->io->writeError('<info>Loading composer repositories with package information</info>');
  15565. $policy = $this->createPolicy(true);
  15566. $repositorySet = $this->createRepositorySet(true, $platformRepo, $aliases);
  15567. $repositories = $this->repositoryManager->getRepositories();
  15568. foreach ($repositories as $repository) {
  15569. $repositorySet->addRepository($repository);
  15570. }
  15571. if ($lockedRepository) {
  15572. $repositorySet->addRepository($lockedRepository);
  15573. }
  15574. $request = $this->createRequest($this->fixedRootPackage, $platformRepo, $lockedRepository);
  15575. $this->io->writeError('<info>Updating dependencies</info>');
  15576. if ($this->updateMirrors && $lockedRepository) {
  15577. foreach ($lockedRepository->getPackages() as $lockedPackage) {
  15578. if (!$lockedPackage instanceof AliasPackage) {
  15579. $request->requireName($lockedPackage->getName(), new Constraint('==', $lockedPackage->getVersion()));
  15580. }
  15581. }
  15582. } else {
  15583. $links = array_merge($this->package->getRequires(), $this->package->getDevRequires());
  15584. foreach ($links as $link) {
  15585. $request->requireName($link->getTarget(), $link->getConstraint());
  15586. }
  15587. }
  15588. if ($this->updateAllowList) {
  15589. $request->setUpdateAllowList($this->updateAllowList, $this->updateAllowTransitiveDependencies);
  15590. }
  15591. $pool = $repositorySet->createPool($request, $this->io, $this->eventDispatcher);
  15592. $solver = new Solver($policy, $pool, $this->io);
  15593. try {
  15594. $lockTransaction = $solver->solve($request, $this->ignorePlatformReqs);
  15595. $ruleSetSize = $solver->getRuleSetSize();
  15596. $solver = null;
  15597. } catch (SolverProblemsException $e) {
  15598. $err = 'Your requirements could not be resolved to an installable set of packages.';
  15599. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose());
  15600. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  15601. $this->io->writeError($prettyProblem);
  15602. if (!$this->devMode) {
  15603. $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);
  15604. }
  15605. $ghe = new GithubActionError($this->io);
  15606. $ghe->emit($err."\n".$prettyProblem);
  15607. return max(1, $e->getCode());
  15608. }
  15609. $this->io->writeError("Analyzed ".count($pool)." packages to resolve dependencies", true, IOInterface::VERBOSE);
  15610. $this->io->writeError("Analyzed ".$ruleSetSize." rules to resolve dependencies", true, IOInterface::VERBOSE);
  15611. if (!$lockTransaction->getOperations()) {
  15612. $this->io->writeError('Nothing to modify in lock file');
  15613. }
  15614. $exitCode = $this->extractDevPackages($lockTransaction, $platformRepo, $aliases, $policy);
  15615. if ($exitCode !== 0) {
  15616. return $exitCode;
  15617. }
  15618. $platformReqs = $this->extractPlatformRequirements($this->package->getRequires());
  15619. $platformDevReqs = $this->extractPlatformRequirements($this->package->getDevRequires());
  15620. $installsUpdates = $uninstalls = array();
  15621. if ($lockTransaction->getOperations()) {
  15622. $installNames = $updateNames = $uninstallNames = array();
  15623. foreach ($lockTransaction->getOperations() as $operation) {
  15624. if ($operation instanceof InstallOperation) {
  15625. $installsUpdates[] = $operation;
  15626. $installNames[] = $operation->getPackage()->getPrettyName().':'.$operation->getPackage()->getFullPrettyVersion();
  15627. } elseif ($operation instanceof UpdateOperation) {
  15628. $installsUpdates[] = $operation;
  15629. $updateNames[] = $operation->getTargetPackage()->getPrettyName().':'.$operation->getTargetPackage()->getFullPrettyVersion();
  15630. } elseif ($operation instanceof UninstallOperation) {
  15631. $uninstalls[] = $operation;
  15632. $uninstallNames[] = $operation->getPackage()->getPrettyName();
  15633. }
  15634. }
  15635. $this->io->writeError(sprintf(
  15636. "<info>Lock file operations: %d install%s, %d update%s, %d removal%s</info>",
  15637. count($installNames),
  15638. 1 === count($installNames) ? '' : 's',
  15639. count($updateNames),
  15640. 1 === count($updateNames) ? '' : 's',
  15641. count($uninstalls),
  15642. 1 === count($uninstalls) ? '' : 's'
  15643. ));
  15644. if ($installNames) {
  15645. $this->io->writeError("Installs: ".implode(', ', $installNames), true, IOInterface::VERBOSE);
  15646. }
  15647. if ($updateNames) {
  15648. $this->io->writeError("Updates: ".implode(', ', $updateNames), true, IOInterface::VERBOSE);
  15649. }
  15650. if ($uninstalls) {
  15651. $this->io->writeError("Removals: ".implode(', ', $uninstallNames), true, IOInterface::VERBOSE);
  15652. }
  15653. }
  15654. $sortByName = function ($a, $b) {
  15655. if ($a instanceof UpdateOperation) {
  15656. $a = $a->getTargetPackage()->getName();
  15657. } else {
  15658. $a = $a->getPackage()->getName();
  15659. }
  15660. if ($b instanceof UpdateOperation) {
  15661. $b = $b->getTargetPackage()->getName();
  15662. } else {
  15663. $b = $b->getPackage()->getName();
  15664. }
  15665. return strcmp($a, $b);
  15666. };
  15667. usort($uninstalls, $sortByName);
  15668. usort($installsUpdates, $sortByName);
  15669. foreach (array_merge($uninstalls, $installsUpdates) as $operation) {
  15670. if ($operation instanceof InstallOperation) {
  15671. $this->suggestedPackagesReporter->addSuggestionsFromPackage($operation->getPackage());
  15672. }
  15673. if (false === strpos($operation->getOperationType(), 'Alias') || $this->io->isDebug()) {
  15674. $this->io->writeError(' - ' . $operation->show(true));
  15675. }
  15676. }
  15677. $updatedLock = $this->locker->setLockData(
  15678. $lockTransaction->getNewLockPackages(false, $this->updateMirrors),
  15679. $lockTransaction->getNewLockPackages(true, $this->updateMirrors),
  15680. $platformReqs,
  15681. $platformDevReqs,
  15682. $lockTransaction->getAliases($aliases),
  15683. $this->package->getMinimumStability(),
  15684. $this->package->getStabilityFlags(),
  15685. $this->preferStable || $this->package->getPreferStable(),
  15686. $this->preferLowest,
  15687. $this->config->get('platform') ?: array(),
  15688. $this->writeLock && $this->executeOperations
  15689. );
  15690. if ($updatedLock && $this->writeLock && $this->executeOperations) {
  15691. $this->io->writeError('<info>Writing lock file</info>');
  15692. }
  15693. if ($this->executeOperations && count($lockTransaction->getOperations()) > 0) {
  15694. $vendorDir = $this->config->get('vendor-dir');
  15695. if (is_dir($vendorDir)) {
  15696. @touch($vendorDir);
  15697. }
  15698. }
  15699. if ($doInstall) {
  15700. return $this->doInstall($localRepo, true);
  15701. }
  15702. return 0;
  15703. }
  15704. protected function extractDevPackages(LockTransaction $lockTransaction, $platformRepo, $aliases, $policy)
  15705. {
  15706. if (!$this->package->getDevRequires()) {
  15707. return 0;
  15708. }
  15709. $resultRepo = new ArrayRepository(array());
  15710. $loader = new ArrayLoader(null, true);
  15711. $dumper = new ArrayDumper();
  15712. foreach ($lockTransaction->getNewLockPackages(false) as $pkg) {
  15713. $resultRepo->addPackage($loader->load($dumper->dump($pkg)));
  15714. }
  15715. $repositorySet = $this->createRepositorySet(true, $platformRepo, $aliases);
  15716. $repositorySet->addRepository($resultRepo);
  15717. $request = $this->createRequest($this->fixedRootPackage, $platformRepo);
  15718. $links = $this->package->getRequires();
  15719. foreach ($links as $link) {
  15720. $request->requireName($link->getTarget(), $link->getConstraint());
  15721. }
  15722. $pool = $repositorySet->createPoolWithAllPackages();
  15723. $solver = new Solver($policy, $pool, $this->io);
  15724. try {
  15725. $nonDevLockTransaction = $solver->solve($request, $this->ignorePlatformReqs);
  15726. $solver = null;
  15727. } catch (SolverProblemsException $e) {
  15728. $err = 'Unable to find a compatible set of packages based on your non-dev requirements alone.';
  15729. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose(), true);
  15730. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  15731. $this->io->writeError('Your requirements can be resolved successfully when require-dev packages are present.');
  15732. $this->io->writeError('You may need to move packages from require-dev or some of their dependencies to require.');
  15733. $this->io->writeError($prettyProblem);
  15734. $ghe = new GithubActionError($this->io);
  15735. $ghe->emit($err."\n".$prettyProblem);
  15736. return max(1, $e->getCode());
  15737. }
  15738. $lockTransaction->setNonDevPackages($nonDevLockTransaction);
  15739. return 0;
  15740. }
  15741. protected function doInstall(RepositoryInterface $localRepo, $alreadySolved = false)
  15742. {
  15743. $this->io->writeError('<info>Installing dependencies from lock file'.($this->devMode ? ' (including require-dev)' : '').'</info>');
  15744. $lockedRepository = $this->locker->getLockedRepository($this->devMode);
  15745. if (!$alreadySolved) {
  15746. $this->io->writeError('<info>Verifying lock file contents can be installed on current platform.</info>');
  15747. $platformRepo = $this->createPlatformRepo(false);
  15748. $policy = $this->createPolicy(false);
  15749. $repositorySet = $this->createRepositorySet(false, $platformRepo, array(), $lockedRepository);
  15750. $repositorySet->addRepository($lockedRepository);
  15751. $request = $this->createRequest($this->fixedRootPackage, $platformRepo, $lockedRepository);
  15752. if (!$this->locker->isFresh()) {
  15753. $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);
  15754. }
  15755. foreach ($lockedRepository->getPackages() as $package) {
  15756. $request->fixLockedPackage($package);
  15757. }
  15758. foreach ($this->locker->getPlatformRequirements($this->devMode) as $link) {
  15759. $request->requireName($link->getTarget(), $link->getConstraint());
  15760. }
  15761. $pool = $repositorySet->createPool($request, $this->io, $this->eventDispatcher);
  15762. $solver = new Solver($policy, $pool, $this->io);
  15763. try {
  15764. $lockTransaction = $solver->solve($request, $this->ignorePlatformReqs);
  15765. $solver = null;
  15766. if (0 !== count($lockTransaction->getOperations())) {
  15767. $this->io->writeError('<error>Your lock file cannot be installed on this system without changes. Please run composer update.</error>', true, IOInterface::QUIET);
  15768. return 1;
  15769. }
  15770. } catch (SolverProblemsException $e) {
  15771. $err = 'Your lock file does not contain a compatible set of packages. Please run composer update.';
  15772. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose());
  15773. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  15774. $this->io->writeError($prettyProblem);
  15775. $ghe = new GithubActionError($this->io);
  15776. $ghe->emit($err."\n".$prettyProblem);
  15777. return max(1, $e->getCode());
  15778. }
  15779. }
  15780. $localRepoTransaction = new LocalRepoTransaction($lockedRepository, $localRepo);
  15781. $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_OPERATIONS_EXEC, $this->devMode, $this->executeOperations, $localRepoTransaction);
  15782. if (!$localRepoTransaction->getOperations()) {
  15783. $this->io->writeError('Nothing to install, update or remove');
  15784. }
  15785. if ($localRepoTransaction->getOperations()) {
  15786. $installs = $updates = $uninstalls = array();
  15787. foreach ($localRepoTransaction->getOperations() as $operation) {
  15788. if ($operation instanceof InstallOperation) {
  15789. $installs[] = $operation->getPackage()->getPrettyName().':'.$operation->getPackage()->getFullPrettyVersion();
  15790. } elseif ($operation instanceof UpdateOperation) {
  15791. $updates[] = $operation->getTargetPackage()->getPrettyName().':'.$operation->getTargetPackage()->getFullPrettyVersion();
  15792. } elseif ($operation instanceof UninstallOperation) {
  15793. $uninstalls[] = $operation->getPackage()->getPrettyName();
  15794. }
  15795. }
  15796. $this->io->writeError(sprintf(
  15797. "<info>Package operations: %d install%s, %d update%s, %d removal%s</info>",
  15798. count($installs),
  15799. 1 === count($installs) ? '' : 's',
  15800. count($updates),
  15801. 1 === count($updates) ? '' : 's',
  15802. count($uninstalls),
  15803. 1 === count($uninstalls) ? '' : 's'
  15804. ));
  15805. if ($installs) {
  15806. $this->io->writeError("Installs: ".implode(', ', $installs), true, IOInterface::VERBOSE);
  15807. }
  15808. if ($updates) {
  15809. $this->io->writeError("Updates: ".implode(', ', $updates), true, IOInterface::VERBOSE);
  15810. }
  15811. if ($uninstalls) {
  15812. $this->io->writeError("Removals: ".implode(', ', $uninstalls), true, IOInterface::VERBOSE);
  15813. }
  15814. }
  15815. if ($this->executeOperations) {
  15816. $this->installationManager->execute($localRepo, $localRepoTransaction->getOperations(), $this->devMode, $this->runScripts);
  15817. } else {
  15818. foreach ($localRepoTransaction->getOperations() as $operation) {
  15819. if (false === strpos($operation->getOperationType(), 'Alias') || $this->io->isDebug()) {
  15820. $this->io->writeError(' - ' . $operation->show(false));
  15821. }
  15822. }
  15823. }
  15824. return 0;
  15825. }
  15826. private function createPlatformRepo($forUpdate)
  15827. {
  15828. if ($forUpdate) {
  15829. $platformOverrides = $this->config->get('platform') ?: array();
  15830. } else {
  15831. $platformOverrides = $this->locker->getPlatformOverrides();
  15832. }
  15833. return new PlatformRepository(array(), $platformOverrides);
  15834. }
  15835. private function createRepositorySet($forUpdate, PlatformRepository $platformRepo, array $rootAliases = array(), $lockedRepository = null)
  15836. {
  15837. if ($forUpdate) {
  15838. $minimumStability = $this->package->getMinimumStability();
  15839. $stabilityFlags = $this->package->getStabilityFlags();
  15840. $requires = array_merge($this->package->getRequires(), $this->package->getDevRequires());
  15841. } else {
  15842. $minimumStability = $this->locker->getMinimumStability();
  15843. $stabilityFlags = $this->locker->getStabilityFlags();
  15844. $requires = array();
  15845. foreach ($lockedRepository->getPackages() as $package) {
  15846. $constraint = new Constraint('=', $package->getVersion());
  15847. $constraint->setPrettyString($package->getPrettyVersion());
  15848. $requires[$package->getName()] = $constraint;
  15849. }
  15850. }
  15851. $rootRequires = array();
  15852. foreach ($requires as $req => $constraint) {
  15853. if ((true === $this->ignorePlatformReqs || (is_array($this->ignorePlatformReqs) && in_array($req, $this->ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($req)) {
  15854. continue;
  15855. }
  15856. if ($constraint instanceof Link) {
  15857. $rootRequires[$req] = $constraint->getConstraint();
  15858. } else {
  15859. $rootRequires[$req] = $constraint;
  15860. }
  15861. }
  15862. $this->fixedRootPackage = clone $this->package;
  15863. $this->fixedRootPackage->setRequires(array());
  15864. $this->fixedRootPackage->setDevRequires(array());
  15865. $stabilityFlags[$this->package->getName()] = BasePackage::$stabilities[VersionParser::parseStability($this->package->getVersion())];
  15866. $repositorySet = new RepositorySet($minimumStability, $stabilityFlags, $rootAliases, $this->package->getReferences(), $rootRequires);
  15867. $repositorySet->addRepository(new RootPackageRepository($this->fixedRootPackage));
  15868. $repositorySet->addRepository($platformRepo);
  15869. if ($this->additionalFixedRepository) {
  15870. $repositorySet->addRepository($this->additionalFixedRepository);
  15871. }
  15872. return $repositorySet;
  15873. }
  15874. private function createPolicy($forUpdate)
  15875. {
  15876. $preferStable = null;
  15877. $preferLowest = null;
  15878. if (!$forUpdate) {
  15879. $preferStable = $this->locker->getPreferStable();
  15880. $preferLowest = $this->locker->getPreferLowest();
  15881. }
  15882. if (null === $preferStable) {
  15883. $preferStable = $this->preferStable || $this->package->getPreferStable();
  15884. }
  15885. if (null === $preferLowest) {
  15886. $preferLowest = $this->preferLowest;
  15887. }
  15888. return new DefaultPolicy($preferStable, $preferLowest);
  15889. }
  15890. private function createRequest(RootPackageInterface $rootPackage, PlatformRepository $platformRepo, $lockedRepository = null)
  15891. {
  15892. $request = new Request($lockedRepository);
  15893. $request->fixPackage($rootPackage);
  15894. if ($rootPackage instanceof RootAliasPackage) {
  15895. $request->fixPackage($rootPackage->getAliasOf());
  15896. }
  15897. $fixedPackages = $platformRepo->getPackages();
  15898. if ($this->additionalFixedRepository) {
  15899. $fixedPackages = array_merge($fixedPackages, $this->additionalFixedRepository->getPackages());
  15900. }
  15901. $provided = $rootPackage->getProvides();
  15902. foreach ($fixedPackages as $package) {
  15903. if ($package->getRepository() !== $platformRepo
  15904. || !isset($provided[$package->getName()])
  15905. || !$provided[$package->getName()]->getConstraint()->matches(new Constraint('=', $package->getVersion()))
  15906. ) {
  15907. $request->fixPackage($package);
  15908. }
  15909. }
  15910. return $request;
  15911. }
  15912. private function getRootAliases($forUpdate)
  15913. {
  15914. if ($forUpdate) {
  15915. $aliases = $this->package->getAliases();
  15916. } else {
  15917. $aliases = $this->locker->getAliases();
  15918. }
  15919. return $aliases;
  15920. }
  15921. private function extractPlatformRequirements($links)
  15922. {
  15923. $platformReqs = array();
  15924. foreach ($links as $link) {
  15925. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  15926. $platformReqs[$link->getTarget()] = $link->getPrettyConstraint();
  15927. }
  15928. }
  15929. return $platformReqs;
  15930. }
  15931. private function mockLocalRepositories(RepositoryManager $rm)
  15932. {
  15933. $packages = array();
  15934. foreach ($rm->getLocalRepository()->getPackages() as $package) {
  15935. $packages[(string) $package] = clone $package;
  15936. }
  15937. foreach ($packages as $key => $package) {
  15938. if ($package instanceof AliasPackage) {
  15939. $alias = (string) $package->getAliasOf();
  15940. $packages[$key] = new AliasPackage($packages[$alias], $package->getVersion(), $package->getPrettyVersion());
  15941. }
  15942. }
  15943. $rm->setLocalRepository(
  15944. new InstalledArrayRepository($packages)
  15945. );
  15946. }
  15947. public static function create(IOInterface $io, Composer $composer)
  15948. {
  15949. return new static(
  15950. $io,
  15951. $composer->getConfig(),
  15952. $composer->getPackage(),
  15953. $composer->getDownloadManager(),
  15954. $composer->getRepositoryManager(),
  15955. $composer->getLocker(),
  15956. $composer->getInstallationManager(),
  15957. $composer->getEventDispatcher(),
  15958. $composer->getAutoloadGenerator()
  15959. );
  15960. }
  15961. public function setAdditionalFixedRepository(RepositoryInterface $additionalFixedRepository)
  15962. {
  15963. $this->additionalFixedRepository = $additionalFixedRepository;
  15964. return $this;
  15965. }
  15966. public function setDryRun($dryRun = true)
  15967. {
  15968. $this->dryRun = (bool) $dryRun;
  15969. return $this;
  15970. }
  15971. public function isDryRun()
  15972. {
  15973. return $this->dryRun;
  15974. }
  15975. public function setPreferSource($preferSource = true)
  15976. {
  15977. $this->preferSource = (bool) $preferSource;
  15978. return $this;
  15979. }
  15980. public function setPreferDist($preferDist = true)
  15981. {
  15982. $this->preferDist = (bool) $preferDist;
  15983. return $this;
  15984. }
  15985. public function setOptimizeAutoloader($optimizeAutoloader)
  15986. {
  15987. $this->optimizeAutoloader = (bool) $optimizeAutoloader;
  15988. if (!$this->optimizeAutoloader) {
  15989. $this->setClassMapAuthoritative(false);
  15990. }
  15991. return $this;
  15992. }
  15993. public function setClassMapAuthoritative($classMapAuthoritative)
  15994. {
  15995. $this->classMapAuthoritative = (bool) $classMapAuthoritative;
  15996. if ($this->classMapAuthoritative) {
  15997. $this->setOptimizeAutoloader(true);
  15998. }
  15999. return $this;
  16000. }
  16001. public function setApcuAutoloader($apcuAutoloader, $apcuAutoloaderPrefix = null)
  16002. {
  16003. $this->apcuAutoloader = $apcuAutoloader;
  16004. $this->apcuAutoloaderPrefix = $apcuAutoloaderPrefix;
  16005. return $this;
  16006. }
  16007. public function setUpdate($update)
  16008. {
  16009. $this->update = (bool) $update;
  16010. return $this;
  16011. }
  16012. public function setInstall($install)
  16013. {
  16014. $this->install = (bool) $install;
  16015. return $this;
  16016. }
  16017. public function setDevMode($devMode = true)
  16018. {
  16019. $this->devMode = (bool) $devMode;
  16020. return $this;
  16021. }
  16022. public function setDumpAutoloader($dumpAutoloader = true)
  16023. {
  16024. $this->dumpAutoloader = (bool) $dumpAutoloader;
  16025. return $this;
  16026. }
  16027. public function setRunScripts($runScripts = true)
  16028. {
  16029. $this->runScripts = (bool) $runScripts;
  16030. return $this;
  16031. }
  16032. public function setConfig(Config $config)
  16033. {
  16034. $this->config = $config;
  16035. return $this;
  16036. }
  16037. public function setVerbose($verbose = true)
  16038. {
  16039. $this->verbose = (bool) $verbose;
  16040. return $this;
  16041. }
  16042. public function isVerbose()
  16043. {
  16044. return $this->verbose;
  16045. }
  16046. public function setIgnorePlatformRequirements($ignorePlatformReqs)
  16047. {
  16048. if (is_array($ignorePlatformReqs)) {
  16049. $this->ignorePlatformReqs = array_filter($ignorePlatformReqs, function ($req) {
  16050. return PlatformRepository::isPlatformPackage($req);
  16051. });
  16052. } else {
  16053. $this->ignorePlatformReqs = (bool) $ignorePlatformReqs;
  16054. }
  16055. return $this;
  16056. }
  16057. public function setUpdateMirrors($updateMirrors)
  16058. {
  16059. $this->updateMirrors = $updateMirrors;
  16060. return $this;
  16061. }
  16062. public function setUpdateAllowList(array $packages)
  16063. {
  16064. $this->updateAllowList = array_flip(array_map('strtolower', $packages));
  16065. return $this;
  16066. }
  16067. public function setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  16068. {
  16069. 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)) {
  16070. throw new \RuntimeException("Invalid value for updateAllowTransitiveDependencies supplied");
  16071. }
  16072. $this->updateAllowTransitiveDependencies = $updateAllowTransitiveDependencies;
  16073. return $this;
  16074. }
  16075. public function setPreferStable($preferStable = true)
  16076. {
  16077. $this->preferStable = (bool) $preferStable;
  16078. return $this;
  16079. }
  16080. public function setPreferLowest($preferLowest = true)
  16081. {
  16082. $this->preferLowest = (bool) $preferLowest;
  16083. return $this;
  16084. }
  16085. public function setWriteLock($writeLock = true)
  16086. {
  16087. $this->writeLock = (bool) $writeLock;
  16088. return $this;
  16089. }
  16090. public function setExecuteOperations($executeOperations = true)
  16091. {
  16092. $this->executeOperations = (bool) $executeOperations;
  16093. return $this;
  16094. }
  16095. public function disablePlugins()
  16096. {
  16097. $this->installationManager->disablePlugins();
  16098. return $this;
  16099. }
  16100. public function setSuggestedPackagesReporter(SuggestedPackagesReporter $suggestedPackagesReporter)
  16101. {
  16102. $this->suggestedPackagesReporter = $suggestedPackagesReporter;
  16103. return $this;
  16104. }
  16105. }
  16106. <?php
  16107. namespace Composer\Installer;
  16108. use Composer\IO\IOInterface;
  16109. use Composer\Package\PackageInterface;
  16110. use Composer\Util\Filesystem;
  16111. use Composer\Util\Platform;
  16112. use Composer\Util\ProcessExecutor;
  16113. use Composer\Util\Silencer;
  16114. class BinaryInstaller
  16115. {
  16116. protected $binDir;
  16117. protected $binCompat;
  16118. protected $io;
  16119. protected $filesystem;
  16120. public function __construct(IOInterface $io, $binDir, $binCompat, Filesystem $filesystem = null)
  16121. {
  16122. $this->binDir = $binDir;
  16123. $this->binCompat = $binCompat;
  16124. $this->io = $io;
  16125. $this->filesystem = $filesystem ?: new Filesystem();
  16126. }
  16127. public function installBinaries(PackageInterface $package, $installPath, $warnOnOverwrite = true)
  16128. {
  16129. $binaries = $this->getBinaries($package);
  16130. if (!$binaries) {
  16131. return;
  16132. }
  16133. foreach ($binaries as $bin) {
  16134. $binPath = $installPath.'/'.$bin;
  16135. if (!file_exists($binPath)) {
  16136. $this->io->writeError(' <warning>Skipped installation of bin '.$bin.' for package '.$package->getName().': file not found in package</warning>');
  16137. continue;
  16138. }
  16139. $binPath = realpath($binPath);
  16140. $this->initializeBinDir();
  16141. $link = $this->binDir.'/'.basename($bin);
  16142. if (file_exists($link)) {
  16143. if (is_link($link)) {
  16144. Silencer::call('chmod', $link, 0777 & ~umask());
  16145. }
  16146. if ($warnOnOverwrite) {
  16147. $this->io->writeError(' Skipped installation of bin '.$bin.' for package '.$package->getName().': name conflicts with an existing file');
  16148. }
  16149. continue;
  16150. }
  16151. if ($this->binCompat === "auto") {
  16152. if (Platform::isWindows()) {
  16153. $this->installFullBinaries($binPath, $link, $bin, $package);
  16154. } else {
  16155. $this->installSymlinkBinaries($binPath, $link);
  16156. }
  16157. } elseif ($this->binCompat === "full") {
  16158. $this->installFullBinaries($binPath, $link, $bin, $package);
  16159. }
  16160. Silencer::call('chmod', $link, 0777 & ~umask());
  16161. }
  16162. }
  16163. public function removeBinaries(PackageInterface $package)
  16164. {
  16165. $this->initializeBinDir();
  16166. $binaries = $this->getBinaries($package);
  16167. if (!$binaries) {
  16168. return;
  16169. }
  16170. foreach ($binaries as $bin) {
  16171. $link = $this->binDir.'/'.basename($bin);
  16172. if (is_link($link) || file_exists($link)) {
  16173. $this->filesystem->unlink($link);
  16174. }
  16175. if (file_exists($link.'.bat')) {
  16176. $this->filesystem->unlink($link.'.bat');
  16177. }
  16178. }
  16179. if (is_dir($this->binDir) && $this->filesystem->isDirEmpty($this->binDir)) {
  16180. Silencer::call('rmdir', $this->binDir);
  16181. }
  16182. }
  16183. public static function determineBinaryCaller($bin)
  16184. {
  16185. if ('.bat' === substr($bin, -4) || '.exe' === substr($bin, -4)) {
  16186. return 'call';
  16187. }
  16188. $handle = fopen($bin, 'r');
  16189. $line = fgets($handle);
  16190. fclose($handle);
  16191. if (preg_match('{^#!/(?:usr/bin/env )?(?:[^/]+/)*(.+)$}m', $line, $match)) {
  16192. return trim($match[1]);
  16193. }
  16194. return 'php';
  16195. }
  16196. protected function getBinaries(PackageInterface $package)
  16197. {
  16198. return $package->getBinaries();
  16199. }
  16200. protected function installFullBinaries($binPath, $link, $bin, PackageInterface $package)
  16201. {
  16202. if ('.bat' !== substr($binPath, -4)) {
  16203. $this->installUnixyProxyBinaries($binPath, $link);
  16204. @chmod($link, 0777 & ~umask());
  16205. $link .= '.bat';
  16206. if (file_exists($link)) {
  16207. $this->io->writeError(' Skipped installation of bin '.$bin.'.bat proxy for package '.$package->getName().': a .bat proxy was already installed');
  16208. }
  16209. }
  16210. if (!file_exists($link)) {
  16211. file_put_contents($link, $this->generateWindowsProxyCode($binPath, $link));
  16212. }
  16213. }
  16214. protected function installSymlinkBinaries($binPath, $link)
  16215. {
  16216. if (!$this->filesystem->relativeSymlink($binPath, $link)) {
  16217. $this->installUnixyProxyBinaries($binPath, $link);
  16218. }
  16219. }
  16220. protected function installUnixyProxyBinaries($binPath, $link)
  16221. {
  16222. file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
  16223. }
  16224. protected function initializeBinDir()
  16225. {
  16226. $this->filesystem->ensureDirectoryExists($this->binDir);
  16227. $this->binDir = realpath($this->binDir);
  16228. }
  16229. protected function generateWindowsProxyCode($bin, $link)
  16230. {
  16231. $binPath = $this->filesystem->findShortestPath($link, $bin);
  16232. $caller = self::determineBinaryCaller($bin);
  16233. return "@ECHO OFF\r\n".
  16234. "setlocal DISABLEDELAYEDEXPANSION\r\n".
  16235. "SET BIN_TARGET=%~dp0/".trim(ProcessExecutor::escape($binPath), '"\'')."\r\n".
  16236. "{$caller} \"%BIN_TARGET%\" %*\r\n";
  16237. }
  16238. protected function generateUnixyProxyCode($bin, $link)
  16239. {
  16240. $binPath = $this->filesystem->findShortestPath($link, $bin);
  16241. $binDir = ProcessExecutor::escape(dirname($binPath));
  16242. $binFile = basename($binPath);
  16243. $proxyCode = <<<PROXY
  16244. #!/usr/bin/env sh
  16245. dir=\$(cd "\${0%[/\\\\]*}" > /dev/null; cd $binDir && pwd)
  16246. if [ -d /proc/cygdrive ]; then
  16247. case \$(which php) in
  16248. \$(readlink -n /proc/cygdrive)/*)
  16249. # We are in Cygwin using Windows php, so the path must be translated
  16250. dir=\$(cygpath -m "\$dir");
  16251. ;;
  16252. esac
  16253. fi
  16254. "\${dir}/$binFile" "\$@"
  16255. PROXY;
  16256. return $proxyCode;
  16257. }
  16258. }
  16259. <?php
  16260. namespace Composer\Installer;
  16261. use Composer\Package\PackageInterface;
  16262. interface BinaryPresenceInterface
  16263. {
  16264. public function ensureBinariesPresence(PackageInterface $package);
  16265. }
  16266. <?php
  16267. namespace Composer\Installer;
  16268. use Composer\IO\IOInterface;
  16269. use Composer\IO\ConsoleIO;
  16270. use Composer\Package\PackageInterface;
  16271. use Composer\Package\AliasPackage;
  16272. use Composer\Repository\RepositoryInterface;
  16273. use Composer\Repository\InstalledRepositoryInterface;
  16274. use Composer\DependencyResolver\Operation\OperationInterface;
  16275. use Composer\DependencyResolver\Operation\InstallOperation;
  16276. use Composer\DependencyResolver\Operation\UpdateOperation;
  16277. use Composer\DependencyResolver\Operation\UninstallOperation;
  16278. use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation;
  16279. use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
  16280. use Composer\EventDispatcher\EventDispatcher;
  16281. use Composer\Util\StreamContextFactory;
  16282. use Composer\Util\Loop;
  16283. use React\Promise\PromiseInterface;
  16284. class InstallationManager
  16285. {
  16286. private $installers = array();
  16287. private $cache = array();
  16288. private $notifiablePackages = array();
  16289. private $loop;
  16290. private $io;
  16291. private $eventDispatcher;
  16292. private $outputProgress;
  16293. public function __construct(Loop $loop, IOInterface $io, EventDispatcher $eventDispatcher = null)
  16294. {
  16295. $this->loop = $loop;
  16296. $this->io = $io;
  16297. $this->eventDispatcher = $eventDispatcher;
  16298. }
  16299. public function reset()
  16300. {
  16301. $this->notifiablePackages = array();
  16302. }
  16303. public function addInstaller(InstallerInterface $installer)
  16304. {
  16305. array_unshift($this->installers, $installer);
  16306. $this->cache = array();
  16307. }
  16308. public function removeInstaller(InstallerInterface $installer)
  16309. {
  16310. if (false !== ($key = array_search($installer, $this->installers, true))) {
  16311. array_splice($this->installers, $key, 1);
  16312. $this->cache = array();
  16313. }
  16314. }
  16315. public function disablePlugins()
  16316. {
  16317. foreach ($this->installers as $i => $installer) {
  16318. if (!$installer instanceof PluginInstaller) {
  16319. continue;
  16320. }
  16321. unset($this->installers[$i]);
  16322. }
  16323. }
  16324. public function getInstaller($type)
  16325. {
  16326. $type = strtolower($type);
  16327. if (isset($this->cache[$type])) {
  16328. return $this->cache[$type];
  16329. }
  16330. foreach ($this->installers as $installer) {
  16331. if ($installer->supports($type)) {
  16332. return $this->cache[$type] = $installer;
  16333. }
  16334. }
  16335. throw new \InvalidArgumentException('Unknown installer type: '.$type);
  16336. }
  16337. public function isPackageInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  16338. {
  16339. if ($package instanceof AliasPackage) {
  16340. return $repo->hasPackage($package) && $this->isPackageInstalled($repo, $package->getAliasOf());
  16341. }
  16342. return $this->getInstaller($package->getType())->isInstalled($repo, $package);
  16343. }
  16344. public function ensureBinariesPresence(PackageInterface $package)
  16345. {
  16346. try {
  16347. $installer = $this->getInstaller($package->getType());
  16348. } catch (\InvalidArgumentException $e) {
  16349. return;
  16350. }
  16351. if ($installer instanceof BinaryPresenceInterface) {
  16352. $installer->ensureBinariesPresence($package);
  16353. }
  16354. }
  16355. public function execute(RepositoryInterface $repo, array $operations, $devMode = true, $runScripts = true)
  16356. {
  16357. $promises = array();
  16358. $cleanupPromises = array();
  16359. $loop = $this->loop;
  16360. $runCleanup = function () use (&$cleanupPromises, $loop) {
  16361. $promises = array();
  16362. $loop->abortJobs();
  16363. foreach ($cleanupPromises as $cleanup) {
  16364. $promises[] = new \React\Promise\Promise(function ($resolve, $reject) use ($cleanup) {
  16365. $promise = $cleanup();
  16366. if (!$promise instanceof PromiseInterface) {
  16367. $resolve();
  16368. } else {
  16369. $promise->then(function () use ($resolve) {
  16370. $resolve();
  16371. });
  16372. }
  16373. });
  16374. }
  16375. if (!empty($promises)) {
  16376. $loop->wait($promises);
  16377. }
  16378. };
  16379. $handleInterruptsUnix = function_exists('pcntl_async_signals') && function_exists('pcntl_signal');
  16380. $handleInterruptsWindows = function_exists('sapi_windows_set_ctrl_handler');
  16381. $prevHandler = null;
  16382. $windowsHandler = null;
  16383. if ($handleInterruptsUnix) {
  16384. pcntl_async_signals(true);
  16385. $prevHandler = pcntl_signal_get_handler(SIGINT);
  16386. pcntl_signal(SIGINT, function ($sig) use ($runCleanup, $prevHandler) {
  16387. $runCleanup();
  16388. if (!in_array($prevHandler, array(SIG_DFL, SIG_IGN), true)) {
  16389. call_user_func($prevHandler, $sig);
  16390. }
  16391. exit(130);
  16392. });
  16393. }
  16394. if ($handleInterruptsWindows) {
  16395. $windowsHandler = function () use ($runCleanup) {
  16396. $runCleanup();
  16397. exit(130);
  16398. };
  16399. sapi_windows_set_ctrl_handler($windowsHandler);
  16400. }
  16401. try {
  16402. foreach ($operations as $index => $operation) {
  16403. $opType = $operation->getOperationType();
  16404. if (!in_array($opType, array('update', 'install', 'uninstall'))) {
  16405. continue;
  16406. }
  16407. if ($opType === 'update') {
  16408. $package = $operation->getTargetPackage();
  16409. $initialPackage = $operation->getInitialPackage();
  16410. } else {
  16411. $package = $operation->getPackage();
  16412. $initialPackage = null;
  16413. }
  16414. $installer = $this->getInstaller($package->getType());
  16415. $cleanupPromises[$index] = function () use ($opType, $installer, $package, $initialPackage) {
  16416. if (!$package->getInstallationSource()) {
  16417. return;
  16418. }
  16419. return $installer->cleanup($opType, $package, $initialPackage);
  16420. };
  16421. if ($opType !== 'uninstall') {
  16422. $promise = $installer->download($package, $initialPackage);
  16423. if ($promise) {
  16424. $promises[] = $promise;
  16425. }
  16426. }
  16427. }
  16428. if (!empty($promises)) {
  16429. $progress = null;
  16430. if ($this->outputProgress && $this->io instanceof ConsoleIO && !$this->io->isDebug() && count($promises) > 1) {
  16431. $progress = $this->io->getProgressBar();
  16432. }
  16433. $this->loop->wait($promises, $progress);
  16434. if ($progress) {
  16435. $progress->clear();
  16436. }
  16437. }
  16438. $batches = array();
  16439. $batch = array();
  16440. foreach ($operations as $index => $operation) {
  16441. if (in_array($operation->getOperationType(), array('update', 'install'), true)) {
  16442. $package = $operation->getOperationType() === 'update' ? $operation->getTargetPackage() : $operation->getPackage();
  16443. if ($package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer') {
  16444. if ($batch) {
  16445. $batches[] = $batch;
  16446. }
  16447. $batches[] = array($index => $operation);
  16448. $batch = array();
  16449. continue;
  16450. }
  16451. }
  16452. $batch[$index] = $operation;
  16453. }
  16454. if ($batch) {
  16455. $batches[] = $batch;
  16456. }
  16457. foreach ($batches as $batch) {
  16458. $this->executeBatch($repo, $batch, $cleanupPromises, $devMode, $runScripts, $operations);
  16459. }
  16460. } catch (\Exception $e) {
  16461. $runCleanup();
  16462. if ($handleInterruptsUnix) {
  16463. pcntl_signal(SIGINT, $prevHandler);
  16464. }
  16465. if ($handleInterruptsWindows) {
  16466. sapi_windows_set_ctrl_handler($prevHandler, false);
  16467. }
  16468. throw $e;
  16469. }
  16470. if ($handleInterruptsUnix) {
  16471. pcntl_signal(SIGINT, $prevHandler);
  16472. }
  16473. if ($handleInterruptsWindows) {
  16474. sapi_windows_set_ctrl_handler($prevHandler, false);
  16475. }
  16476. $repo->write($devMode, $this);
  16477. }
  16478. private function executeBatch(RepositoryInterface $repo, array $operations, array $cleanupPromises, $devMode, $runScripts, array $allOperations)
  16479. {
  16480. foreach ($operations as $index => $operation) {
  16481. $opType = $operation->getOperationType();
  16482. if (!in_array($opType, array('update', 'install', 'uninstall'))) {
  16483. if ($this->io->isDebug()) {
  16484. $this->io->writeError(' - ' . $operation->show(false));
  16485. }
  16486. $this->$opType($repo, $operation);
  16487. continue;
  16488. }
  16489. if ($opType === 'update') {
  16490. $package = $operation->getTargetPackage();
  16491. $initialPackage = $operation->getInitialPackage();
  16492. } else {
  16493. $package = $operation->getPackage();
  16494. $initialPackage = null;
  16495. }
  16496. $installer = $this->getInstaller($package->getType());
  16497. $event = 'Composer\Installer\PackageEvents::PRE_PACKAGE_'.strtoupper($opType);
  16498. if (defined($event) && $runScripts && $this->eventDispatcher) {
  16499. $this->eventDispatcher->dispatchPackageEvent(constant($event), $devMode, $repo, $allOperations, $operation);
  16500. }
  16501. $dispatcher = $this->eventDispatcher;
  16502. $installManager = $this;
  16503. $io = $this->io;
  16504. $promise = $installer->prepare($opType, $package, $initialPackage);
  16505. if (!$promise instanceof PromiseInterface) {
  16506. $promise = \React\Promise\resolve();
  16507. }
  16508. $promise = $promise->then(function () use ($opType, $installManager, $repo, $operation) {
  16509. return $installManager->$opType($repo, $operation);
  16510. })->then($cleanupPromises[$index])
  16511. ->then(function () use ($opType, $runScripts, $dispatcher, $installManager, $devMode, $repo, $allOperations, $operation) {
  16512. $repo->write($devMode, $installManager);
  16513. $event = 'Composer\Installer\PackageEvents::POST_PACKAGE_'.strtoupper($opType);
  16514. if (defined($event) && $runScripts && $dispatcher) {
  16515. $dispatcher->dispatchPackageEvent(constant($event), $devMode, $repo, $allOperations, $operation);
  16516. }
  16517. }, function ($e) use ($opType, $package, $io) {
  16518. $io->writeError(' <error>' . ucfirst($opType) .' of '.$package->getPrettyName().' failed</error>');
  16519. throw $e;
  16520. });
  16521. $promises[] = $promise;
  16522. }
  16523. if (!empty($promises)) {
  16524. $progress = null;
  16525. if ($this->outputProgress && $this->io instanceof ConsoleIO && !$this->io->isDebug() && count($promises) > 1) {
  16526. $progress = $this->io->getProgressBar();
  16527. }
  16528. $this->loop->wait($promises, $progress);
  16529. if ($progress) {
  16530. $progress->clear();
  16531. }
  16532. }
  16533. }
  16534. public function install(RepositoryInterface $repo, InstallOperation $operation)
  16535. {
  16536. $package = $operation->getPackage();
  16537. $installer = $this->getInstaller($package->getType());
  16538. $promise = $installer->install($repo, $package);
  16539. $this->markForNotification($package);
  16540. return $promise;
  16541. }
  16542. public function update(RepositoryInterface $repo, UpdateOperation $operation)
  16543. {
  16544. $initial = $operation->getInitialPackage();
  16545. $target = $operation->getTargetPackage();
  16546. $initialType = $initial->getType();
  16547. $targetType = $target->getType();
  16548. if ($initialType === $targetType) {
  16549. $installer = $this->getInstaller($initialType);
  16550. $promise = $installer->update($repo, $initial, $target);
  16551. $this->markForNotification($target);
  16552. } else {
  16553. $this->getInstaller($initialType)->uninstall($repo, $initial);
  16554. $installer = $this->getInstaller($targetType);
  16555. $promise = $installer->install($repo, $target);
  16556. }
  16557. return $promise;
  16558. }
  16559. public function uninstall(RepositoryInterface $repo, UninstallOperation $operation)
  16560. {
  16561. $package = $operation->getPackage();
  16562. $installer = $this->getInstaller($package->getType());
  16563. return $installer->uninstall($repo, $package);
  16564. }
  16565. public function markAliasInstalled(RepositoryInterface $repo, MarkAliasInstalledOperation $operation)
  16566. {
  16567. $package = $operation->getPackage();
  16568. if (!$repo->hasPackage($package)) {
  16569. $repo->addPackage(clone $package);
  16570. }
  16571. }
  16572. public function markAliasUninstalled(RepositoryInterface $repo, MarkAliasUninstalledOperation $operation)
  16573. {
  16574. $package = $operation->getPackage();
  16575. $repo->removePackage($package);
  16576. }
  16577. public function getInstallPath(PackageInterface $package)
  16578. {
  16579. $installer = $this->getInstaller($package->getType());
  16580. return $installer->getInstallPath($package);
  16581. }
  16582. public function setOutputProgress($outputProgress)
  16583. {
  16584. $this->outputProgress = $outputProgress;
  16585. }
  16586. public function notifyInstalls(IOInterface $io)
  16587. {
  16588. foreach ($this->notifiablePackages as $repoUrl => $packages) {
  16589. $repositoryName = parse_url($repoUrl, PHP_URL_HOST);
  16590. if ($io->hasAuthentication($repositoryName)) {
  16591. $auth = $io->getAuthentication($repositoryName);
  16592. $authStr = base64_encode($auth['username'] . ':' . $auth['password']);
  16593. $authHeader = 'Authorization: Basic '.$authStr;
  16594. }
  16595. if (strpos($repoUrl, '%package%')) {
  16596. foreach ($packages as $package) {
  16597. $url = str_replace('%package%', $package->getPrettyName(), $repoUrl);
  16598. $params = array(
  16599. 'version' => $package->getPrettyVersion(),
  16600. 'version_normalized' => $package->getVersion(),
  16601. );
  16602. $opts = array('http' =>
  16603. array(
  16604. 'method' => 'POST',
  16605. 'header' => array('Content-type: application/x-www-form-urlencoded'),
  16606. 'content' => http_build_query($params, '', '&'),
  16607. 'timeout' => 3,
  16608. ),
  16609. );
  16610. if (isset($authHeader)) {
  16611. $opts['http']['header'][] = $authHeader;
  16612. }
  16613. $context = StreamContextFactory::getContext($url, $opts);
  16614. @file_get_contents($url, false, $context);
  16615. }
  16616. continue;
  16617. }
  16618. $postData = array('downloads' => array());
  16619. foreach ($packages as $package) {
  16620. $postData['downloads'][] = array(
  16621. 'name' => $package->getPrettyName(),
  16622. 'version' => $package->getVersion(),
  16623. );
  16624. }
  16625. $opts = array('http' =>
  16626. array(
  16627. 'method' => 'POST',
  16628. 'header' => array('Content-Type: application/json'),
  16629. 'content' => json_encode($postData),
  16630. 'timeout' => 6,
  16631. ),
  16632. );
  16633. if (isset($authHeader)) {
  16634. $opts['http']['header'][] = $authHeader;
  16635. }
  16636. $context = StreamContextFactory::getContext($repoUrl, $opts);
  16637. @file_get_contents($repoUrl, false, $context);
  16638. }
  16639. $this->reset();
  16640. }
  16641. private function markForNotification(PackageInterface $package)
  16642. {
  16643. if ($package->getNotificationUrl()) {
  16644. $this->notifiablePackages[$package->getNotificationUrl()][$package->getName()] = $package;
  16645. }
  16646. }
  16647. }
  16648. <?php
  16649. namespace Composer\Installer;
  16650. use Composer\Composer;
  16651. use Composer\DependencyResolver\PolicyInterface;
  16652. use Composer\DependencyResolver\Request;
  16653. use Composer\DependencyResolver\Pool;
  16654. use Composer\DependencyResolver\Transaction;
  16655. use Composer\EventDispatcher\Event;
  16656. use Composer\IO\IOInterface;
  16657. use Composer\Repository\RepositorySet;
  16658. class InstallerEvent extends Event
  16659. {
  16660. private $composer;
  16661. private $io;
  16662. private $devMode;
  16663. private $executeOperations;
  16664. private $transaction;
  16665. public function __construct($eventName, Composer $composer, IOInterface $io, $devMode, $executeOperations, Transaction $transaction)
  16666. {
  16667. parent::__construct($eventName);
  16668. $this->composer = $composer;
  16669. $this->io = $io;
  16670. $this->devMode = $devMode;
  16671. $this->executeOperations = $executeOperations;
  16672. $this->transaction = $transaction;
  16673. }
  16674. public function getComposer()
  16675. {
  16676. return $this->composer;
  16677. }
  16678. public function getIO()
  16679. {
  16680. return $this->io;
  16681. }
  16682. public function isDevMode()
  16683. {
  16684. return $this->devMode;
  16685. }
  16686. public function isExecutingOperations()
  16687. {
  16688. return $this->executeOperations;
  16689. }
  16690. public function getTransaction()
  16691. {
  16692. return $this->transaction;
  16693. }
  16694. }
  16695. <?php
  16696. namespace Composer\Installer;
  16697. class InstallerEvents
  16698. {
  16699. const PRE_OPERATIONS_EXEC = 'pre-operations-exec';
  16700. }
  16701. <?php
  16702. namespace Composer\Installer;
  16703. use Composer\Package\PackageInterface;
  16704. use Composer\Repository\InstalledRepositoryInterface;
  16705. use InvalidArgumentException;
  16706. use React\Promise\PromiseInterface;
  16707. interface InstallerInterface
  16708. {
  16709. public function supports($packageType);
  16710. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package);
  16711. public function download(PackageInterface $package, PackageInterface $prevPackage = null);
  16712. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null);
  16713. public function install(InstalledRepositoryInterface $repo, PackageInterface $package);
  16714. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target);
  16715. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package);
  16716. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null);
  16717. public function getInstallPath(PackageInterface $package);
  16718. }
  16719. <?php
  16720. namespace Composer\Installer;
  16721. use Composer\Composer;
  16722. use Composer\IO\IOInterface;
  16723. use Composer\Repository\InstalledRepositoryInterface;
  16724. use Composer\Package\PackageInterface;
  16725. use Composer\Util\Filesystem;
  16726. use Composer\Util\Silencer;
  16727. use Composer\Util\Platform;
  16728. use React\Promise\PromiseInterface;
  16729. class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
  16730. {
  16731. protected $composer;
  16732. protected $vendorDir;
  16733. protected $binDir;
  16734. protected $downloadManager;
  16735. protected $io;
  16736. protected $type;
  16737. protected $filesystem;
  16738. protected $binCompat;
  16739. protected $binaryInstaller;
  16740. public function __construct(IOInterface $io, Composer $composer, $type = 'library', Filesystem $filesystem = null, BinaryInstaller $binaryInstaller = null)
  16741. {
  16742. $this->composer = $composer;
  16743. $this->downloadManager = $composer->getDownloadManager();
  16744. $this->io = $io;
  16745. $this->type = $type;
  16746. $this->filesystem = $filesystem ?: new Filesystem();
  16747. $this->vendorDir = rtrim($composer->getConfig()->get('vendor-dir'), '/');
  16748. $this->binaryInstaller = $binaryInstaller ?: new BinaryInstaller($this->io, rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $this->filesystem);
  16749. }
  16750. public function supports($packageType)
  16751. {
  16752. return $packageType === $this->type || null === $this->type;
  16753. }
  16754. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  16755. {
  16756. if (!$repo->hasPackage($package)) {
  16757. return false;
  16758. }
  16759. $installPath = $this->getInstallPath($package);
  16760. if (is_readable($installPath)) {
  16761. return true;
  16762. }
  16763. return (Platform::isWindows() && $this->filesystem->isJunction($installPath)) || is_link($installPath);
  16764. }
  16765. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  16766. {
  16767. $this->initializeVendorDir();
  16768. $downloadPath = $this->getInstallPath($package);
  16769. return $this->downloadManager->download($package, $downloadPath, $prevPackage);
  16770. }
  16771. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  16772. {
  16773. $this->initializeVendorDir();
  16774. $downloadPath = $this->getInstallPath($package);
  16775. return $this->downloadManager->prepare($type, $package, $downloadPath, $prevPackage);
  16776. }
  16777. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  16778. {
  16779. $this->initializeVendorDir();
  16780. $downloadPath = $this->getInstallPath($package);
  16781. return $this->downloadManager->cleanup($type, $package, $downloadPath, $prevPackage);
  16782. }
  16783. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  16784. {
  16785. $this->initializeVendorDir();
  16786. $downloadPath = $this->getInstallPath($package);
  16787. if (!is_readable($downloadPath) && $repo->hasPackage($package)) {
  16788. $this->binaryInstaller->removeBinaries($package);
  16789. }
  16790. $promise = $this->installCode($package);
  16791. if (!$promise instanceof PromiseInterface) {
  16792. $promise = \React\Promise\resolve();
  16793. }
  16794. $binaryInstaller = $this->binaryInstaller;
  16795. $installPath = $this->getInstallPath($package);
  16796. return $promise->then(function () use ($binaryInstaller, $installPath, $package, $repo) {
  16797. $binaryInstaller->installBinaries($package, $installPath);
  16798. if (!$repo->hasPackage($package)) {
  16799. $repo->addPackage(clone $package);
  16800. }
  16801. });
  16802. }
  16803. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  16804. {
  16805. if (!$repo->hasPackage($initial)) {
  16806. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  16807. }
  16808. $this->initializeVendorDir();
  16809. $this->binaryInstaller->removeBinaries($initial);
  16810. $promise = $this->updateCode($initial, $target);
  16811. if (!$promise instanceof PromiseInterface) {
  16812. $promise = \React\Promise\resolve();
  16813. }
  16814. $binaryInstaller = $this->binaryInstaller;
  16815. $installPath = $this->getInstallPath($target);
  16816. return $promise->then(function () use ($binaryInstaller, $installPath, $target, $initial, $repo) {
  16817. $binaryInstaller->installBinaries($target, $installPath);
  16818. $repo->removePackage($initial);
  16819. if (!$repo->hasPackage($target)) {
  16820. $repo->addPackage(clone $target);
  16821. }
  16822. });
  16823. }
  16824. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  16825. {
  16826. if (!$repo->hasPackage($package)) {
  16827. throw new \InvalidArgumentException('Package is not installed: '.$package);
  16828. }
  16829. $promise = $this->removeCode($package);
  16830. if (!$promise instanceof PromiseInterface) {
  16831. $promise = \React\Promise\resolve();
  16832. }
  16833. $binaryInstaller = $this->binaryInstaller;
  16834. $downloadPath = $this->getPackageBasePath($package);
  16835. $filesystem = $this->filesystem;
  16836. return $promise->then(function () use ($binaryInstaller, $filesystem, $downloadPath, $package, $repo) {
  16837. $binaryInstaller->removeBinaries($package);
  16838. $repo->removePackage($package);
  16839. if (strpos($package->getName(), '/')) {
  16840. $packageVendorDir = dirname($downloadPath);
  16841. if (is_dir($packageVendorDir) && $filesystem->isDirEmpty($packageVendorDir)) {
  16842. Silencer::call('rmdir', $packageVendorDir);
  16843. }
  16844. }
  16845. });
  16846. }
  16847. public function getInstallPath(PackageInterface $package)
  16848. {
  16849. $this->initializeVendorDir();
  16850. $basePath = ($this->vendorDir ? $this->vendorDir.'/' : '') . $package->getPrettyName();
  16851. $targetDir = $package->getTargetDir();
  16852. return $basePath . ($targetDir ? '/'.$targetDir : '');
  16853. }
  16854. public function ensureBinariesPresence(PackageInterface $package)
  16855. {
  16856. $this->binaryInstaller->installBinaries($package, $this->getInstallPath($package), false);
  16857. }
  16858. protected function getPackageBasePath(PackageInterface $package)
  16859. {
  16860. $installPath = $this->getInstallPath($package);
  16861. $targetDir = $package->getTargetDir();
  16862. if ($targetDir) {
  16863. return preg_replace('{/*'.str_replace('/', '/+', preg_quote($targetDir)).'/?$}', '', $installPath);
  16864. }
  16865. return $installPath;
  16866. }
  16867. protected function installCode(PackageInterface $package)
  16868. {
  16869. $downloadPath = $this->getInstallPath($package);
  16870. return $this->downloadManager->install($package, $downloadPath);
  16871. }
  16872. protected function updateCode(PackageInterface $initial, PackageInterface $target)
  16873. {
  16874. $initialDownloadPath = $this->getInstallPath($initial);
  16875. $targetDownloadPath = $this->getInstallPath($target);
  16876. if ($targetDownloadPath !== $initialDownloadPath) {
  16877. if (strpos($initialDownloadPath, $targetDownloadPath) === 0
  16878. || strpos($targetDownloadPath, $initialDownloadPath) === 0
  16879. ) {
  16880. $promise = $this->removeCode($initial);
  16881. if (!$promise instanceof PromiseInterface) {
  16882. $promise = \React\Promise\resolve();
  16883. }
  16884. $self = $this;
  16885. return $promise->then(function () use ($self, $target) {
  16886. $reflMethod = new \ReflectionMethod($self, 'installCode');
  16887. $reflMethod->setAccessible(true);
  16888. return $reflMethod->invoke($self, $target);
  16889. });
  16890. }
  16891. $this->filesystem->rename($initialDownloadPath, $targetDownloadPath);
  16892. }
  16893. return $this->downloadManager->update($initial, $target, $targetDownloadPath);
  16894. }
  16895. protected function removeCode(PackageInterface $package)
  16896. {
  16897. $downloadPath = $this->getPackageBasePath($package);
  16898. return $this->downloadManager->remove($package, $downloadPath);
  16899. }
  16900. protected function initializeVendorDir()
  16901. {
  16902. $this->filesystem->ensureDirectoryExists($this->vendorDir);
  16903. $this->vendorDir = realpath($this->vendorDir);
  16904. }
  16905. }
  16906. <?php
  16907. namespace Composer\Installer;
  16908. use Composer\Repository\InstalledRepositoryInterface;
  16909. use Composer\Package\PackageInterface;
  16910. use Composer\Package\Version\VersionParser;
  16911. use Composer\IO\IOInterface;
  16912. use Composer\DependencyResolver\Operation\UpdateOperation;
  16913. use Composer\DependencyResolver\Operation\InstallOperation;
  16914. use Composer\DependencyResolver\Operation\UninstallOperation;
  16915. class MetapackageInstaller implements InstallerInterface
  16916. {
  16917. private $io;
  16918. public function __construct(IOInterface $io)
  16919. {
  16920. $this->io = $io;
  16921. }
  16922. public function supports($packageType)
  16923. {
  16924. return $packageType === 'metapackage';
  16925. }
  16926. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  16927. {
  16928. return $repo->hasPackage($package);
  16929. }
  16930. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  16931. {
  16932. }
  16933. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  16934. {
  16935. }
  16936. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  16937. {
  16938. }
  16939. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  16940. {
  16941. $this->io->writeError(" - " . InstallOperation::format($package));
  16942. $repo->addPackage(clone $package);
  16943. }
  16944. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  16945. {
  16946. if (!$repo->hasPackage($initial)) {
  16947. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  16948. }
  16949. $this->io->writeError(" - " . UpdateOperation::format($initial, $target));
  16950. $repo->removePackage($initial);
  16951. $repo->addPackage(clone $target);
  16952. }
  16953. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  16954. {
  16955. if (!$repo->hasPackage($package)) {
  16956. throw new \InvalidArgumentException('Package is not installed: '.$package);
  16957. }
  16958. $this->io->writeError(" - " . UninstallOperation::format($package));
  16959. $repo->removePackage($package);
  16960. }
  16961. public function getInstallPath(PackageInterface $package)
  16962. {
  16963. return '';
  16964. }
  16965. }
  16966. <?php
  16967. namespace Composer\Installer;
  16968. use Composer\Repository\InstalledRepositoryInterface;
  16969. use Composer\Package\PackageInterface;
  16970. class NoopInstaller implements InstallerInterface
  16971. {
  16972. public function supports($packageType)
  16973. {
  16974. return true;
  16975. }
  16976. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  16977. {
  16978. return $repo->hasPackage($package);
  16979. }
  16980. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  16981. {
  16982. }
  16983. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  16984. {
  16985. }
  16986. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  16987. {
  16988. }
  16989. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  16990. {
  16991. if (!$repo->hasPackage($package)) {
  16992. $repo->addPackage(clone $package);
  16993. }
  16994. }
  16995. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  16996. {
  16997. if (!$repo->hasPackage($initial)) {
  16998. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  16999. }
  17000. $repo->removePackage($initial);
  17001. if (!$repo->hasPackage($target)) {
  17002. $repo->addPackage(clone $target);
  17003. }
  17004. }
  17005. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  17006. {
  17007. if (!$repo->hasPackage($package)) {
  17008. throw new \InvalidArgumentException('Package is not installed: '.$package);
  17009. }
  17010. $repo->removePackage($package);
  17011. }
  17012. public function getInstallPath(PackageInterface $package)
  17013. {
  17014. $targetDir = $package->getTargetDir();
  17015. return $package->getPrettyName() . ($targetDir ? '/'.$targetDir : '');
  17016. }
  17017. }
  17018. <?php
  17019. namespace Composer\Installer;
  17020. use Composer\Composer;
  17021. use Composer\IO\IOInterface;
  17022. use Composer\DependencyResolver\Operation\OperationInterface;
  17023. use Composer\DependencyResolver\PolicyInterface;
  17024. use Composer\DependencyResolver\Request;
  17025. use Composer\Repository\RepositoryInterface;
  17026. use Composer\Repository\RepositorySet;
  17027. use Composer\EventDispatcher\Event;
  17028. class PackageEvent extends Event
  17029. {
  17030. private $composer;
  17031. private $io;
  17032. private $devMode;
  17033. private $localRepo;
  17034. private $operations;
  17035. private $operation;
  17036. public function __construct($eventName, Composer $composer, IOInterface $io, $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation)
  17037. {
  17038. parent::__construct($eventName);
  17039. $this->composer = $composer;
  17040. $this->io = $io;
  17041. $this->devMode = $devMode;
  17042. $this->localRepo = $localRepo;
  17043. $this->operations = $operations;
  17044. $this->operation = $operation;
  17045. }
  17046. public function getComposer()
  17047. {
  17048. return $this->composer;
  17049. }
  17050. public function getIO()
  17051. {
  17052. return $this->io;
  17053. }
  17054. public function isDevMode()
  17055. {
  17056. return $this->devMode;
  17057. }
  17058. public function getLocalRepo()
  17059. {
  17060. return $this->localRepo;
  17061. }
  17062. public function getOperations()
  17063. {
  17064. return $this->operations;
  17065. }
  17066. public function getOperation()
  17067. {
  17068. return $this->operation;
  17069. }
  17070. }
  17071. <?php
  17072. namespace Composer\Installer;
  17073. class PackageEvents
  17074. {
  17075. const PRE_PACKAGE_INSTALL = 'pre-package-install';
  17076. const POST_PACKAGE_INSTALL = 'post-package-install';
  17077. const PRE_PACKAGE_UPDATE = 'pre-package-update';
  17078. const POST_PACKAGE_UPDATE = 'post-package-update';
  17079. const PRE_PACKAGE_UNINSTALL = 'pre-package-uninstall';
  17080. const POST_PACKAGE_UNINSTALL = 'post-package-uninstall';
  17081. }
  17082. <?php
  17083. namespace Composer\Installer;
  17084. use Composer\Composer;
  17085. use Composer\IO\IOInterface;
  17086. use Composer\Repository\InstalledRepositoryInterface;
  17087. use Composer\Package\PackageInterface;
  17088. use Composer\Util\Filesystem;
  17089. use React\Promise\PromiseInterface;
  17090. class PluginInstaller extends LibraryInstaller
  17091. {
  17092. public function __construct(IOInterface $io, Composer $composer, Filesystem $fs = null, BinaryInstaller $binaryInstaller = null)
  17093. {
  17094. parent::__construct($io, $composer, 'composer-plugin', $fs, $binaryInstaller);
  17095. }
  17096. public function supports($packageType)
  17097. {
  17098. return $packageType === 'composer-plugin' || $packageType === 'composer-installer';
  17099. }
  17100. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  17101. {
  17102. $extra = $package->getExtra();
  17103. if (empty($extra['class'])) {
  17104. throw new \UnexpectedValueException('Error while installing '.$package->getPrettyName().', composer-plugin packages should have a class defined in their extra key to be usable.');
  17105. }
  17106. return parent::download($package, $prevPackage);
  17107. }
  17108. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  17109. {
  17110. $promise = parent::install($repo, $package);
  17111. if (!$promise instanceof PromiseInterface) {
  17112. $promise = \React\Promise\resolve();
  17113. }
  17114. $pluginManager = $this->composer->getPluginManager();
  17115. $self = $this;
  17116. return $promise->then(function () use ($self, $pluginManager, $package, $repo) {
  17117. try {
  17118. $pluginManager->registerPackage($package, true);
  17119. } catch (\Exception $e) {
  17120. $self->rollbackInstall($e, $repo, $package);
  17121. }
  17122. });
  17123. }
  17124. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  17125. {
  17126. $promise = parent::update($repo, $initial, $target);
  17127. if (!$promise instanceof PromiseInterface) {
  17128. $promise = \React\Promise\resolve();
  17129. }
  17130. $pluginManager = $this->composer->getPluginManager();
  17131. $self = $this;
  17132. return $promise->then(function () use ($self, $pluginManager, $initial, $target, $repo) {
  17133. try {
  17134. $pluginManager->deactivatePackage($initial, true);
  17135. $pluginManager->registerPackage($target, true);
  17136. } catch (\Exception $e) {
  17137. $self->rollbackInstall($e, $repo, $target);
  17138. }
  17139. });
  17140. }
  17141. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  17142. {
  17143. $this->composer->getPluginManager()->uninstallPackage($package, true);
  17144. return parent::uninstall($repo, $package);
  17145. }
  17146. public function rollbackInstall(\Exception $e, InstalledRepositoryInterface $repo, PackageInterface $package)
  17147. {
  17148. $this->io->writeError('Plugin initialization failed ('.$e->getMessage().'), uninstalling plugin');
  17149. parent::uninstall($repo, $package);
  17150. throw $e;
  17151. }
  17152. }
  17153. <?php
  17154. namespace Composer\Installer;
  17155. use Composer\Package\PackageInterface;
  17156. use Composer\Downloader\DownloadManager;
  17157. use Composer\Repository\InstalledRepositoryInterface;
  17158. use Composer\Util\Filesystem;
  17159. class ProjectInstaller implements InstallerInterface
  17160. {
  17161. private $installPath;
  17162. private $downloadManager;
  17163. private $filesystem;
  17164. public function __construct($installPath, DownloadManager $dm, Filesystem $fs)
  17165. {
  17166. $this->installPath = rtrim(strtr($installPath, '\\', '/'), '/').'/';
  17167. $this->downloadManager = $dm;
  17168. $this->filesystem = $fs;
  17169. }
  17170. public function supports($packageType)
  17171. {
  17172. return true;
  17173. }
  17174. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  17175. {
  17176. return false;
  17177. }
  17178. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  17179. {
  17180. $installPath = $this->installPath;
  17181. if (file_exists($installPath) && !$this->filesystem->isDirEmpty($installPath)) {
  17182. throw new \InvalidArgumentException("Project directory $installPath is not empty.");
  17183. }
  17184. if (!is_dir($installPath)) {
  17185. mkdir($installPath, 0777, true);
  17186. }
  17187. return $this->downloadManager->download($package, $installPath, $prevPackage);
  17188. }
  17189. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17190. {
  17191. return $this->downloadManager->prepare($type, $package, $this->installPath, $prevPackage);
  17192. }
  17193. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17194. {
  17195. return $this->downloadManager->cleanup($type, $package, $this->installPath, $prevPackage);
  17196. }
  17197. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  17198. {
  17199. return $this->downloadManager->install($package, $this->installPath);
  17200. }
  17201. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  17202. {
  17203. throw new \InvalidArgumentException("not supported");
  17204. }
  17205. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  17206. {
  17207. throw new \InvalidArgumentException("not supported");
  17208. }
  17209. public function getInstallPath(PackageInterface $package)
  17210. {
  17211. return $this->installPath;
  17212. }
  17213. }
  17214. <?php
  17215. namespace Composer\Installer;
  17216. use Composer\IO\IOInterface;
  17217. use Composer\Package\PackageInterface;
  17218. use Composer\Repository\InstalledRepository;
  17219. use Symfony\Component\Console\Formatter\OutputFormatter;
  17220. class SuggestedPackagesReporter
  17221. {
  17222. const MODE_LIST = 1;
  17223. const MODE_BY_PACKAGE = 2;
  17224. const MODE_BY_SUGGESTION = 4;
  17225. protected $suggestedPackages = array();
  17226. private $io;
  17227. public function __construct(IOInterface $io)
  17228. {
  17229. $this->io = $io;
  17230. }
  17231. public function getPackages()
  17232. {
  17233. return $this->suggestedPackages;
  17234. }
  17235. public function addPackage($source, $target, $reason)
  17236. {
  17237. $this->suggestedPackages[] = array(
  17238. 'source' => $source,
  17239. 'target' => $target,
  17240. 'reason' => $reason,
  17241. );
  17242. return $this;
  17243. }
  17244. public function addSuggestionsFromPackage(PackageInterface $package)
  17245. {
  17246. $source = $package->getPrettyName();
  17247. foreach ($package->getSuggests() as $target => $reason) {
  17248. $this->addPackage(
  17249. $source,
  17250. $target,
  17251. $reason
  17252. );
  17253. }
  17254. return $this;
  17255. }
  17256. public function output($mode, InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
  17257. {
  17258. $suggestedPackages = $this->getFilteredSuggestions($installedRepo, $onlyDependentsOf);
  17259. $suggesters = array();
  17260. $suggested = array();
  17261. foreach ($suggestedPackages as $suggestion) {
  17262. $suggesters[$suggestion['source']][$suggestion['target']] = $suggestion['reason'];
  17263. $suggested[$suggestion['target']][$suggestion['source']] = $suggestion['reason'];
  17264. }
  17265. ksort($suggesters);
  17266. ksort($suggested);
  17267. if ($mode & self::MODE_LIST) {
  17268. foreach (array_keys($suggested) as $name) {
  17269. $this->io->write(sprintf('<info>%s</info>', $name));
  17270. }
  17271. return 0;
  17272. }
  17273. if ($mode & self::MODE_BY_PACKAGE) {
  17274. foreach ($suggesters as $suggester => $suggestions) {
  17275. $this->io->write(sprintf('<comment>%s</comment> suggests:', $suggester));
  17276. foreach ($suggestions as $suggestion => $reason) {
  17277. $this->io->write(sprintf(' - <info>%s</info>' . ($reason ? ': %s' : ''), $suggestion, $this->escapeOutput($reason)));
  17278. }
  17279. $this->io->write('');
  17280. }
  17281. }
  17282. if ($mode & self::MODE_BY_SUGGESTION) {
  17283. if ($mode & self::MODE_BY_PACKAGE) {
  17284. $this->io->write(str_repeat('-', 78));
  17285. }
  17286. foreach ($suggested as $suggestion => $suggesters) {
  17287. $this->io->write(sprintf('<comment>%s</comment> is suggested by:', $suggestion));
  17288. foreach ($suggesters as $suggester => $reason) {
  17289. $this->io->write(sprintf(' - <info>%s</info>' . ($reason ? ': %s' : ''), $suggester, $this->escapeOutput($reason)));
  17290. }
  17291. $this->io->write('');
  17292. }
  17293. }
  17294. if ($onlyDependentsOf) {
  17295. $allSuggestedPackages = $this->getFilteredSuggestions($installedRepo);
  17296. $diff = count($allSuggestedPackages) - count($suggestedPackages);
  17297. if ($diff) {
  17298. $this->io->write('<info>'.$diff.' additional suggestions</info> by transitive dependencies can be shown with <info>--all</info>');
  17299. }
  17300. }
  17301. return $this;
  17302. }
  17303. public function outputMinimalistic(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
  17304. {
  17305. $suggestedPackages = $this->getFilteredSuggestions($installedRepo, $onlyDependentsOf);
  17306. if ($suggestedPackages) {
  17307. $this->io->writeError('<info>'.count($suggestedPackages).' package suggestions were added by new dependencies, use `composer suggest` to see details.</info>');
  17308. }
  17309. return $this;
  17310. }
  17311. private function getFilteredSuggestions(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
  17312. {
  17313. $suggestedPackages = $this->getPackages();
  17314. $installedNames = array();
  17315. if (null !== $installedRepo && !empty($suggestedPackages)) {
  17316. foreach ($installedRepo->getPackages() as $package) {
  17317. $installedNames = array_merge(
  17318. $installedNames,
  17319. $package->getNames()
  17320. );
  17321. }
  17322. }
  17323. $sourceFilter = array();
  17324. if ($onlyDependentsOf) {
  17325. $sourceFilter = array_map(function ($link) {
  17326. return $link->getTarget();
  17327. }, array_merge($onlyDependentsOf->getRequires(), $onlyDependentsOf->getDevRequires()));
  17328. $sourceFilter[] = $onlyDependentsOf->getName();
  17329. }
  17330. $suggestions = array();
  17331. foreach ($suggestedPackages as $suggestion) {
  17332. if (in_array($suggestion['target'], $installedNames) || ($sourceFilter && !in_array($suggestion['source'], $sourceFilter))) {
  17333. continue;
  17334. }
  17335. $suggestions[] = $suggestion;
  17336. }
  17337. return $suggestions;
  17338. }
  17339. private function escapeOutput($string)
  17340. {
  17341. return OutputFormatter::escape(
  17342. $this->removeControlCharacters($string)
  17343. );
  17344. }
  17345. private function removeControlCharacters($string)
  17346. {
  17347. return preg_replace(
  17348. '/[[:cntrl:]]/',
  17349. '',
  17350. str_replace("\n", ' ', $string)
  17351. );
  17352. }
  17353. }
  17354. <?php
  17355. namespace Composer\Json;
  17356. use JsonSchema\Validator;
  17357. use Seld\JsonLint\JsonParser;
  17358. use Seld\JsonLint\ParsingException;
  17359. use Composer\Util\HttpDownloader;
  17360. use Composer\IO\IOInterface;
  17361. use Composer\Downloader\TransportException;
  17362. class JsonFile
  17363. {
  17364. const LAX_SCHEMA = 1;
  17365. const STRICT_SCHEMA = 2;
  17366. const JSON_UNESCAPED_SLASHES = 64;
  17367. const JSON_PRETTY_PRINT = 128;
  17368. const JSON_UNESCAPED_UNICODE = 256;
  17369. const COMPOSER_SCHEMA_PATH = '/../../../res/composer-schema.json';
  17370. private $path;
  17371. private $httpDownloader;
  17372. private $io;
  17373. public function __construct($path, HttpDownloader $httpDownloader = null, IOInterface $io = null)
  17374. {
  17375. $this->path = $path;
  17376. if (null === $httpDownloader && preg_match('{^https?://}i', $path)) {
  17377. throw new \InvalidArgumentException('http urls require a HttpDownloader instance to be passed');
  17378. }
  17379. $this->httpDownloader = $httpDownloader;
  17380. $this->io = $io;
  17381. }
  17382. public function getPath()
  17383. {
  17384. return $this->path;
  17385. }
  17386. public function exists()
  17387. {
  17388. return is_file($this->path);
  17389. }
  17390. public function read()
  17391. {
  17392. try {
  17393. if ($this->httpDownloader) {
  17394. $json = $this->httpDownloader->get($this->path)->getBody();
  17395. } else {
  17396. if ($this->io && $this->io->isDebug()) {
  17397. $this->io->writeError('Reading ' . $this->path);
  17398. }
  17399. $json = file_get_contents($this->path);
  17400. }
  17401. } catch (TransportException $e) {
  17402. throw new \RuntimeException($e->getMessage(), 0, $e);
  17403. } catch (\Exception $e) {
  17404. throw new \RuntimeException('Could not read '.$this->path."\n\n".$e->getMessage());
  17405. }
  17406. return static::parseJson($json, $this->path);
  17407. }
  17408. public function write(array $hash, $options = 448)
  17409. {
  17410. if ($this->path === 'php://memory') {
  17411. file_put_contents($this->path, static::encode($hash, $options));
  17412. return;
  17413. }
  17414. $dir = dirname($this->path);
  17415. if (!is_dir($dir)) {
  17416. if (file_exists($dir)) {
  17417. throw new \UnexpectedValueException(
  17418. realpath($dir).' exists and is not a directory.'
  17419. );
  17420. }
  17421. if (!@mkdir($dir, 0777, true)) {
  17422. throw new \UnexpectedValueException(
  17423. $dir.' does not exist and could not be created.'
  17424. );
  17425. }
  17426. }
  17427. $retries = 3;
  17428. while ($retries--) {
  17429. try {
  17430. $this->filePutContentsIfModified($this->path, static::encode($hash, $options). ($options & self::JSON_PRETTY_PRINT ? "\n" : ''));
  17431. break;
  17432. } catch (\Exception $e) {
  17433. if ($retries) {
  17434. usleep(500000);
  17435. continue;
  17436. }
  17437. throw $e;
  17438. }
  17439. }
  17440. }
  17441. private function filePutContentsIfModified($path, $content)
  17442. {
  17443. $currentContent = @file_get_contents($path);
  17444. if (!$currentContent || ($currentContent != $content)) {
  17445. return file_put_contents($path, $content);
  17446. }
  17447. return 0;
  17448. }
  17449. public function validateSchema($schema = self::STRICT_SCHEMA, $schemaFile = null)
  17450. {
  17451. $content = file_get_contents($this->path);
  17452. $data = json_decode($content);
  17453. if (null === $data && 'null' !== $content) {
  17454. self::validateSyntax($content, $this->path);
  17455. }
  17456. if (null === $schemaFile) {
  17457. $schemaFile = __DIR__ . self::COMPOSER_SCHEMA_PATH;
  17458. }
  17459. if (false === strpos($schemaFile, '://')) {
  17460. $schemaFile = 'file://' . $schemaFile;
  17461. }
  17462. $schemaData = (object) array('$ref' => $schemaFile);
  17463. if ($schema === self::LAX_SCHEMA) {
  17464. $schemaData->additionalProperties = true;
  17465. $schemaData->required = array();
  17466. }
  17467. $validator = new Validator();
  17468. $validator->check($data, $schemaData);
  17469. if (!$validator->isValid()) {
  17470. $errors = array();
  17471. foreach ((array) $validator->getErrors() as $error) {
  17472. $errors[] = ($error['property'] ? $error['property'].' : ' : '').$error['message'];
  17473. }
  17474. throw new JsonValidationException('"'.$this->path.'" does not match the expected JSON schema', $errors);
  17475. }
  17476. return true;
  17477. }
  17478. public static function encode($data, $options = 448)
  17479. {
  17480. if (PHP_VERSION_ID >= 50400) {
  17481. $json = json_encode($data, $options);
  17482. if (false === $json) {
  17483. self::throwEncodeError(json_last_error());
  17484. }
  17485. if (PHP_VERSION_ID < 50428 || (PHP_VERSION_ID >= 50500 && PHP_VERSION_ID < 50512) || (defined('JSON_C_VERSION') && version_compare(phpversion('json'), '1.3.6', '<'))) {
  17486. $json = preg_replace('/\[\s+\]/', '[]', $json);
  17487. $json = preg_replace('/\{\s+\}/', '{}', $json);
  17488. }
  17489. return $json;
  17490. }
  17491. $json = json_encode($data);
  17492. if (false === $json) {
  17493. self::throwEncodeError(json_last_error());
  17494. }
  17495. $prettyPrint = (bool) ($options & self::JSON_PRETTY_PRINT);
  17496. $unescapeUnicode = (bool) ($options & self::JSON_UNESCAPED_UNICODE);
  17497. $unescapeSlashes = (bool) ($options & self::JSON_UNESCAPED_SLASHES);
  17498. if (!$prettyPrint && !$unescapeUnicode && !$unescapeSlashes) {
  17499. return $json;
  17500. }
  17501. return JsonFormatter::format($json, $unescapeUnicode, $unescapeSlashes);
  17502. }
  17503. private static function throwEncodeError($code)
  17504. {
  17505. switch ($code) {
  17506. case JSON_ERROR_DEPTH:
  17507. $msg = 'Maximum stack depth exceeded';
  17508. break;
  17509. case JSON_ERROR_STATE_MISMATCH:
  17510. $msg = 'Underflow or the modes mismatch';
  17511. break;
  17512. case JSON_ERROR_CTRL_CHAR:
  17513. $msg = 'Unexpected control character found';
  17514. break;
  17515. case JSON_ERROR_UTF8:
  17516. $msg = 'Malformed UTF-8 characters, possibly incorrectly encoded';
  17517. break;
  17518. default:
  17519. $msg = 'Unknown error';
  17520. }
  17521. throw new \RuntimeException('JSON encoding failed: '.$msg);
  17522. }
  17523. public static function parseJson($json, $file = null)
  17524. {
  17525. if (null === $json) {
  17526. return;
  17527. }
  17528. $data = json_decode($json, true);
  17529. if (null === $data && JSON_ERROR_NONE !== json_last_error()) {
  17530. self::validateSyntax($json, $file);
  17531. }
  17532. return $data;
  17533. }
  17534. protected static function validateSyntax($json, $file = null)
  17535. {
  17536. $parser = new JsonParser();
  17537. $result = $parser->lint($json);
  17538. if (null === $result) {
  17539. if (defined('JSON_ERROR_UTF8') && JSON_ERROR_UTF8 === json_last_error()) {
  17540. throw new \UnexpectedValueException('"'.$file.'" is not UTF-8, could not parse as JSON');
  17541. }
  17542. return true;
  17543. }
  17544. throw new ParsingException('"'.$file.'" does not contain valid JSON'."\n".$result->getMessage(), $result->getDetails());
  17545. }
  17546. }
  17547. <?php
  17548. namespace Composer\Json;
  17549. class JsonFormatter
  17550. {
  17551. public static function format($json, $unescapeUnicode, $unescapeSlashes)
  17552. {
  17553. $result = '';
  17554. $pos = 0;
  17555. $strLen = strlen($json);
  17556. $indentStr = ' ';
  17557. $newLine = "\n";
  17558. $outOfQuotes = true;
  17559. $buffer = '';
  17560. $noescape = true;
  17561. for ($i = 0; $i < $strLen; $i++) {
  17562. $char = substr($json, $i, 1);
  17563. if ('"' === $char && $noescape) {
  17564. $outOfQuotes = !$outOfQuotes;
  17565. }
  17566. if (!$outOfQuotes) {
  17567. $buffer .= $char;
  17568. $noescape = '\\' === $char ? !$noescape : true;
  17569. continue;
  17570. }
  17571. if ('' !== $buffer) {
  17572. if ($unescapeSlashes) {
  17573. $buffer = str_replace('\\/', '/', $buffer);
  17574. }
  17575. if ($unescapeUnicode && function_exists('mb_convert_encoding')) {
  17576. $buffer = preg_replace_callback('/(\\\\+)u([0-9a-f]{4})/i', function ($match) {
  17577. $l = strlen($match[1]);
  17578. if ($l % 2) {
  17579. $code = hexdec($match[2]);
  17580. if (0xD800 <= $code && 0xDFFF >= $code) {
  17581. return $match[0];
  17582. }
  17583. return str_repeat('\\', $l - 1) . mb_convert_encoding(
  17584. pack('H*', $match[2]),
  17585. 'UTF-8',
  17586. 'UCS-2BE'
  17587. );
  17588. }
  17589. return $match[0];
  17590. }, $buffer);
  17591. }
  17592. $result .= $buffer.$char;
  17593. $buffer = '';
  17594. continue;
  17595. }
  17596. if (':' === $char) {
  17597. $char .= ' ';
  17598. } elseif ('}' === $char || ']' === $char) {
  17599. $pos--;
  17600. $prevChar = substr($json, $i - 1, 1);
  17601. if ('{' !== $prevChar && '[' !== $prevChar) {
  17602. $result .= $newLine;
  17603. for ($j = 0; $j < $pos; $j++) {
  17604. $result .= $indentStr;
  17605. }
  17606. } else {
  17607. $result = rtrim($result);
  17608. }
  17609. }
  17610. $result .= $char;
  17611. if (',' === $char || '{' === $char || '[' === $char) {
  17612. $result .= $newLine;
  17613. if ('{' === $char || '[' === $char) {
  17614. $pos++;
  17615. }
  17616. for ($j = 0; $j < $pos; $j++) {
  17617. $result .= $indentStr;
  17618. }
  17619. }
  17620. }
  17621. return $result;
  17622. }
  17623. }
  17624. <?php
  17625. namespace Composer\Json;
  17626. use Composer\Repository\PlatformRepository;
  17627. class JsonManipulator
  17628. {
  17629. private static $DEFINES = '(?(DEFINE)
  17630. (?<number> -? (?= [1-9]|0(?!\d) ) \d+ (\.\d+)? ([eE] [+-]? \d+)? )
  17631. (?<boolean> true | false | null )
  17632. (?<string> " ([^"\\\\]* | \\\\ ["\\\\bfnrt\/] | \\\\ u [0-9A-Fa-f]{4} )* " )
  17633. (?<array> \[ (?: (?&json) \s* (?: , (?&json) \s* )* )? \s* \] )
  17634. (?<pair> \s* (?&string) \s* : (?&json) \s* )
  17635. (?<object> \{ (?: (?&pair) (?: , (?&pair) )* )? \s* \} )
  17636. (?<json> \s* (?: (?&number) | (?&boolean) | (?&string) | (?&array) | (?&object) ) )
  17637. )';
  17638. private $contents;
  17639. private $newline;
  17640. private $indent;
  17641. public function __construct($contents)
  17642. {
  17643. $contents = trim($contents);
  17644. if ($contents === '') {
  17645. $contents = '{}';
  17646. }
  17647. if (!$this->pregMatch('#^\{(.*)\}$#s', $contents)) {
  17648. throw new \InvalidArgumentException('The json file must be an object ({})');
  17649. }
  17650. $this->newline = false !== strpos($contents, "\r\n") ? "\r\n" : "\n";
  17651. $this->contents = $contents === '{}' ? '{' . $this->newline . '}' : $contents;
  17652. $this->detectIndenting();
  17653. }
  17654. public function getContents()
  17655. {
  17656. return $this->contents . $this->newline;
  17657. }
  17658. public function addLink($type, $package, $constraint, $sortPackages = false)
  17659. {
  17660. $decoded = JsonFile::parseJson($this->contents);
  17661. if (!isset($decoded[$type])) {
  17662. return $this->addMainKey($type, array($package => $constraint));
  17663. }
  17664. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  17665. '(?P<property>'.preg_quote(JsonFile::encode($type)).'\s*:\s*)(?P<value>(?&json))(?P<end>.*)}sx';
  17666. if (!$this->pregMatch($regex, $this->contents, $matches)) {
  17667. return false;
  17668. }
  17669. $links = $matches['value'];
  17670. $packageRegex = str_replace('/', '\\\\?/', preg_quote($package));
  17671. $regex = '{'.self::$DEFINES.'"(?P<package>'.$packageRegex.')"(\s*:\s*)(?&string)}ix';
  17672. if ($this->pregMatch($regex, $links, $packageMatches)) {
  17673. $existingPackage = $packageMatches['package'];
  17674. $packageRegex = str_replace('/', '\\\\?/', preg_quote($existingPackage));
  17675. $links = preg_replace_callback('{'.self::$DEFINES.'"'.$packageRegex.'"(?P<separator>\s*:\s*)(?&string)}ix', function ($m) use ($existingPackage, $constraint) {
  17676. return JsonFile::encode(str_replace('\\/', '/', $existingPackage)) . $m['separator'] . '"' . $constraint . '"';
  17677. }, $links);
  17678. } else {
  17679. if ($this->pregMatch('#^\s*\{\s*\S+.*?(\s*\}\s*)$#s', $links, $match)) {
  17680. $links = preg_replace(
  17681. '{'.preg_quote($match[1]).'$}',
  17682. addcslashes(',' . $this->newline . $this->indent . $this->indent . JsonFile::encode($package).': '.JsonFile::encode($constraint) . $match[1], '\\$'),
  17683. $links
  17684. );
  17685. } else {
  17686. $links = '{' . $this->newline .
  17687. $this->indent . $this->indent . JsonFile::encode($package).': '.JsonFile::encode($constraint) . $this->newline .
  17688. $this->indent . '}';
  17689. }
  17690. }
  17691. if (true === $sortPackages) {
  17692. $requirements = json_decode($links, true);
  17693. $this->sortPackages($requirements);
  17694. $links = $this->format($requirements);
  17695. }
  17696. $this->contents = $matches['start'] . $matches['property'] . $links . $matches['end'];
  17697. return true;
  17698. }
  17699. private function sortPackages(array &$packages = array())
  17700. {
  17701. $prefix = function ($requirement) {
  17702. if (PlatformRepository::isPlatformPackage($requirement)) {
  17703. return preg_replace(
  17704. array(
  17705. '/^php/',
  17706. '/^hhvm/',
  17707. '/^ext/',
  17708. '/^lib/',
  17709. '/^\D/',
  17710. ),
  17711. array(
  17712. '0-$0',
  17713. '1-$0',
  17714. '2-$0',
  17715. '3-$0',
  17716. '4-$0',
  17717. ),
  17718. $requirement
  17719. );
  17720. }
  17721. return '5-'.$requirement;
  17722. };
  17723. uksort($packages, function ($a, $b) use ($prefix) {
  17724. return strnatcmp($prefix($a), $prefix($b));
  17725. });
  17726. }
  17727. public function addRepository($name, $config)
  17728. {
  17729. return $this->addSubNode('repositories', $name, $config);
  17730. }
  17731. public function removeRepository($name)
  17732. {
  17733. return $this->removeSubNode('repositories', $name);
  17734. }
  17735. public function addConfigSetting($name, $value)
  17736. {
  17737. return $this->addSubNode('config', $name, $value);
  17738. }
  17739. public function removeConfigSetting($name)
  17740. {
  17741. return $this->removeSubNode('config', $name);
  17742. }
  17743. public function addProperty($name, $value)
  17744. {
  17745. if (strpos($name, 'suggest.') === 0) {
  17746. return $this->addSubNode('suggest', substr($name, 8), $value);
  17747. }
  17748. if (strpos($name, 'extra.') === 0) {
  17749. return $this->addSubNode('extra', substr($name, 6), $value);
  17750. }
  17751. if (strpos($name, 'scripts.') === 0) {
  17752. return $this->addSubNode('scripts', substr($name, 8), $value);
  17753. }
  17754. return $this->addMainKey($name, $value);
  17755. }
  17756. public function removeProperty($name)
  17757. {
  17758. if (strpos($name, 'suggest.') === 0) {
  17759. return $this->removeSubNode('suggest', substr($name, 8));
  17760. }
  17761. if (strpos($name, 'extra.') === 0) {
  17762. return $this->removeSubNode('extra', substr($name, 6));
  17763. }
  17764. if (strpos($name, 'scripts.') === 0) {
  17765. return $this->removeSubNode('scripts', substr($name, 8));
  17766. }
  17767. return $this->removeMainKey($name);
  17768. }
  17769. public function addSubNode($mainNode, $name, $value)
  17770. {
  17771. $decoded = JsonFile::parseJson($this->contents);
  17772. $subName = null;
  17773. if (in_array($mainNode, array('config', 'extra', 'scripts')) && false !== strpos($name, '.')) {
  17774. list($name, $subName) = explode('.', $name, 2);
  17775. }
  17776. if (!isset($decoded[$mainNode])) {
  17777. if ($subName !== null) {
  17778. $this->addMainKey($mainNode, array($name => array($subName => $value)));
  17779. } else {
  17780. $this->addMainKey($mainNode, array($name => $value));
  17781. }
  17782. return true;
  17783. }
  17784. $nodeRegex = '{'.self::$DEFINES.'^(?P<start> \s* \{ \s* (?: (?&string) \s* : (?&json) \s* , \s* )*?'.
  17785. preg_quote(JsonFile::encode($mainNode)).'\s*:\s*)(?P<content>(?&object))(?P<end>.*)}sx';
  17786. try {
  17787. if (!$this->pregMatch($nodeRegex, $this->contents, $match)) {
  17788. return false;
  17789. }
  17790. } catch (\RuntimeException $e) {
  17791. if ($e->getCode() === PREG_BACKTRACK_LIMIT_ERROR) {
  17792. return false;
  17793. }
  17794. throw $e;
  17795. }
  17796. $children = $match['content'];
  17797. if (!@json_decode($children)) {
  17798. return false;
  17799. }
  17800. $that = $this;
  17801. $childRegex = '{'.self::$DEFINES.'(?P<start>"'.preg_quote($name).'"\s*:\s*)(?P<content>(?&json))(?P<end>,?)}x';
  17802. if ($this->pregMatch($childRegex, $children, $matches)) {
  17803. $children = preg_replace_callback($childRegex, function ($matches) use ($subName, $value, $that) {
  17804. if ($subName !== null) {
  17805. $curVal = json_decode($matches['content'], true);
  17806. if (!is_array($curVal)) {
  17807. $curVal = array();
  17808. }
  17809. $curVal[$subName] = $value;
  17810. $value = $curVal;
  17811. }
  17812. return $matches['start'] . $that->format($value, 1) . $matches['end'];
  17813. }, $children);
  17814. } else {
  17815. $this->pregMatch('#^{ \s*? (?P<content>\S+.*?)? (?P<trailingspace>\s*) }$#sx', $children, $match);
  17816. $whitespace = '';
  17817. if (!empty($match['trailingspace'])) {
  17818. $whitespace = $match['trailingspace'];
  17819. }
  17820. if (!empty($match['content'])) {
  17821. if ($subName !== null) {
  17822. $value = array($subName => $value);
  17823. }
  17824. $children = preg_replace(
  17825. '#'.$whitespace.'}$#',
  17826. addcslashes(',' . $this->newline . $this->indent . $this->indent . JsonFile::encode($name).': '.$this->format($value, 1) . $whitespace . '}', '\\$'),
  17827. $children
  17828. );
  17829. } else {
  17830. if ($subName !== null) {
  17831. $value = array($subName => $value);
  17832. }
  17833. $children = '{' . $this->newline . $this->indent . $this->indent . JsonFile::encode($name).': '.$this->format($value, 1) . $whitespace . '}';
  17834. }
  17835. }
  17836. $this->contents = preg_replace_callback($nodeRegex, function ($m) use ($children) {
  17837. return $m['start'] . $children . $m['end'];
  17838. }, $this->contents);
  17839. return true;
  17840. }
  17841. public function removeSubNode($mainNode, $name)
  17842. {
  17843. $decoded = JsonFile::parseJson($this->contents);
  17844. if (empty($decoded[$mainNode])) {
  17845. return true;
  17846. }
  17847. $nodeRegex = '{'.self::$DEFINES.'^(?P<start> \s* \{ \s* (?: (?&string) \s* : (?&json) \s* , \s* )*?'.
  17848. preg_quote(JsonFile::encode($mainNode)).'\s*:\s*)(?P<content>(?&object))(?P<end>.*)}sx';
  17849. try {
  17850. if (!$this->pregMatch($nodeRegex, $this->contents, $match)) {
  17851. return false;
  17852. }
  17853. } catch (\RuntimeException $e) {
  17854. if ($e->getCode() === PREG_BACKTRACK_LIMIT_ERROR) {
  17855. return false;
  17856. }
  17857. throw $e;
  17858. }
  17859. $children = $match['content'];
  17860. if (!@json_decode($children, true)) {
  17861. return false;
  17862. }
  17863. $subName = null;
  17864. if (in_array($mainNode, array('config', 'extra', 'scripts')) && false !== strpos($name, '.')) {
  17865. list($name, $subName) = explode('.', $name, 2);
  17866. }
  17867. if (!isset($decoded[$mainNode][$name]) || ($subName && !isset($decoded[$mainNode][$name][$subName]))) {
  17868. return true;
  17869. }
  17870. $keyRegex = str_replace('/', '\\\\?/', preg_quote($name));
  17871. if ($this->pregMatch('{"'.$keyRegex.'"\s*:}i', $children)) {
  17872. if (preg_match_all('{'.self::$DEFINES.'"'.$keyRegex.'"\s*:\s*(?:(?&json))}x', $children, $matches)) {
  17873. $bestMatch = '';
  17874. foreach ($matches[0] as $match) {
  17875. if (strlen($bestMatch) < strlen($match)) {
  17876. $bestMatch = $match;
  17877. }
  17878. }
  17879. $childrenClean = preg_replace('{,\s*'.preg_quote($bestMatch).'}i', '', $children, -1, $count);
  17880. if (1 !== $count) {
  17881. $childrenClean = preg_replace('{'.preg_quote($bestMatch).'\s*,?\s*}i', '', $childrenClean, -1, $count);
  17882. if (1 !== $count) {
  17883. return false;
  17884. }
  17885. }
  17886. }
  17887. } else {
  17888. $childrenClean = $children;
  17889. }
  17890. if (!isset($childrenClean)) {
  17891. throw new \InvalidArgumentException("JsonManipulator: \$childrenClean is not defined. Please report at https://github.com/composer/composer/issues/new.");
  17892. }
  17893. $this->pregMatch('#^{ \s*? (?P<content>\S+.*?)? (?P<trailingspace>\s*) }$#sx', $childrenClean, $match);
  17894. if (empty($match['content'])) {
  17895. $newline = $this->newline;
  17896. $indent = $this->indent;
  17897. $this->contents = preg_replace_callback($nodeRegex, function ($matches) use ($indent, $newline) {
  17898. return $matches['start'] . '{' . $newline . $indent . '}' . $matches['end'];
  17899. }, $this->contents);
  17900. if ($subName !== null) {
  17901. $curVal = json_decode($children, true);
  17902. unset($curVal[$name][$subName]);
  17903. $this->addSubNode($mainNode, $name, $curVal[$name]);
  17904. }
  17905. return true;
  17906. }
  17907. $that = $this;
  17908. $this->contents = preg_replace_callback($nodeRegex, function ($matches) use ($that, $name, $subName, $childrenClean) {
  17909. if ($subName !== null) {
  17910. $curVal = json_decode($matches['content'], true);
  17911. unset($curVal[$name][$subName]);
  17912. $childrenClean = $that->format($curVal);
  17913. }
  17914. return $matches['start'] . $childrenClean . $matches['end'];
  17915. }, $this->contents);
  17916. return true;
  17917. }
  17918. public function addMainKey($key, $content)
  17919. {
  17920. $decoded = JsonFile::parseJson($this->contents);
  17921. $content = $this->format($content);
  17922. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  17923. '(?P<key>'.preg_quote(JsonFile::encode($key)).'\s*:\s*(?&json))(?P<end>.*)}sx';
  17924. if (isset($decoded[$key]) && $this->pregMatch($regex, $this->contents, $matches)) {
  17925. if (!@json_decode('{'.$matches['key'].'}')) {
  17926. return false;
  17927. }
  17928. $this->contents = $matches['start'] . JsonFile::encode($key).': '.$content . $matches['end'];
  17929. return true;
  17930. }
  17931. if ($this->pregMatch('#[^{\s](\s*)\}$#', $this->contents, $match)) {
  17932. $this->contents = preg_replace(
  17933. '#'.$match[1].'\}$#',
  17934. addcslashes(',' . $this->newline . $this->indent . JsonFile::encode($key). ': '. $content . $this->newline . '}', '\\$'),
  17935. $this->contents
  17936. );
  17937. return true;
  17938. }
  17939. $this->contents = preg_replace(
  17940. '#\}$#',
  17941. addcslashes($this->indent . JsonFile::encode($key). ': '.$content . $this->newline . '}', '\\$'),
  17942. $this->contents
  17943. );
  17944. return true;
  17945. }
  17946. public function removeMainKey($key)
  17947. {
  17948. $decoded = JsonFile::parseJson($this->contents);
  17949. if (!array_key_exists($key, $decoded)) {
  17950. return true;
  17951. }
  17952. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  17953. '(?P<removal>'.preg_quote(JsonFile::encode($key)).'\s*:\s*(?&json))\s*,?\s*(?P<end>.*)}sx';
  17954. if ($this->pregMatch($regex, $this->contents, $matches)) {
  17955. if (!@json_decode('{'.$matches['removal'].'}')) {
  17956. return false;
  17957. }
  17958. if (preg_match('#,\s*$#', $matches['start']) && preg_match('#^\}$#', $matches['end'])) {
  17959. $matches['start'] = rtrim(preg_replace('#,(\s*)$#', '$1', $matches['start']), $this->indent);
  17960. }
  17961. $this->contents = $matches['start'] . $matches['end'];
  17962. if (preg_match('#^\{\s*\}\s*$#', $this->contents)) {
  17963. $this->contents = "{\n}";
  17964. }
  17965. return true;
  17966. }
  17967. return false;
  17968. }
  17969. public function format($data, $depth = 0)
  17970. {
  17971. if (is_array($data)) {
  17972. reset($data);
  17973. if (is_numeric(key($data))) {
  17974. foreach ($data as $key => $val) {
  17975. $data[$key] = $this->format($val, $depth + 1);
  17976. }
  17977. return '['.implode(', ', $data).']';
  17978. }
  17979. $out = '{' . $this->newline;
  17980. $elems = array();
  17981. foreach ($data as $key => $val) {
  17982. $elems[] = str_repeat($this->indent, $depth + 2) . JsonFile::encode($key). ': '.$this->format($val, $depth + 1);
  17983. }
  17984. return $out . implode(','.$this->newline, $elems) . $this->newline . str_repeat($this->indent, $depth + 1) . '}';
  17985. }
  17986. return JsonFile::encode($data);
  17987. }
  17988. protected function detectIndenting()
  17989. {
  17990. if ($this->pregMatch('{^([ \t]+)"}m', $this->contents, $match)) {
  17991. $this->indent = $match[1];
  17992. } else {
  17993. $this->indent = ' ';
  17994. }
  17995. }
  17996. protected function pregMatch($re, $str, &$matches = array())
  17997. {
  17998. $count = preg_match($re, $str, $matches);
  17999. if ($count === false) {
  18000. switch (preg_last_error()) {
  18001. case PREG_NO_ERROR:
  18002. throw new \RuntimeException('Failed to execute regex: PREG_NO_ERROR', PREG_NO_ERROR);
  18003. case PREG_INTERNAL_ERROR:
  18004. throw new \RuntimeException('Failed to execute regex: PREG_INTERNAL_ERROR', PREG_INTERNAL_ERROR);
  18005. case PREG_BACKTRACK_LIMIT_ERROR:
  18006. throw new \RuntimeException('Failed to execute regex: PREG_BACKTRACK_LIMIT_ERROR', PREG_BACKTRACK_LIMIT_ERROR);
  18007. case PREG_RECURSION_LIMIT_ERROR:
  18008. throw new \RuntimeException('Failed to execute regex: PREG_RECURSION_LIMIT_ERROR', PREG_RECURSION_LIMIT_ERROR);
  18009. case PREG_BAD_UTF8_ERROR:
  18010. throw new \RuntimeException('Failed to execute regex: PREG_BAD_UTF8_ERROR', PREG_BAD_UTF8_ERROR);
  18011. case PREG_BAD_UTF8_OFFSET_ERROR:
  18012. throw new \RuntimeException('Failed to execute regex: PREG_BAD_UTF8_OFFSET_ERROR', PREG_BAD_UTF8_OFFSET_ERROR);
  18013. case 6:
  18014. if (PHP_VERSION_ID > 70000) {
  18015. throw new \RuntimeException('Failed to execute regex: PREG_JIT_STACKLIMIT_ERROR', 6);
  18016. }
  18017. default:
  18018. throw new \RuntimeException('Failed to execute regex: Unknown error');
  18019. }
  18020. }
  18021. return $count;
  18022. }
  18023. }
  18024. <?php
  18025. namespace Composer\Json;
  18026. use Exception;
  18027. class JsonValidationException extends Exception
  18028. {
  18029. protected $errors;
  18030. public function __construct($message, $errors = array(), Exception $previous = null)
  18031. {
  18032. $this->errors = $errors;
  18033. parent::__construct($message, 0, $previous);
  18034. }
  18035. public function getErrors()
  18036. {
  18037. return $this->errors;
  18038. }
  18039. }
  18040. <?php
  18041. namespace Composer\Package;
  18042. use Composer\Semver\Constraint\Constraint;
  18043. use Composer\Package\Version\VersionParser;
  18044. class AliasPackage extends BasePackage implements CompletePackageInterface
  18045. {
  18046. protected $version;
  18047. protected $prettyVersion;
  18048. protected $dev;
  18049. protected $rootPackageAlias = false;
  18050. protected $stability;
  18051. protected $hasSelfVersionRequires = false;
  18052. protected $aliasOf;
  18053. protected $requires;
  18054. protected $devRequires;
  18055. protected $conflicts;
  18056. protected $provides;
  18057. protected $replaces;
  18058. public function __construct(PackageInterface $aliasOf, $version, $prettyVersion)
  18059. {
  18060. parent::__construct($aliasOf->getName());
  18061. $this->version = $version;
  18062. $this->prettyVersion = $prettyVersion;
  18063. $this->aliasOf = $aliasOf;
  18064. $this->stability = VersionParser::parseStability($version);
  18065. $this->dev = $this->stability === 'dev';
  18066. foreach (Link::$TYPES as $type) {
  18067. $links = $aliasOf->{'get' . ucfirst($type)}();
  18068. $this->$type = $this->replaceSelfVersionDependencies($links, $type);
  18069. }
  18070. }
  18071. public function getAliasOf()
  18072. {
  18073. return $this->aliasOf;
  18074. }
  18075. public function getVersion()
  18076. {
  18077. return $this->version;
  18078. }
  18079. public function getStability()
  18080. {
  18081. return $this->stability;
  18082. }
  18083. public function getPrettyVersion()
  18084. {
  18085. return $this->prettyVersion;
  18086. }
  18087. public function isDev()
  18088. {
  18089. return $this->dev;
  18090. }
  18091. public function getRequires()
  18092. {
  18093. return $this->requires;
  18094. }
  18095. public function getConflicts()
  18096. {
  18097. return $this->conflicts;
  18098. }
  18099. public function getProvides()
  18100. {
  18101. return $this->provides;
  18102. }
  18103. public function getReplaces()
  18104. {
  18105. return $this->replaces;
  18106. }
  18107. public function getDevRequires()
  18108. {
  18109. return $this->devRequires;
  18110. }
  18111. public function setRootPackageAlias($value)
  18112. {
  18113. return $this->rootPackageAlias = $value;
  18114. }
  18115. public function isRootPackageAlias()
  18116. {
  18117. return $this->rootPackageAlias;
  18118. }
  18119. protected function replaceSelfVersionDependencies(array $links, $linkType)
  18120. {
  18121. $prettyVersion = $this->prettyVersion;
  18122. if ($prettyVersion === VersionParser::DEFAULT_BRANCH_ALIAS) {
  18123. $prettyVersion = $this->aliasOf->getPrettyVersion();
  18124. }
  18125. if (\in_array($linkType, array(Link::TYPE_CONFLICT, Link::TYPE_PROVIDE, Link::TYPE_REPLACE), true)) {
  18126. $newLinks = array();
  18127. foreach ($links as $link) {
  18128. if ('self.version' === $link->getPrettyConstraint()) {
  18129. $newLinks[] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
  18130. $constraint->setPrettyString($prettyVersion);
  18131. }
  18132. }
  18133. $links = array_merge($links, $newLinks);
  18134. } else {
  18135. foreach ($links as $index => $link) {
  18136. if ('self.version' === $link->getPrettyConstraint()) {
  18137. if ($linkType === Link::TYPE_REQUIRE) {
  18138. $this->hasSelfVersionRequires = true;
  18139. }
  18140. $links[$index] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
  18141. $constraint->setPrettyString($prettyVersion);
  18142. }
  18143. }
  18144. }
  18145. return $links;
  18146. }
  18147. public function hasSelfVersionRequires()
  18148. {
  18149. return $this->hasSelfVersionRequires;
  18150. }
  18151. public function getType()
  18152. {
  18153. return $this->aliasOf->getType();
  18154. }
  18155. public function getTargetDir()
  18156. {
  18157. return $this->aliasOf->getTargetDir();
  18158. }
  18159. public function getExtra()
  18160. {
  18161. return $this->aliasOf->getExtra();
  18162. }
  18163. public function setInstallationSource($type)
  18164. {
  18165. $this->aliasOf->setInstallationSource($type);
  18166. }
  18167. public function getInstallationSource()
  18168. {
  18169. return $this->aliasOf->getInstallationSource();
  18170. }
  18171. public function getSourceType()
  18172. {
  18173. return $this->aliasOf->getSourceType();
  18174. }
  18175. public function getSourceUrl()
  18176. {
  18177. return $this->aliasOf->getSourceUrl();
  18178. }
  18179. public function getSourceUrls()
  18180. {
  18181. return $this->aliasOf->getSourceUrls();
  18182. }
  18183. public function getSourceReference()
  18184. {
  18185. return $this->aliasOf->getSourceReference();
  18186. }
  18187. public function setSourceReference($reference)
  18188. {
  18189. return $this->aliasOf->setSourceReference($reference);
  18190. }
  18191. public function setSourceMirrors($mirrors)
  18192. {
  18193. return $this->aliasOf->setSourceMirrors($mirrors);
  18194. }
  18195. public function getSourceMirrors()
  18196. {
  18197. return $this->aliasOf->getSourceMirrors();
  18198. }
  18199. public function getDistType()
  18200. {
  18201. return $this->aliasOf->getDistType();
  18202. }
  18203. public function getDistUrl()
  18204. {
  18205. return $this->aliasOf->getDistUrl();
  18206. }
  18207. public function getDistUrls()
  18208. {
  18209. return $this->aliasOf->getDistUrls();
  18210. }
  18211. public function getDistReference()
  18212. {
  18213. return $this->aliasOf->getDistReference();
  18214. }
  18215. public function setDistReference($reference)
  18216. {
  18217. return $this->aliasOf->setDistReference($reference);
  18218. }
  18219. public function getDistSha1Checksum()
  18220. {
  18221. return $this->aliasOf->getDistSha1Checksum();
  18222. }
  18223. public function setTransportOptions(array $options)
  18224. {
  18225. return $this->aliasOf->setTransportOptions($options);
  18226. }
  18227. public function getTransportOptions()
  18228. {
  18229. return $this->aliasOf->getTransportOptions();
  18230. }
  18231. public function setDistMirrors($mirrors)
  18232. {
  18233. return $this->aliasOf->setDistMirrors($mirrors);
  18234. }
  18235. public function getDistMirrors()
  18236. {
  18237. return $this->aliasOf->getDistMirrors();
  18238. }
  18239. public function getScripts()
  18240. {
  18241. return $this->aliasOf->getScripts();
  18242. }
  18243. public function getLicense()
  18244. {
  18245. return $this->aliasOf->getLicense();
  18246. }
  18247. public function getAutoload()
  18248. {
  18249. return $this->aliasOf->getAutoload();
  18250. }
  18251. public function getDevAutoload()
  18252. {
  18253. return $this->aliasOf->getDevAutoload();
  18254. }
  18255. public function getIncludePaths()
  18256. {
  18257. return $this->aliasOf->getIncludePaths();
  18258. }
  18259. public function getRepositories()
  18260. {
  18261. return $this->aliasOf->getRepositories();
  18262. }
  18263. public function getReleaseDate()
  18264. {
  18265. return $this->aliasOf->getReleaseDate();
  18266. }
  18267. public function getBinaries()
  18268. {
  18269. return $this->aliasOf->getBinaries();
  18270. }
  18271. public function getKeywords()
  18272. {
  18273. return $this->aliasOf->getKeywords();
  18274. }
  18275. public function getDescription()
  18276. {
  18277. return $this->aliasOf->getDescription();
  18278. }
  18279. public function getHomepage()
  18280. {
  18281. return $this->aliasOf->getHomepage();
  18282. }
  18283. public function getSuggests()
  18284. {
  18285. return $this->aliasOf->getSuggests();
  18286. }
  18287. public function getAuthors()
  18288. {
  18289. return $this->aliasOf->getAuthors();
  18290. }
  18291. public function getSupport()
  18292. {
  18293. return $this->aliasOf->getSupport();
  18294. }
  18295. public function getFunding()
  18296. {
  18297. return $this->aliasOf->getFunding();
  18298. }
  18299. public function getNotificationUrl()
  18300. {
  18301. return $this->aliasOf->getNotificationUrl();
  18302. }
  18303. public function getArchiveName()
  18304. {
  18305. return $this->aliasOf->getArchiveName();
  18306. }
  18307. public function getArchiveExcludes()
  18308. {
  18309. return $this->aliasOf->getArchiveExcludes();
  18310. }
  18311. public function isDefaultBranch()
  18312. {
  18313. return $this->aliasOf->isDefaultBranch();
  18314. }
  18315. public function isAbandoned()
  18316. {
  18317. return $this->aliasOf->isAbandoned();
  18318. }
  18319. public function getReplacementPackage()
  18320. {
  18321. return $this->aliasOf->getReplacementPackage();
  18322. }
  18323. public function __toString()
  18324. {
  18325. return parent::__toString().' (alias of '.$this->aliasOf->getVersion().')';
  18326. }
  18327. public function setDistUrl($url)
  18328. {
  18329. return $this->aliasOf->setDistUrl($url);
  18330. }
  18331. public function setDistType($type)
  18332. {
  18333. return $this->aliasOf->setDistType($type);
  18334. }
  18335. public function setSourceDistReferences($reference)
  18336. {
  18337. return $this->aliasOf->setSourceDistReferences($reference);
  18338. }
  18339. }
  18340. <?php
  18341. namespace Composer\Package\Archiver;
  18342. use FilterIterator;
  18343. use PharData;
  18344. class ArchivableFilesFilter extends FilterIterator
  18345. {
  18346. private $dirs = array();
  18347. public function accept()
  18348. {
  18349. $file = $this->getInnerIterator()->current();
  18350. if ($file->isDir()) {
  18351. $this->dirs[] = (string) $file;
  18352. return false;
  18353. }
  18354. return true;
  18355. }
  18356. public function addEmptyDir(PharData $phar, $sources)
  18357. {
  18358. foreach ($this->dirs as $filepath) {
  18359. $localname = str_replace($sources . "/", '', $filepath);
  18360. $phar->addEmptyDir($localname);
  18361. }
  18362. }
  18363. }
  18364. <?php
  18365. namespace Composer\Package\Archiver;
  18366. use Composer\Util\Filesystem;
  18367. use FilesystemIterator;
  18368. use Symfony\Component\Finder\Finder;
  18369. use Symfony\Component\Finder\SplFileInfo;
  18370. class ArchivableFilesFinder extends \FilterIterator
  18371. {
  18372. protected $finder;
  18373. public function __construct($sources, array $excludes, $ignoreFilters = false)
  18374. {
  18375. $fs = new Filesystem();
  18376. $sources = $fs->normalizePath($sources);
  18377. if ($ignoreFilters) {
  18378. $filters = array();
  18379. } else {
  18380. $filters = array(
  18381. new HgExcludeFilter($sources),
  18382. new GitExcludeFilter($sources),
  18383. new ComposerExcludeFilter($sources, $excludes),
  18384. );
  18385. }
  18386. $this->finder = new Finder();
  18387. $filter = function (\SplFileInfo $file) use ($sources, $filters, $fs) {
  18388. if ($file->isLink() && strpos($file->getLinkTarget(), $sources) !== 0) {
  18389. return false;
  18390. }
  18391. $relativePath = preg_replace(
  18392. '#^'.preg_quote($sources, '#').'#',
  18393. '',
  18394. $fs->normalizePath($file->getRealPath())
  18395. );
  18396. $exclude = false;
  18397. foreach ($filters as $filter) {
  18398. $exclude = $filter->filter($relativePath, $exclude);
  18399. }
  18400. return !$exclude;
  18401. };
  18402. if (method_exists($filter, 'bindTo')) {
  18403. $filter = $filter->bindTo(null);
  18404. }
  18405. $this->finder
  18406. ->in($sources)
  18407. ->filter($filter)
  18408. ->ignoreVCS(true)
  18409. ->ignoreDotFiles(false);
  18410. parent::__construct($this->finder->getIterator());
  18411. }
  18412. public function accept()
  18413. {
  18414. $current = $this->getInnerIterator()->current();
  18415. if (!$current->isDir()) {
  18416. return true;
  18417. }
  18418. $iterator = new FilesystemIterator($current, FilesystemIterator::SKIP_DOTS);
  18419. return !$iterator->valid();
  18420. }
  18421. }
  18422. <?php
  18423. namespace Composer\Package\Archiver;
  18424. use Composer\Downloader\DownloadManager;
  18425. use Composer\Package\PackageInterface;
  18426. use Composer\Package\RootPackageInterface;
  18427. use Composer\Util\Filesystem;
  18428. use Composer\Util\Loop;
  18429. use Composer\Json\JsonFile;
  18430. class ArchiveManager
  18431. {
  18432. protected $downloadManager;
  18433. protected $loop;
  18434. protected $archivers = array();
  18435. protected $overwriteFiles = true;
  18436. public function __construct(DownloadManager $downloadManager, Loop $loop)
  18437. {
  18438. $this->downloadManager = $downloadManager;
  18439. $this->loop = $loop;
  18440. }
  18441. public function addArchiver(ArchiverInterface $archiver)
  18442. {
  18443. $this->archivers[] = $archiver;
  18444. }
  18445. public function setOverwriteFiles($overwriteFiles)
  18446. {
  18447. $this->overwriteFiles = $overwriteFiles;
  18448. return $this;
  18449. }
  18450. public function getPackageFilename(PackageInterface $package)
  18451. {
  18452. if ($package->getArchiveName()) {
  18453. $baseName = $package->getArchiveName();
  18454. } else {
  18455. $baseName = preg_replace('#[^a-z0-9-_]#i', '-', $package->getName());
  18456. }
  18457. $nameParts = array($baseName);
  18458. if (preg_match('{^[a-f0-9]{40}$}', $package->getDistReference())) {
  18459. array_push($nameParts, $package->getDistReference(), $package->getDistType());
  18460. } else {
  18461. array_push($nameParts, $package->getPrettyVersion(), $package->getDistReference());
  18462. }
  18463. if ($package->getSourceReference()) {
  18464. $nameParts[] = substr(sha1($package->getSourceReference()), 0, 6);
  18465. }
  18466. $name = implode('-', array_filter($nameParts, function ($p) {
  18467. return !empty($p);
  18468. }));
  18469. return str_replace('/', '-', $name);
  18470. }
  18471. public function archive(PackageInterface $package, $format, $targetDir, $fileName = null, $ignoreFilters = false)
  18472. {
  18473. if (empty($format)) {
  18474. throw new \InvalidArgumentException('Format must be specified');
  18475. }
  18476. $usableArchiver = null;
  18477. foreach ($this->archivers as $archiver) {
  18478. if ($archiver->supports($format, $package->getSourceType())) {
  18479. $usableArchiver = $archiver;
  18480. break;
  18481. }
  18482. }
  18483. if (null === $usableArchiver) {
  18484. throw new \RuntimeException(sprintf('No archiver found to support %s format', $format));
  18485. }
  18486. $filesystem = new Filesystem();
  18487. if ($package instanceof RootPackageInterface) {
  18488. $sourcePath = realpath('.');
  18489. } else {
  18490. $sourcePath = sys_get_temp_dir().'/composer_archive'.uniqid();
  18491. $filesystem->ensureDirectoryExists($sourcePath);
  18492. try {
  18493. $promise = $this->downloadManager->download($package, $sourcePath);
  18494. $this->loop->wait(array($promise));
  18495. $this->downloadManager->install($package, $sourcePath);
  18496. } catch (\Exception $e) {
  18497. $filesystem->removeDirectory($sourcePath);
  18498. throw $e;
  18499. }
  18500. if (file_exists($composerJsonPath = $sourcePath.'/composer.json')) {
  18501. $jsonFile = new JsonFile($composerJsonPath);
  18502. $jsonData = $jsonFile->read();
  18503. if (!empty($jsonData['archive']['name'])) {
  18504. $package->setArchiveName($jsonData['archive']['name']);
  18505. }
  18506. if (!empty($jsonData['archive']['exclude'])) {
  18507. $package->setArchiveExcludes($jsonData['archive']['exclude']);
  18508. }
  18509. }
  18510. }
  18511. if (null === $fileName) {
  18512. $packageName = $this->getPackageFilename($package);
  18513. } else {
  18514. $packageName = $fileName;
  18515. }
  18516. $filesystem->ensureDirectoryExists($targetDir);
  18517. $target = realpath($targetDir).'/'.$packageName.'.'.$format;
  18518. $filesystem->ensureDirectoryExists(dirname($target));
  18519. if (!$this->overwriteFiles && file_exists($target)) {
  18520. return $target;
  18521. }
  18522. $tempTarget = sys_get_temp_dir().'/composer_archive'.uniqid().'.'.$format;
  18523. $filesystem->ensureDirectoryExists(dirname($tempTarget));
  18524. $archivePath = $usableArchiver->archive($sourcePath, $tempTarget, $format, $package->getArchiveExcludes(), $ignoreFilters);
  18525. $filesystem->rename($archivePath, $target);
  18526. if (!$package instanceof RootPackageInterface) {
  18527. $filesystem->removeDirectory($sourcePath);
  18528. }
  18529. $filesystem->remove($tempTarget);
  18530. return $target;
  18531. }
  18532. }
  18533. <?php
  18534. namespace Composer\Package\Archiver;
  18535. interface ArchiverInterface
  18536. {
  18537. public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false);
  18538. public function supports($format, $sourceType);
  18539. }
  18540. <?php
  18541. namespace Composer\Package\Archiver;
  18542. use Symfony\Component\Finder;
  18543. abstract class BaseExcludeFilter
  18544. {
  18545. protected $sourcePath;
  18546. protected $excludePatterns;
  18547. public function __construct($sourcePath)
  18548. {
  18549. $this->sourcePath = $sourcePath;
  18550. $this->excludePatterns = array();
  18551. }
  18552. public function filter($relativePath, $exclude)
  18553. {
  18554. foreach ($this->excludePatterns as $patternData) {
  18555. list($pattern, $negate, $stripLeadingSlash) = $patternData;
  18556. if ($stripLeadingSlash) {
  18557. $path = substr($relativePath, 1);
  18558. } else {
  18559. $path = $relativePath;
  18560. }
  18561. if (preg_match($pattern, $path)) {
  18562. $exclude = !$negate;
  18563. }
  18564. }
  18565. return $exclude;
  18566. }
  18567. protected function parseLines(array $lines, $lineParser)
  18568. {
  18569. return array_filter(
  18570. array_map(
  18571. function ($line) use ($lineParser) {
  18572. $line = trim($line);
  18573. if (!$line || 0 === strpos($line, '#')) {
  18574. return null;
  18575. }
  18576. return call_user_func($lineParser, $line);
  18577. },
  18578. $lines
  18579. ),
  18580. function ($pattern) {
  18581. return $pattern !== null;
  18582. }
  18583. );
  18584. }
  18585. protected function generatePatterns($rules)
  18586. {
  18587. $patterns = array();
  18588. foreach ($rules as $rule) {
  18589. $patterns[] = $this->generatePattern($rule);
  18590. }
  18591. return $patterns;
  18592. }
  18593. protected function generatePattern($rule)
  18594. {
  18595. $negate = false;
  18596. $pattern = '{';
  18597. if (strlen($rule) && $rule[0] === '!') {
  18598. $negate = true;
  18599. $rule = substr($rule, 1);
  18600. }
  18601. if (strlen($rule) && $rule[0] === '/') {
  18602. $pattern .= '^/';
  18603. $rule = substr($rule, 1);
  18604. } elseif (strlen($rule) - 1 === strpos($rule, '/')) {
  18605. $pattern .= '/';
  18606. $rule = substr($rule, 0, -1);
  18607. } elseif (false === strpos($rule, '/')) {
  18608. $pattern .= '/';
  18609. }
  18610. $pattern .= substr(Finder\Glob::toRegex($rule), 2, -2) . '(?=$|/)';
  18611. return array($pattern . '}', $negate, false);
  18612. }
  18613. }
  18614. <?php
  18615. namespace Composer\Package\Archiver;
  18616. class ComposerExcludeFilter extends BaseExcludeFilter
  18617. {
  18618. public function __construct($sourcePath, array $excludeRules)
  18619. {
  18620. parent::__construct($sourcePath);
  18621. $this->excludePatterns = $this->generatePatterns($excludeRules);
  18622. }
  18623. }
  18624. <?php
  18625. namespace Composer\Package\Archiver;
  18626. class GitExcludeFilter extends BaseExcludeFilter
  18627. {
  18628. public function __construct($sourcePath)
  18629. {
  18630. parent::__construct($sourcePath);
  18631. if (file_exists($sourcePath.'/.gitignore')) {
  18632. $this->excludePatterns = $this->parseLines(
  18633. file($sourcePath.'/.gitignore'),
  18634. array($this, 'parseGitIgnoreLine')
  18635. );
  18636. }
  18637. if (file_exists($sourcePath.'/.gitattributes')) {
  18638. $this->excludePatterns = array_merge(
  18639. $this->excludePatterns,
  18640. $this->parseLines(
  18641. file($sourcePath.'/.gitattributes'),
  18642. array($this, 'parseGitAttributesLine')
  18643. )
  18644. );
  18645. }
  18646. }
  18647. public function parseGitIgnoreLine($line)
  18648. {
  18649. return $this->generatePattern($line);
  18650. }
  18651. public function parseGitAttributesLine($line)
  18652. {
  18653. $parts = preg_split('#\s+#', $line);
  18654. if (count($parts) == 2 && $parts[1] === 'export-ignore') {
  18655. return $this->generatePattern($parts[0]);
  18656. }
  18657. return null;
  18658. }
  18659. }
  18660. <?php
  18661. namespace Composer\Package\Archiver;
  18662. use Symfony\Component\Finder;
  18663. class HgExcludeFilter extends BaseExcludeFilter
  18664. {
  18665. const HG_IGNORE_REGEX = 1;
  18666. const HG_IGNORE_GLOB = 2;
  18667. protected $patternMode;
  18668. public function __construct($sourcePath)
  18669. {
  18670. parent::__construct($sourcePath);
  18671. $this->patternMode = self::HG_IGNORE_REGEX;
  18672. if (file_exists($sourcePath.'/.hgignore')) {
  18673. $this->excludePatterns = $this->parseLines(
  18674. file($sourcePath.'/.hgignore'),
  18675. array($this, 'parseHgIgnoreLine')
  18676. );
  18677. }
  18678. }
  18679. public function parseHgIgnoreLine($line)
  18680. {
  18681. if (preg_match('#^syntax\s*:\s*(glob|regexp)$#', $line, $matches)) {
  18682. if ($matches[1] === 'glob') {
  18683. $this->patternMode = self::HG_IGNORE_GLOB;
  18684. } else {
  18685. $this->patternMode = self::HG_IGNORE_REGEX;
  18686. }
  18687. return null;
  18688. }
  18689. if ($this->patternMode == self::HG_IGNORE_GLOB) {
  18690. return $this->patternFromGlob($line);
  18691. }
  18692. return $this->patternFromRegex($line);
  18693. }
  18694. protected function patternFromGlob($line)
  18695. {
  18696. $pattern = '#'.substr(Finder\Glob::toRegex($line), 2, -1).'#';
  18697. $pattern = str_replace('[^/]*', '.*', $pattern);
  18698. return array($pattern, false, true);
  18699. }
  18700. public function patternFromRegex($line)
  18701. {
  18702. $pattern = '#'.preg_replace('/((?:\\\\\\\\)*)(\\\\?)#/', '\1\2\2\\#', $line).'#';
  18703. return array($pattern, false, true);
  18704. }
  18705. }
  18706. <?php
  18707. namespace Composer\Package\Archiver;
  18708. class PharArchiver implements ArchiverInterface
  18709. {
  18710. protected static $formats = array(
  18711. 'zip' => \Phar::ZIP,
  18712. 'tar' => \Phar::TAR,
  18713. 'tar.gz' => \Phar::TAR,
  18714. 'tar.bz2' => \Phar::TAR,
  18715. );
  18716. protected static $compressFormats = array(
  18717. 'tar.gz' => \Phar::GZ,
  18718. 'tar.bz2' => \Phar::BZ2,
  18719. );
  18720. public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false)
  18721. {
  18722. $sources = realpath($sources);
  18723. if (file_exists($target)) {
  18724. unlink($target);
  18725. }
  18726. try {
  18727. $filename = substr($target, 0, strrpos($target, $format) - 1);
  18728. if (isset(static::$compressFormats[$format])) {
  18729. $target = $filename . '.tar';
  18730. }
  18731. $phar = new \PharData($target, null, null, static::$formats[$format]);
  18732. $files = new ArchivableFilesFinder($sources, $excludes, $ignoreFilters);
  18733. $filesOnly = new ArchivableFilesFilter($files);
  18734. $phar->buildFromIterator($filesOnly, $sources);
  18735. $filesOnly->addEmptyDir($phar, $sources);
  18736. if (isset(static::$compressFormats[$format])) {
  18737. if (!$phar->canCompress(static::$compressFormats[$format])) {
  18738. throw new \RuntimeException(sprintf('Can not compress to %s format', $format));
  18739. }
  18740. unlink($target);
  18741. $phar->compress(static::$compressFormats[$format]);
  18742. $target = $filename . '.' . $format;
  18743. }
  18744. return $target;
  18745. } catch (\UnexpectedValueException $e) {
  18746. $message = sprintf(
  18747. "Could not create archive '%s' from '%s': %s",
  18748. $target,
  18749. $sources,
  18750. $e->getMessage()
  18751. );
  18752. throw new \RuntimeException($message, $e->getCode(), $e);
  18753. }
  18754. }
  18755. public function supports($format, $sourceType)
  18756. {
  18757. return isset(static::$formats[$format]);
  18758. }
  18759. }
  18760. <?php
  18761. namespace Composer\Package\Archiver;
  18762. use ZipArchive;
  18763. use Composer\Util\Filesystem;
  18764. class ZipArchiver implements ArchiverInterface
  18765. {
  18766. protected static $formats = array(
  18767. 'zip' => 1,
  18768. );
  18769. public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false)
  18770. {
  18771. $fs = new Filesystem();
  18772. $sources = $fs->normalizePath($sources);
  18773. $zip = new ZipArchive();
  18774. $res = $zip->open($target, ZipArchive::CREATE);
  18775. if ($res === true) {
  18776. $files = new ArchivableFilesFinder($sources, $excludes, $ignoreFilters);
  18777. foreach ($files as $file) {
  18778. $filepath = strtr($file->getPath()."/".$file->getFilename(), '\\', '/');
  18779. $localname = str_replace($sources.'/', '', $filepath);
  18780. if ($file->isDir()) {
  18781. $zip->addEmptyDir($localname);
  18782. } else {
  18783. $zip->addFile($filepath, $localname);
  18784. }
  18785. if (PHP_VERSION_ID >= 50600) {
  18786. $perms = fileperms($filepath);
  18787. $zip->setExternalAttributesName($localname, ZipArchive::OPSYS_UNIX, $perms << 16);
  18788. }
  18789. }
  18790. if ($zip->close()) {
  18791. return $target;
  18792. }
  18793. }
  18794. $message = sprintf(
  18795. "Could not create archive '%s' from '%s': %s",
  18796. $target,
  18797. $sources,
  18798. $zip->getStatusString()
  18799. );
  18800. throw new \RuntimeException($message);
  18801. }
  18802. public function supports($format, $sourceType)
  18803. {
  18804. return isset(static::$formats[$format]) && $this->compressionAvailable();
  18805. }
  18806. private function compressionAvailable()
  18807. {
  18808. return class_exists('ZipArchive');
  18809. }
  18810. }
  18811. <?php
  18812. namespace Composer\Package;
  18813. use Composer\Repository\RepositoryInterface;
  18814. use Composer\Repository\PlatformRepository;
  18815. abstract class BasePackage implements PackageInterface
  18816. {
  18817. public static $supportedLinkTypes = array(
  18818. 'require' => array('description' => 'requires', 'method' => Link::TYPE_REQUIRE),
  18819. 'conflict' => array('description' => 'conflicts', 'method' => Link::TYPE_CONFLICT),
  18820. 'provide' => array('description' => 'provides', 'method' => Link::TYPE_PROVIDE),
  18821. 'replace' => array('description' => 'replaces', 'method' => Link::TYPE_REPLACE),
  18822. 'require-dev' => array('description' => 'requires (for development)', 'method' => Link::TYPE_DEV_REQUIRE),
  18823. );
  18824. const STABILITY_STABLE = 0;
  18825. const STABILITY_RC = 5;
  18826. const STABILITY_BETA = 10;
  18827. const STABILITY_ALPHA = 15;
  18828. const STABILITY_DEV = 20;
  18829. public static $stabilities = array(
  18830. 'stable' => self::STABILITY_STABLE,
  18831. 'RC' => self::STABILITY_RC,
  18832. 'beta' => self::STABILITY_BETA,
  18833. 'alpha' => self::STABILITY_ALPHA,
  18834. 'dev' => self::STABILITY_DEV,
  18835. );
  18836. public $id;
  18837. protected $name;
  18838. protected $prettyName;
  18839. protected $repository;
  18840. protected $transportOptions = array();
  18841. public function __construct($name)
  18842. {
  18843. $this->prettyName = $name;
  18844. $this->name = strtolower($name);
  18845. $this->id = -1;
  18846. }
  18847. public function getName()
  18848. {
  18849. return $this->name;
  18850. }
  18851. public function getPrettyName()
  18852. {
  18853. return $this->prettyName;
  18854. }
  18855. public function getNames($provides = true)
  18856. {
  18857. $names = array(
  18858. $this->getName() => true,
  18859. );
  18860. if ($provides) {
  18861. foreach ($this->getProvides() as $link) {
  18862. $names[$link->getTarget()] = true;
  18863. }
  18864. }
  18865. foreach ($this->getReplaces() as $link) {
  18866. $names[$link->getTarget()] = true;
  18867. }
  18868. return array_keys($names);
  18869. }
  18870. public function setId($id)
  18871. {
  18872. $this->id = $id;
  18873. }
  18874. public function getId()
  18875. {
  18876. return $this->id;
  18877. }
  18878. public function setRepository(RepositoryInterface $repository)
  18879. {
  18880. if ($this->repository && $repository !== $this->repository) {
  18881. throw new \LogicException('A package can only be added to one repository');
  18882. }
  18883. $this->repository = $repository;
  18884. }
  18885. public function getRepository()
  18886. {
  18887. return $this->repository;
  18888. }
  18889. public function getTransportOptions()
  18890. {
  18891. return $this->transportOptions;
  18892. }
  18893. public function setTransportOptions(array $options)
  18894. {
  18895. $this->transportOptions = $options;
  18896. }
  18897. public function isPlatform()
  18898. {
  18899. return $this->getRepository() instanceof PlatformRepository;
  18900. }
  18901. public function getUniqueName()
  18902. {
  18903. return $this->getName().'-'.$this->getVersion();
  18904. }
  18905. public function equals(PackageInterface $package)
  18906. {
  18907. $self = $this;
  18908. if ($this instanceof AliasPackage) {
  18909. $self = $this->getAliasOf();
  18910. }
  18911. if ($package instanceof AliasPackage) {
  18912. $package = $package->getAliasOf();
  18913. }
  18914. return $package === $self;
  18915. }
  18916. public function __toString()
  18917. {
  18918. return $this->getUniqueName();
  18919. }
  18920. public function getPrettyString()
  18921. {
  18922. return $this->getPrettyName().' '.$this->getPrettyVersion();
  18923. }
  18924. public function getFullPrettyVersion($truncate = true, $displayMode = PackageInterface::DISPLAY_SOURCE_REF_IF_DEV)
  18925. {
  18926. if ($displayMode === PackageInterface::DISPLAY_SOURCE_REF_IF_DEV &&
  18927. (!$this->isDev() || !\in_array($this->getSourceType(), array('hg', 'git')))
  18928. ) {
  18929. return $this->getPrettyVersion();
  18930. }
  18931. switch ($displayMode) {
  18932. case PackageInterface::DISPLAY_SOURCE_REF_IF_DEV:
  18933. case PackageInterface::DISPLAY_SOURCE_REF:
  18934. $reference = $this->getSourceReference();
  18935. break;
  18936. case PackageInterface::DISPLAY_DIST_REF:
  18937. $reference = $this->getDistReference();
  18938. break;
  18939. default:
  18940. throw new \UnexpectedValueException('Display mode '.$displayMode.' is not supported');
  18941. }
  18942. if ($truncate && \strlen($reference) === 40 && $this->getSourceType() !== 'svn') {
  18943. return $this->getPrettyVersion() . ' ' . substr($reference, 0, 7);
  18944. }
  18945. return $this->getPrettyVersion() . ' ' . $reference;
  18946. }
  18947. public function getStabilityPriority()
  18948. {
  18949. return self::$stabilities[$this->getStability()];
  18950. }
  18951. public function __clone()
  18952. {
  18953. $this->repository = null;
  18954. $this->id = -1;
  18955. }
  18956. public static function packageNameToRegexp($allowPattern, $wrap = '{^%s$}i')
  18957. {
  18958. $cleanedAllowPattern = str_replace('\\*', '.*', preg_quote($allowPattern));
  18959. return sprintf($wrap, $cleanedAllowPattern);
  18960. }
  18961. }
  18962. <?php
  18963. namespace Composer\Package\Comparer;
  18964. class Comparer
  18965. {
  18966. private $source;
  18967. private $update;
  18968. private $changed;
  18969. public function setSource($source)
  18970. {
  18971. $this->source = $source;
  18972. }
  18973. public function setUpdate($update)
  18974. {
  18975. $this->update = $update;
  18976. }
  18977. public function getChanged($toString = false, $explicated = false)
  18978. {
  18979. $changed = $this->changed;
  18980. if (!count($changed)) {
  18981. return false;
  18982. }
  18983. if ($explicated) {
  18984. foreach ($changed as $sectionKey => $itemSection) {
  18985. foreach ($itemSection as $itemKey => $item) {
  18986. $changed[$sectionKey][$itemKey] = $item.' ('.$sectionKey.')';
  18987. }
  18988. }
  18989. }
  18990. if ($toString) {
  18991. foreach ($changed as $sectionKey => $itemSection) {
  18992. foreach ($itemSection as $itemKey => $item) {
  18993. $changed['string'][] = $item."\r\n";
  18994. }
  18995. }
  18996. $changed = implode("\r\n", $changed['string']);
  18997. }
  18998. return $changed;
  18999. }
  19000. public function doCompare()
  19001. {
  19002. $source = array();
  19003. $destination = array();
  19004. $this->changed = array();
  19005. $currentDirectory = getcwd();
  19006. chdir($this->source);
  19007. $source = $this->doTree('.', $source);
  19008. if (!is_array($source)) {
  19009. return;
  19010. }
  19011. chdir($currentDirectory);
  19012. chdir($this->update);
  19013. $destination = $this->doTree('.', $destination);
  19014. if (!is_array($destination)) {
  19015. exit;
  19016. }
  19017. chdir($currentDirectory);
  19018. foreach ($source as $dir => $value) {
  19019. foreach ($value as $file => $hash) {
  19020. if (isset($destination[$dir][$file])) {
  19021. if ($hash !== $destination[$dir][$file]) {
  19022. $this->changed['changed'][] = $dir.'/'.$file;
  19023. }
  19024. } else {
  19025. $this->changed['removed'][] = $dir.'/'.$file;
  19026. }
  19027. }
  19028. }
  19029. foreach ($destination as $dir => $value) {
  19030. foreach ($value as $file => $hash) {
  19031. if (!isset($source[$dir][$file])) {
  19032. $this->changed['added'][] = $dir.'/'.$file;
  19033. }
  19034. }
  19035. }
  19036. }
  19037. private function doTree($dir, &$array)
  19038. {
  19039. if ($dh = opendir($dir)) {
  19040. while ($file = readdir($dh)) {
  19041. if ($file !== '.' && $file !== '..') {
  19042. if (is_link($dir.'/'.$file)) {
  19043. $array[$dir][$file] = readlink($dir.'/'.$file);
  19044. } elseif (is_dir($dir.'/'.$file)) {
  19045. if (!count($array)) {
  19046. $array[0] = 'Temp';
  19047. }
  19048. if (!$this->doTree($dir.'/'.$file, $array)) {
  19049. return false;
  19050. }
  19051. } elseif (is_file($dir.'/'.$file) && filesize($dir.'/'.$file)) {
  19052. set_time_limit(30);
  19053. $array[$dir][$file] = md5_file($dir.'/'.$file);
  19054. }
  19055. }
  19056. }
  19057. if (count($array) > 1 && isset($array['0'])) {
  19058. unset($array['0']);
  19059. }
  19060. return $array;
  19061. }
  19062. return false;
  19063. }
  19064. }
  19065. <?php
  19066. namespace Composer\Package;
  19067. class CompletePackage extends Package implements CompletePackageInterface
  19068. {
  19069. protected $repositories;
  19070. protected $license = array();
  19071. protected $keywords;
  19072. protected $authors;
  19073. protected $description;
  19074. protected $homepage;
  19075. protected $scripts = array();
  19076. protected $support = array();
  19077. protected $funding = array();
  19078. protected $abandoned = false;
  19079. public function setScripts(array $scripts)
  19080. {
  19081. $this->scripts = $scripts;
  19082. }
  19083. public function getScripts()
  19084. {
  19085. return $this->scripts;
  19086. }
  19087. public function setRepositories($repositories)
  19088. {
  19089. $this->repositories = $repositories;
  19090. }
  19091. public function getRepositories()
  19092. {
  19093. return $this->repositories;
  19094. }
  19095. public function setLicense(array $license)
  19096. {
  19097. $this->license = $license;
  19098. }
  19099. public function getLicense()
  19100. {
  19101. return $this->license;
  19102. }
  19103. public function setKeywords(array $keywords)
  19104. {
  19105. $this->keywords = $keywords;
  19106. }
  19107. public function getKeywords()
  19108. {
  19109. return $this->keywords;
  19110. }
  19111. public function setAuthors(array $authors)
  19112. {
  19113. $this->authors = $authors;
  19114. }
  19115. public function getAuthors()
  19116. {
  19117. return $this->authors;
  19118. }
  19119. public function setDescription($description)
  19120. {
  19121. $this->description = $description;
  19122. }
  19123. public function getDescription()
  19124. {
  19125. return $this->description;
  19126. }
  19127. public function setHomepage($homepage)
  19128. {
  19129. $this->homepage = $homepage;
  19130. }
  19131. public function getHomepage()
  19132. {
  19133. return $this->homepage;
  19134. }
  19135. public function setSupport(array $support)
  19136. {
  19137. $this->support = $support;
  19138. }
  19139. public function getSupport()
  19140. {
  19141. return $this->support;
  19142. }
  19143. public function setFunding(array $funding)
  19144. {
  19145. $this->funding = $funding;
  19146. }
  19147. public function getFunding()
  19148. {
  19149. return $this->funding;
  19150. }
  19151. public function isAbandoned()
  19152. {
  19153. return (bool) $this->abandoned;
  19154. }
  19155. public function setAbandoned($abandoned)
  19156. {
  19157. $this->abandoned = $abandoned;
  19158. }
  19159. public function getReplacementPackage()
  19160. {
  19161. return \is_string($this->abandoned) ? $this->abandoned : null;
  19162. }
  19163. }
  19164. <?php
  19165. namespace Composer\Package;
  19166. interface CompletePackageInterface extends PackageInterface
  19167. {
  19168. public function getScripts();
  19169. public function getRepositories();
  19170. public function getLicense();
  19171. public function getKeywords();
  19172. public function getDescription();
  19173. public function getHomepage();
  19174. public function getAuthors();
  19175. public function getSupport();
  19176. public function getFunding();
  19177. public function isAbandoned();
  19178. public function getReplacementPackage();
  19179. }
  19180. <?php
  19181. namespace Composer\Package\Dumper;
  19182. use Composer\Package\BasePackage;
  19183. use Composer\Package\PackageInterface;
  19184. use Composer\Package\CompletePackageInterface;
  19185. use Composer\Package\RootPackageInterface;
  19186. class ArrayDumper
  19187. {
  19188. public function dump(PackageInterface $package)
  19189. {
  19190. $keys = array(
  19191. 'binaries' => 'bin',
  19192. 'type',
  19193. 'extra',
  19194. 'installationSource' => 'installation-source',
  19195. 'autoload',
  19196. 'devAutoload' => 'autoload-dev',
  19197. 'notificationUrl' => 'notification-url',
  19198. 'includePaths' => 'include-path',
  19199. );
  19200. $data = array();
  19201. $data['name'] = $package->getPrettyName();
  19202. $data['version'] = $package->getPrettyVersion();
  19203. $data['version_normalized'] = $package->getVersion();
  19204. if ($package->getTargetDir()) {
  19205. $data['target-dir'] = $package->getTargetDir();
  19206. }
  19207. if ($package->getSourceType()) {
  19208. $data['source']['type'] = $package->getSourceType();
  19209. $data['source']['url'] = $package->getSourceUrl();
  19210. if (null !== ($value = $package->getSourceReference())) {
  19211. $data['source']['reference'] = $value;
  19212. }
  19213. if ($mirrors = $package->getSourceMirrors()) {
  19214. $data['source']['mirrors'] = $mirrors;
  19215. }
  19216. }
  19217. if ($package->getDistType()) {
  19218. $data['dist']['type'] = $package->getDistType();
  19219. $data['dist']['url'] = $package->getDistUrl();
  19220. if (null !== ($value = $package->getDistReference())) {
  19221. $data['dist']['reference'] = $value;
  19222. }
  19223. if (null !== ($value = $package->getDistSha1Checksum())) {
  19224. $data['dist']['shasum'] = $value;
  19225. }
  19226. if ($mirrors = $package->getDistMirrors()) {
  19227. $data['dist']['mirrors'] = $mirrors;
  19228. }
  19229. }
  19230. if ($package->getArchiveName()) {
  19231. $data['archive']['name'] = $package->getArchiveName();
  19232. }
  19233. if ($package->getArchiveExcludes()) {
  19234. $data['archive']['exclude'] = $package->getArchiveExcludes();
  19235. }
  19236. foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
  19237. if ($links = $package->{'get'.ucfirst($opts['method'])}()) {
  19238. foreach ($links as $link) {
  19239. $data[$type][$link->getTarget()] = $link->getPrettyConstraint();
  19240. }
  19241. ksort($data[$type]);
  19242. }
  19243. }
  19244. if ($packages = $package->getSuggests()) {
  19245. ksort($packages);
  19246. $data['suggest'] = $packages;
  19247. }
  19248. if ($package->getReleaseDate()) {
  19249. $data['time'] = $package->getReleaseDate()->format(DATE_RFC3339);
  19250. }
  19251. if ($package->isDefaultBranch()) {
  19252. $data['default-branch'] = true;
  19253. }
  19254. $data = $this->dumpValues($package, $keys, $data);
  19255. if ($package instanceof CompletePackageInterface) {
  19256. $keys = array(
  19257. 'scripts',
  19258. 'license',
  19259. 'authors',
  19260. 'description',
  19261. 'homepage',
  19262. 'keywords',
  19263. 'repositories',
  19264. 'support',
  19265. 'funding',
  19266. );
  19267. $data = $this->dumpValues($package, $keys, $data);
  19268. if (isset($data['keywords']) && \is_array($data['keywords'])) {
  19269. sort($data['keywords']);
  19270. }
  19271. if ($package->isAbandoned()) {
  19272. $data['abandoned'] = $package->getReplacementPackage() ?: true;
  19273. }
  19274. }
  19275. if ($package instanceof RootPackageInterface) {
  19276. $minimumStability = $package->getMinimumStability();
  19277. if ($minimumStability) {
  19278. $data['minimum-stability'] = $minimumStability;
  19279. }
  19280. }
  19281. if (\count($package->getTransportOptions()) > 0) {
  19282. $data['transport-options'] = $package->getTransportOptions();
  19283. }
  19284. return $data;
  19285. }
  19286. private function dumpValues(PackageInterface $package, array $keys, array $data)
  19287. {
  19288. foreach ($keys as $method => $key) {
  19289. if (is_numeric($method)) {
  19290. $method = $key;
  19291. }
  19292. $getter = 'get'.ucfirst($method);
  19293. $value = $package->$getter();
  19294. if (null !== $value && !(\is_array($value) && 0 === \count($value))) {
  19295. $data[$key] = $value;
  19296. }
  19297. }
  19298. return $data;
  19299. }
  19300. }
  19301. <?php
  19302. namespace Composer\Package;
  19303. use Composer\Semver\Constraint\ConstraintInterface;
  19304. class Link
  19305. {
  19306. const TYPE_REQUIRE = 'requires';
  19307. const TYPE_DEV_REQUIRE = 'devRequires';
  19308. const TYPE_PROVIDE = 'provides';
  19309. const TYPE_CONFLICT = 'conflicts';
  19310. const TYPE_REPLACE = 'replaces';
  19311. public static $TYPES = array(
  19312. self::TYPE_REQUIRE,
  19313. self::TYPE_DEV_REQUIRE,
  19314. self::TYPE_PROVIDE,
  19315. self::TYPE_CONFLICT,
  19316. self::TYPE_REPLACE,
  19317. );
  19318. protected $source;
  19319. protected $target;
  19320. protected $constraint;
  19321. protected $description;
  19322. protected $prettyConstraint;
  19323. public function __construct(
  19324. $source,
  19325. $target,
  19326. ConstraintInterface $constraint,
  19327. $description = 'relates to',
  19328. $prettyConstraint = null
  19329. ) {
  19330. $this->source = strtolower($source);
  19331. $this->target = strtolower($target);
  19332. $this->constraint = $constraint;
  19333. $this->description = $description;
  19334. $this->prettyConstraint = $prettyConstraint;
  19335. }
  19336. public function getDescription()
  19337. {
  19338. return $this->description;
  19339. }
  19340. public function getSource()
  19341. {
  19342. return $this->source;
  19343. }
  19344. public function getTarget()
  19345. {
  19346. return $this->target;
  19347. }
  19348. public function getConstraint()
  19349. {
  19350. return $this->constraint;
  19351. }
  19352. public function getPrettyConstraint()
  19353. {
  19354. if (null === $this->prettyConstraint) {
  19355. throw new \UnexpectedValueException(sprintf('Link %s has been misconfigured and had no prettyConstraint given.', $this));
  19356. }
  19357. return $this->prettyConstraint;
  19358. }
  19359. public function __toString()
  19360. {
  19361. return $this->source.' '.$this->description.' '.$this->target.' ('.$this->constraint.')';
  19362. }
  19363. public function getPrettyString(PackageInterface $sourcePackage)
  19364. {
  19365. return $sourcePackage->getPrettyString().' '.$this->description.' '.$this->target.($this->constraint ? ' '.$this->constraint->getPrettyString() : '');
  19366. }
  19367. }
  19368. <?php
  19369. namespace Composer\Package\Loader;
  19370. use Composer\Package;
  19371. use Composer\Package\AliasPackage;
  19372. use Composer\Package\Link;
  19373. use Composer\Package\RootAliasPackage;
  19374. use Composer\Package\RootPackageInterface;
  19375. use Composer\Package\Version\VersionParser;
  19376. class ArrayLoader implements LoaderInterface
  19377. {
  19378. protected $versionParser;
  19379. protected $loadOptions;
  19380. public function __construct(VersionParser $parser = null, $loadOptions = false)
  19381. {
  19382. if (!$parser) {
  19383. $parser = new VersionParser;
  19384. }
  19385. $this->versionParser = $parser;
  19386. $this->loadOptions = $loadOptions;
  19387. }
  19388. public function load(array $config, $class = 'Composer\Package\CompletePackage')
  19389. {
  19390. $package = $this->createObject($config, $class);
  19391. foreach (Package\BasePackage::$supportedLinkTypes as $type => $opts) {
  19392. if (isset($config[$type])) {
  19393. $method = 'set'.ucfirst($opts['method']);
  19394. $package->{$method}(
  19395. $this->parseLinks(
  19396. $package->getName(),
  19397. $package->getPrettyVersion(),
  19398. $opts['description'],
  19399. $config[$type]
  19400. )
  19401. );
  19402. }
  19403. }
  19404. $package = $this->configureObject($package, $config);
  19405. return $package;
  19406. }
  19407. public function loadPackages(array $versions, $class)
  19408. {
  19409. $packages = array();
  19410. $linkCache = array();
  19411. foreach ($versions as $version) {
  19412. $package = $this->createObject($version, $class);
  19413. $this->configureCachedLinks($linkCache, $package, $version);
  19414. $package = $this->configureObject($package, $version);
  19415. $packages[] = $package;
  19416. }
  19417. return $packages;
  19418. }
  19419. private function createObject(array $config, $class)
  19420. {
  19421. if (!isset($config['name'])) {
  19422. throw new \UnexpectedValueException('Unknown package has no name defined ('.json_encode($config).').');
  19423. }
  19424. if (!isset($config['version'])) {
  19425. throw new \UnexpectedValueException('Package '.$config['name'].' has no version defined.');
  19426. }
  19427. if (isset($config['version_normalized'])) {
  19428. $version = $config['version_normalized'];
  19429. if ($version === VersionParser::DEFAULT_BRANCH_ALIAS) {
  19430. $version = $this->versionParser->normalize($config['version']);
  19431. }
  19432. } else {
  19433. $version = $this->versionParser->normalize($config['version']);
  19434. }
  19435. return new $class($config['name'], $version, $config['version']);
  19436. }
  19437. private function configureObject($package, array $config)
  19438. {
  19439. $package->setType(isset($config['type']) ? strtolower($config['type']) : 'library');
  19440. if (isset($config['target-dir'])) {
  19441. $package->setTargetDir($config['target-dir']);
  19442. }
  19443. if (isset($config['extra']) && \is_array($config['extra'])) {
  19444. $package->setExtra($config['extra']);
  19445. }
  19446. if (isset($config['bin'])) {
  19447. foreach ((array) $config['bin'] as $key => $bin) {
  19448. $config['bin'][$key] = ltrim($bin, '/');
  19449. }
  19450. $package->setBinaries((array) $config['bin']);
  19451. }
  19452. if (isset($config['installation-source'])) {
  19453. $package->setInstallationSource($config['installation-source']);
  19454. }
  19455. if (isset($config['default-branch']) && $config['default-branch'] === true) {
  19456. $package->setIsDefaultBranch(true);
  19457. }
  19458. if (isset($config['source'])) {
  19459. if (!isset($config['source']['type'], $config['source']['url'], $config['source']['reference'])) {
  19460. throw new \UnexpectedValueException(sprintf(
  19461. "Package %s's source key should be specified as {\"type\": ..., \"url\": ..., \"reference\": ...},\n%s given.",
  19462. $config['name'],
  19463. json_encode($config['source'])
  19464. ));
  19465. }
  19466. $package->setSourceType($config['source']['type']);
  19467. $package->setSourceUrl($config['source']['url']);
  19468. $package->setSourceReference(isset($config['source']['reference']) ? $config['source']['reference'] : null);
  19469. if (isset($config['source']['mirrors'])) {
  19470. $package->setSourceMirrors($config['source']['mirrors']);
  19471. }
  19472. }
  19473. if (isset($config['dist'])) {
  19474. if (!isset($config['dist']['type'], $config['dist']['url'])) {
  19475. throw new \UnexpectedValueException(sprintf(
  19476. "Package %s's dist key should be specified as ".
  19477. "{\"type\": ..., \"url\": ..., \"reference\": ..., \"shasum\": ...},\n%s given.",
  19478. $config['name'],
  19479. json_encode($config['dist'])
  19480. ));
  19481. }
  19482. $package->setDistType($config['dist']['type']);
  19483. $package->setDistUrl($config['dist']['url']);
  19484. $package->setDistReference(isset($config['dist']['reference']) ? $config['dist']['reference'] : null);
  19485. $package->setDistSha1Checksum(isset($config['dist']['shasum']) ? $config['dist']['shasum'] : null);
  19486. if (isset($config['dist']['mirrors'])) {
  19487. $package->setDistMirrors($config['dist']['mirrors']);
  19488. }
  19489. }
  19490. if (isset($config['suggest']) && \is_array($config['suggest'])) {
  19491. foreach ($config['suggest'] as $target => $reason) {
  19492. if ('self.version' === trim($reason)) {
  19493. $config['suggest'][$target] = $package->getPrettyVersion();
  19494. }
  19495. }
  19496. $package->setSuggests($config['suggest']);
  19497. }
  19498. if (isset($config['autoload'])) {
  19499. $package->setAutoload($config['autoload']);
  19500. }
  19501. if (isset($config['autoload-dev'])) {
  19502. $package->setDevAutoload($config['autoload-dev']);
  19503. }
  19504. if (isset($config['include-path'])) {
  19505. $package->setIncludePaths($config['include-path']);
  19506. }
  19507. if (!empty($config['time'])) {
  19508. $time = preg_match('/^\d++$/D', $config['time']) ? '@'.$config['time'] : $config['time'];
  19509. try {
  19510. $date = new \DateTime($time, new \DateTimeZone('UTC'));
  19511. $package->setReleaseDate($date);
  19512. } catch (\Exception $e) {
  19513. }
  19514. }
  19515. if (!empty($config['notification-url'])) {
  19516. $package->setNotificationUrl($config['notification-url']);
  19517. }
  19518. if (!empty($config['archive']['name'])) {
  19519. $package->setArchiveName($config['archive']['name']);
  19520. }
  19521. if (!empty($config['archive']['exclude'])) {
  19522. $package->setArchiveExcludes($config['archive']['exclude']);
  19523. }
  19524. if ($package instanceof Package\CompletePackageInterface) {
  19525. if (isset($config['scripts']) && \is_array($config['scripts'])) {
  19526. foreach ($config['scripts'] as $event => $listeners) {
  19527. $config['scripts'][$event] = (array) $listeners;
  19528. }
  19529. if (isset($config['scripts']['composer'])) {
  19530. trigger_error('The `composer` script name is reserved for internal use, please avoid defining it', E_USER_DEPRECATED);
  19531. }
  19532. $package->setScripts($config['scripts']);
  19533. }
  19534. if (!empty($config['description']) && \is_string($config['description'])) {
  19535. $package->setDescription($config['description']);
  19536. }
  19537. if (!empty($config['homepage']) && \is_string($config['homepage'])) {
  19538. $package->setHomepage($config['homepage']);
  19539. }
  19540. if (!empty($config['keywords']) && \is_array($config['keywords'])) {
  19541. $package->setKeywords($config['keywords']);
  19542. }
  19543. if (!empty($config['license'])) {
  19544. $package->setLicense(\is_array($config['license']) ? $config['license'] : array($config['license']));
  19545. }
  19546. if (!empty($config['authors']) && \is_array($config['authors'])) {
  19547. $package->setAuthors($config['authors']);
  19548. }
  19549. if (isset($config['support'])) {
  19550. $package->setSupport($config['support']);
  19551. }
  19552. if (!empty($config['funding']) && \is_array($config['funding'])) {
  19553. $package->setFunding($config['funding']);
  19554. }
  19555. if (isset($config['abandoned'])) {
  19556. $package->setAbandoned($config['abandoned']);
  19557. }
  19558. }
  19559. if ($this->loadOptions && isset($config['transport-options'])) {
  19560. $package->setTransportOptions($config['transport-options']);
  19561. }
  19562. if ($aliasNormalized = $this->getBranchAlias($config)) {
  19563. $prettyAlias = preg_replace('{(\.9{7})+}', '.x', $aliasNormalized);
  19564. if ($package instanceof RootPackageInterface) {
  19565. return new RootAliasPackage($package, $aliasNormalized, $prettyAlias);
  19566. }
  19567. return new AliasPackage($package, $aliasNormalized, $prettyAlias);
  19568. }
  19569. return $package;
  19570. }
  19571. private function configureCachedLinks(&$linkCache, $package, array $config)
  19572. {
  19573. $name = $package->getName();
  19574. $prettyVersion = $package->getPrettyVersion();
  19575. foreach (Package\BasePackage::$supportedLinkTypes as $type => $opts) {
  19576. if (isset($config[$type])) {
  19577. $method = 'set'.ucfirst($opts['method']);
  19578. $links = array();
  19579. foreach ($config[$type] as $prettyTarget => $constraint) {
  19580. $target = strtolower($prettyTarget);
  19581. if ($constraint === 'self.version') {
  19582. $links[$target] = $this->createLink($name, $prettyVersion, $opts['description'], $target, $constraint);
  19583. } else {
  19584. if (!isset($linkCache[$name][$type][$target][$constraint])) {
  19585. $linkCache[$name][$type][$target][$constraint] = array($target, $this->createLink($name, $prettyVersion, $opts['description'], $target, $constraint));
  19586. }
  19587. list($target, $link) = $linkCache[$name][$type][$target][$constraint];
  19588. $links[$target] = $link;
  19589. }
  19590. }
  19591. $package->{$method}($links);
  19592. }
  19593. }
  19594. }
  19595. public function parseLinks($source, $sourceVersion, $description, $links)
  19596. {
  19597. $res = array();
  19598. foreach ($links as $target => $constraint) {
  19599. $res[strtolower($target)] = $this->createLink($source, $sourceVersion, $description, $target, $constraint);
  19600. }
  19601. return $res;
  19602. }
  19603. private function createLink($source, $sourceVersion, $description, $target, $prettyConstraint)
  19604. {
  19605. if (!\is_string($prettyConstraint)) {
  19606. throw new \UnexpectedValueException('Link constraint in '.$source.' '.$description.' > '.$target.' should be a string, got '.\gettype($prettyConstraint) . ' (' . var_export($prettyConstraint, true) . ')');
  19607. }
  19608. if ('self.version' === $prettyConstraint) {
  19609. $parsedConstraint = $this->versionParser->parseConstraints($sourceVersion);
  19610. } else {
  19611. $parsedConstraint = $this->versionParser->parseConstraints($prettyConstraint);
  19612. }
  19613. return new Link($source, $target, $parsedConstraint, $description, $prettyConstraint);
  19614. }
  19615. public function getBranchAlias(array $config)
  19616. {
  19617. if (strpos($config['version'], 'dev-') !== 0 && '-dev' !== substr($config['version'], -4)) {
  19618. return;
  19619. }
  19620. if (isset($config['extra']['branch-alias']) && \is_array($config['extra']['branch-alias'])) {
  19621. foreach ($config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {
  19622. if ('-dev' !== substr($targetBranch, -4)) {
  19623. continue;
  19624. }
  19625. $validatedTargetBranch = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4));
  19626. if ('-dev' !== substr($validatedTargetBranch, -4)) {
  19627. continue;
  19628. }
  19629. if (strtolower($config['version']) !== strtolower($sourceBranch)) {
  19630. continue;
  19631. }
  19632. if (($sourcePrefix = $this->versionParser->parseNumericAliasPrefix($sourceBranch))
  19633. && ($targetPrefix = $this->versionParser->parseNumericAliasPrefix($targetBranch))
  19634. && (stripos($targetPrefix, $sourcePrefix) !== 0)
  19635. ) {
  19636. continue;
  19637. }
  19638. return $validatedTargetBranch;
  19639. }
  19640. }
  19641. if (isset($config['default-branch']) && $config['default-branch'] === true) {
  19642. return VersionParser::DEFAULT_BRANCH_ALIAS;
  19643. }
  19644. }
  19645. }
  19646. <?php
  19647. namespace Composer\Package\Loader;
  19648. class InvalidPackageException extends \Exception
  19649. {
  19650. private $errors;
  19651. private $warnings;
  19652. private $data;
  19653. public function __construct(array $errors, array $warnings, array $data)
  19654. {
  19655. $this->errors = $errors;
  19656. $this->warnings = $warnings;
  19657. $this->data = $data;
  19658. parent::__construct("Invalid package information: \n".implode("\n", array_merge($errors, $warnings)));
  19659. }
  19660. public function getData()
  19661. {
  19662. return $this->data;
  19663. }
  19664. public function getErrors()
  19665. {
  19666. return $this->errors;
  19667. }
  19668. public function getWarnings()
  19669. {
  19670. return $this->warnings;
  19671. }
  19672. }
  19673. <?php
  19674. namespace Composer\Package\Loader;
  19675. use Composer\Json\JsonFile;
  19676. class JsonLoader
  19677. {
  19678. private $loader;
  19679. public function __construct(LoaderInterface $loader)
  19680. {
  19681. $this->loader = $loader;
  19682. }
  19683. public function load($json)
  19684. {
  19685. if ($json instanceof JsonFile) {
  19686. $config = $json->read();
  19687. } elseif (file_exists($json)) {
  19688. $config = JsonFile::parseJson(file_get_contents($json), $json);
  19689. } elseif (is_string($json)) {
  19690. $config = JsonFile::parseJson($json);
  19691. } else {
  19692. throw new \InvalidArgumentException(sprintf(
  19693. "JsonLoader: Unknown \$json parameter %s. Please report at https://github.com/composer/composer/issues/new.",
  19694. gettype($json)
  19695. ));
  19696. }
  19697. return $this->loader->load($config);
  19698. }
  19699. }
  19700. <?php
  19701. namespace Composer\Package\Loader;
  19702. interface LoaderInterface
  19703. {
  19704. public function load(array $package, $class = 'Composer\Package\CompletePackage');
  19705. }
  19706. <?php
  19707. namespace Composer\Package\Loader;
  19708. use Composer\Package\BasePackage;
  19709. use Composer\Package\AliasPackage;
  19710. use Composer\Config;
  19711. use Composer\IO\IOInterface;
  19712. use Composer\Package\RootPackageInterface;
  19713. use Composer\Repository\RepositoryFactory;
  19714. use Composer\Package\Version\VersionGuesser;
  19715. use Composer\Package\Version\VersionParser;
  19716. use Composer\Repository\RepositoryManager;
  19717. use Composer\Util\ProcessExecutor;
  19718. class RootPackageLoader extends ArrayLoader
  19719. {
  19720. private $manager;
  19721. private $config;
  19722. private $versionGuesser;
  19723. public function __construct(RepositoryManager $manager, Config $config, VersionParser $parser = null, VersionGuesser $versionGuesser = null, IOInterface $io = null)
  19724. {
  19725. parent::__construct($parser);
  19726. $this->manager = $manager;
  19727. $this->config = $config;
  19728. $this->versionGuesser = $versionGuesser ?: new VersionGuesser($config, new ProcessExecutor($io), $this->versionParser);
  19729. }
  19730. public function load(array $config, $class = 'Composer\Package\RootPackage', $cwd = null)
  19731. {
  19732. if (!isset($config['name'])) {
  19733. $config['name'] = '__root__';
  19734. } elseif ($err = ValidatingArrayLoader::hasPackageNamingError($config['name'])) {
  19735. throw new \RuntimeException('Your package name '.$err);
  19736. }
  19737. $autoVersioned = false;
  19738. if (!isset($config['version'])) {
  19739. $commit = null;
  19740. if (isset($config['extra']['branch-version'])) {
  19741. $config['version'] = preg_replace('{(\.x)?(-dev)?$}', '', $config['extra']['branch-version']).'.x-dev';
  19742. } elseif (getenv('COMPOSER_ROOT_VERSION')) {
  19743. $config['version'] = getenv('COMPOSER_ROOT_VERSION');
  19744. } else {
  19745. $versionData = $this->versionGuesser->guessVersion($config, $cwd ?: getcwd());
  19746. if ($versionData) {
  19747. $config['version'] = $versionData['pretty_version'];
  19748. $config['version_normalized'] = $versionData['version'];
  19749. $commit = $versionData['commit'];
  19750. }
  19751. }
  19752. if (!isset($config['version'])) {
  19753. $config['version'] = '1.0.0';
  19754. $autoVersioned = true;
  19755. }
  19756. if ($commit) {
  19757. $config['source'] = array(
  19758. 'type' => '',
  19759. 'url' => '',
  19760. 'reference' => $commit,
  19761. );
  19762. $config['dist'] = array(
  19763. 'type' => '',
  19764. 'url' => '',
  19765. 'reference' => $commit,
  19766. );
  19767. }
  19768. }
  19769. $realPackage = $package = parent::load($config, $class);
  19770. if ($realPackage instanceof AliasPackage) {
  19771. $realPackage = $package->getAliasOf();
  19772. }
  19773. if ($autoVersioned) {
  19774. $realPackage->replaceVersion($realPackage->getVersion(), 'No version set (parsed as 1.0.0)');
  19775. }
  19776. if (isset($config['minimum-stability'])) {
  19777. $realPackage->setMinimumStability(VersionParser::normalizeStability($config['minimum-stability']));
  19778. }
  19779. $aliases = array();
  19780. $stabilityFlags = array();
  19781. $references = array();
  19782. foreach (array('require', 'require-dev') as $linkType) {
  19783. if (isset($config[$linkType])) {
  19784. $linkInfo = BasePackage::$supportedLinkTypes[$linkType];
  19785. $method = 'get'.ucfirst($linkInfo['method']);
  19786. $links = array();
  19787. foreach ($realPackage->$method() as $link) {
  19788. $links[$link->getTarget()] = $link->getConstraint()->getPrettyString();
  19789. }
  19790. $aliases = $this->extractAliases($links, $aliases);
  19791. $stabilityFlags = $this->extractStabilityFlags($links, $stabilityFlags, $realPackage->getMinimumStability());
  19792. $references = $this->extractReferences($links, $references);
  19793. if (isset($links[$config['name']])) {
  19794. throw new \RuntimeException(sprintf('Root package \'%s\' cannot require itself in its composer.json' . PHP_EOL .
  19795. 'Did you accidentally name your root package after an external package?', $config['name']));
  19796. }
  19797. }
  19798. }
  19799. foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
  19800. if (isset($config[$linkType])) {
  19801. foreach ($config[$linkType] as $linkName => $constraint) {
  19802. if ($err = ValidatingArrayLoader::hasPackageNamingError($linkName, true)) {
  19803. throw new \RuntimeException($linkType.'.'.$err);
  19804. }
  19805. }
  19806. }
  19807. }
  19808. $realPackage->setAliases($aliases);
  19809. $realPackage->setStabilityFlags($stabilityFlags);
  19810. $realPackage->setReferences($references);
  19811. if (isset($config['prefer-stable'])) {
  19812. $realPackage->setPreferStable((bool) $config['prefer-stable']);
  19813. }
  19814. if (isset($config['config'])) {
  19815. $realPackage->setConfig($config['config']);
  19816. }
  19817. $repos = RepositoryFactory::defaultRepos(null, $this->config, $this->manager);
  19818. foreach ($repos as $repo) {
  19819. $this->manager->addRepository($repo);
  19820. }
  19821. $realPackage->setRepositories($this->config->getRepositories());
  19822. return $package;
  19823. }
  19824. private function extractAliases(array $requires, array $aliases)
  19825. {
  19826. foreach ($requires as $reqName => $reqVersion) {
  19827. if (preg_match('{^([^,\s#]+)(?:#[^ ]+)? +as +([^,\s]+)$}', $reqVersion, $match)) {
  19828. $aliases[] = array(
  19829. 'package' => strtolower($reqName),
  19830. 'version' => $this->versionParser->normalize($match[1], $reqVersion),
  19831. 'alias' => $match[2],
  19832. 'alias_normalized' => $this->versionParser->normalize($match[2], $reqVersion),
  19833. );
  19834. } elseif (strpos($reqVersion, ' as ') !== false) {
  19835. throw new \UnexpectedValueException('Invalid alias definition in "'.$reqName.'": "'.$reqVersion.'". Aliases should be in the form "exact-version as other-exact-version".');
  19836. }
  19837. }
  19838. return $aliases;
  19839. }
  19840. private function extractStabilityFlags(array $requires, array $stabilityFlags, $minimumStability)
  19841. {
  19842. $stabilities = BasePackage::$stabilities;
  19843. $minimumStability = $stabilities[$minimumStability];
  19844. foreach ($requires as $reqName => $reqVersion) {
  19845. $constraints = array();
  19846. $orSplit = preg_split('{\s*\|\|?\s*}', trim($reqVersion));
  19847. foreach ($orSplit as $orConstraint) {
  19848. $andSplit = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $orConstraint);
  19849. foreach ($andSplit as $andConstraint) {
  19850. $constraints[] = $andConstraint;
  19851. }
  19852. }
  19853. $match = false;
  19854. foreach ($constraints as $constraint) {
  19855. if (preg_match('{^[^@]*?@('.implode('|', array_keys($stabilities)).')$}i', $constraint, $match)) {
  19856. $name = strtolower($reqName);
  19857. $stability = $stabilities[VersionParser::normalizeStability($match[1])];
  19858. if (isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) {
  19859. continue;
  19860. }
  19861. $stabilityFlags[$name] = $stability;
  19862. $match = true;
  19863. }
  19864. }
  19865. if ($match) {
  19866. continue;
  19867. }
  19868. foreach ($constraints as $constraint) {
  19869. $reqVersion = preg_replace('{^([^,\s@]+) as .+$}', '$1', $constraint);
  19870. if (preg_match('{^[^,\s@]+$}', $reqVersion) && 'stable' !== ($stabilityName = VersionParser::parseStability($reqVersion))) {
  19871. $name = strtolower($reqName);
  19872. $stability = $stabilities[$stabilityName];
  19873. if ((isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) || ($minimumStability > $stability)) {
  19874. continue;
  19875. }
  19876. $stabilityFlags[$name] = $stability;
  19877. }
  19878. }
  19879. }
  19880. return $stabilityFlags;
  19881. }
  19882. private function extractReferences(array $requires, array $references)
  19883. {
  19884. foreach ($requires as $reqName => $reqVersion) {
  19885. $reqVersion = preg_replace('{^([^,\s@]+) as .+$}', '$1', $reqVersion);
  19886. if (preg_match('{^[^,\s@]+?#([a-f0-9]+)$}', $reqVersion, $match) && 'dev' === VersionParser::parseStability($reqVersion)) {
  19887. $name = strtolower($reqName);
  19888. $references[$name] = $match[1];
  19889. }
  19890. }
  19891. return $references;
  19892. }
  19893. }
  19894. <?php
  19895. namespace Composer\Package\Loader;
  19896. use Composer\Package\BasePackage;
  19897. use Composer\Semver\Constraint\Constraint;
  19898. use Composer\Package\Version\VersionParser;
  19899. use Composer\Repository\PlatformRepository;
  19900. use Composer\Spdx\SpdxLicenses;
  19901. class ValidatingArrayLoader implements LoaderInterface
  19902. {
  19903. const CHECK_ALL = 3;
  19904. const CHECK_UNBOUND_CONSTRAINTS = 1;
  19905. const CHECK_STRICT_CONSTRAINTS = 2;
  19906. private $loader;
  19907. private $versionParser;
  19908. private $errors;
  19909. private $warnings;
  19910. private $config;
  19911. private $strictName;
  19912. private $flags;
  19913. public function __construct(LoaderInterface $loader, $strictName = true, VersionParser $parser = null, $flags = 0)
  19914. {
  19915. $this->loader = $loader;
  19916. $this->versionParser = $parser ?: new VersionParser();
  19917. $this->strictName = $strictName;
  19918. $this->flags = $flags;
  19919. }
  19920. public function load(array $config, $class = 'Composer\Package\CompletePackage')
  19921. {
  19922. $this->errors = array();
  19923. $this->warnings = array();
  19924. $this->config = $config;
  19925. if ($err = self::hasPackageNamingError($config['name'])) {
  19926. $this->warnings[] = 'Deprecation warning: Your package name '.$err.' Make sure you fix this as Composer 2.0 will error.';
  19927. }
  19928. if ($this->strictName) {
  19929. $this->validateRegex('name', '[A-Za-z0-9][A-Za-z0-9_.-]*/[A-Za-z0-9][A-Za-z0-9_.-]*', true);
  19930. } else {
  19931. $this->validateString('name', true);
  19932. }
  19933. if (!empty($this->config['version'])) {
  19934. try {
  19935. $this->versionParser->normalize($this->config['version']);
  19936. } catch (\Exception $e) {
  19937. $this->errors[] = 'version : invalid value ('.$this->config['version'].'): '.$e->getMessage();
  19938. unset($this->config['version']);
  19939. }
  19940. }
  19941. if (!empty($this->config['config']['platform'])) {
  19942. foreach ((array) $this->config['config']['platform'] as $key => $platform) {
  19943. try {
  19944. $this->versionParser->normalize($platform);
  19945. } catch (\Exception $e) {
  19946. $this->errors[] = 'config.platform.' . $key . ' : invalid value ('.$platform.'): '.$e->getMessage();
  19947. }
  19948. }
  19949. }
  19950. $this->validateRegex('type', '[A-Za-z0-9-]+');
  19951. $this->validateString('target-dir');
  19952. $this->validateArray('extra');
  19953. if (isset($this->config['bin'])) {
  19954. if (is_string($this->config['bin'])) {
  19955. $this->validateString('bin');
  19956. } else {
  19957. $this->validateFlatArray('bin');
  19958. }
  19959. }
  19960. $this->validateArray('scripts');
  19961. $this->validateString('description');
  19962. $this->validateUrl('homepage');
  19963. $this->validateFlatArray('keywords', '[\p{N}\p{L} ._-]+');
  19964. $releaseDate = null;
  19965. $this->validateString('time');
  19966. if (!empty($this->config['time'])) {
  19967. try {
  19968. $releaseDate = new \DateTime($this->config['time'], new \DateTimeZone('UTC'));
  19969. } catch (\Exception $e) {
  19970. $this->errors[] = 'time : invalid value ('.$this->config['time'].'): '.$e->getMessage();
  19971. unset($this->config['time']);
  19972. }
  19973. }
  19974. if (isset($this->config['license']) && (!$releaseDate || $releaseDate->getTimestamp() >= strtotime('-8days'))) {
  19975. if (is_array($this->config['license']) || is_string($this->config['license'])) {
  19976. $licenses = (array) $this->config['license'];
  19977. $licenseValidator = new SpdxLicenses();
  19978. foreach ($licenses as $license) {
  19979. if ('proprietary' === $license) {
  19980. continue;
  19981. }
  19982. $licenseToValidate = str_replace('proprietary', 'MIT', $license);
  19983. if (!$licenseValidator->validate($licenseToValidate)) {
  19984. if ($licenseValidator->validate(trim($licenseToValidate))) {
  19985. $this->warnings[] = sprintf(
  19986. 'License %s must not contain extra spaces, make sure to trim it.',
  19987. json_encode($license)
  19988. );
  19989. } else {
  19990. $this->warnings[] = sprintf(
  19991. 'License %s is not a valid SPDX license identifier, see https://spdx.org/licenses/ if you use an open license.' . PHP_EOL .
  19992. 'If the software is closed-source, you may use "proprietary" as license.',
  19993. json_encode($license)
  19994. );
  19995. }
  19996. }
  19997. }
  19998. }
  19999. }
  20000. if ($this->validateArray('authors') && !empty($this->config['authors'])) {
  20001. foreach ($this->config['authors'] as $key => $author) {
  20002. if (!is_array($author)) {
  20003. $this->errors[] = 'authors.'.$key.' : should be an array, '.gettype($author).' given';
  20004. unset($this->config['authors'][$key]);
  20005. continue;
  20006. }
  20007. foreach (array('homepage', 'email', 'name', 'role') as $authorData) {
  20008. if (isset($author[$authorData]) && !is_string($author[$authorData])) {
  20009. $this->errors[] = 'authors.'.$key.'.'.$authorData.' : invalid value, must be a string';
  20010. unset($this->config['authors'][$key][$authorData]);
  20011. }
  20012. }
  20013. if (isset($author['homepage']) && !$this->filterUrl($author['homepage'])) {
  20014. $this->warnings[] = 'authors.'.$key.'.homepage : invalid value ('.$author['homepage'].'), must be an http/https URL';
  20015. unset($this->config['authors'][$key]['homepage']);
  20016. }
  20017. if (isset($author['email']) && !filter_var($author['email'], FILTER_VALIDATE_EMAIL)) {
  20018. $this->warnings[] = 'authors.'.$key.'.email : invalid value ('.$author['email'].'), must be a valid email address';
  20019. unset($this->config['authors'][$key]['email']);
  20020. }
  20021. if (empty($this->config['authors'][$key])) {
  20022. unset($this->config['authors'][$key]);
  20023. }
  20024. }
  20025. if (empty($this->config['authors'])) {
  20026. unset($this->config['authors']);
  20027. }
  20028. }
  20029. if ($this->validateArray('support') && !empty($this->config['support'])) {
  20030. foreach (array('issues', 'forum', 'wiki', 'source', 'email', 'irc', 'docs', 'rss', 'chat') as $key) {
  20031. if (isset($this->config['support'][$key]) && !is_string($this->config['support'][$key])) {
  20032. $this->errors[] = 'support.'.$key.' : invalid value, must be a string';
  20033. unset($this->config['support'][$key]);
  20034. }
  20035. }
  20036. if (isset($this->config['support']['email']) && !filter_var($this->config['support']['email'], FILTER_VALIDATE_EMAIL)) {
  20037. $this->warnings[] = 'support.email : invalid value ('.$this->config['support']['email'].'), must be a valid email address';
  20038. unset($this->config['support']['email']);
  20039. }
  20040. if (isset($this->config['support']['irc']) && !$this->filterUrl($this->config['support']['irc'], array('irc'))) {
  20041. $this->warnings[] = 'support.irc : invalid value ('.$this->config['support']['irc'].'), must be a irc://<server>/<channel> URL';
  20042. unset($this->config['support']['irc']);
  20043. }
  20044. foreach (array('issues', 'forum', 'wiki', 'source', 'docs', 'chat') as $key) {
  20045. if (isset($this->config['support'][$key]) && !$this->filterUrl($this->config['support'][$key])) {
  20046. $this->warnings[] = 'support.'.$key.' : invalid value ('.$this->config['support'][$key].'), must be an http/https URL';
  20047. unset($this->config['support'][$key]);
  20048. }
  20049. }
  20050. if (empty($this->config['support'])) {
  20051. unset($this->config['support']);
  20052. }
  20053. }
  20054. if ($this->validateArray('funding') && !empty($this->config['funding'])) {
  20055. foreach ($this->config['funding'] as $key => $fundingOption) {
  20056. if (!is_array($fundingOption)) {
  20057. $this->errors[] = 'funding.'.$key.' : should be an array, '.gettype($fundingOption).' given';
  20058. unset($this->config['funding'][$key]);
  20059. continue;
  20060. }
  20061. foreach (array('type', 'url') as $fundingData) {
  20062. if (isset($fundingOption[$fundingData]) && !is_string($fundingOption[$fundingData])) {
  20063. $this->errors[] = 'funding.'.$key.'.'.$fundingData.' : invalid value, must be a string';
  20064. unset($this->config['funding'][$key][$fundingData]);
  20065. }
  20066. }
  20067. if (isset($fundingOption['url']) && !$this->filterUrl($fundingOption['url'])) {
  20068. $this->warnings[] = 'funding.'.$key.'.url : invalid value ('.$fundingOption['url'].'), must be an http/https URL';
  20069. unset($this->config['funding'][$key]['url']);
  20070. }
  20071. if (empty($this->config['funding'][$key])) {
  20072. unset($this->config['funding'][$key]);
  20073. }
  20074. }
  20075. if (empty($this->config['funding'])) {
  20076. unset($this->config['funding']);
  20077. }
  20078. }
  20079. $unboundConstraint = new Constraint('=', '10000000-dev');
  20080. $stableConstraint = new Constraint('=', '1.0.0');
  20081. foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
  20082. if ($this->validateArray($linkType) && isset($this->config[$linkType])) {
  20083. foreach ($this->config[$linkType] as $package => $constraint) {
  20084. if ($err = self::hasPackageNamingError($package, true)) {
  20085. $this->warnings[] = 'Deprecation warning: '.$linkType.'.'.$err.' Make sure you fix this as Composer 2.0 will error.';
  20086. } elseif (!preg_match('{^[A-Za-z0-9_./-]+$}', $package)) {
  20087. $this->warnings[] = $linkType.'.'.$package.' : invalid key, package names must be strings containing only [A-Za-z0-9_./-]';
  20088. }
  20089. if (!is_string($constraint)) {
  20090. $this->errors[] = $linkType.'.'.$package.' : invalid value, must be a string containing a version constraint';
  20091. unset($this->config[$linkType][$package]);
  20092. } elseif ('self.version' !== $constraint) {
  20093. try {
  20094. $linkConstraint = $this->versionParser->parseConstraints($constraint);
  20095. } catch (\Exception $e) {
  20096. $this->errors[] = $linkType.'.'.$package.' : invalid version constraint ('.$e->getMessage().')';
  20097. unset($this->config[$linkType][$package]);
  20098. continue;
  20099. }
  20100. if (
  20101. ($this->flags & self::CHECK_UNBOUND_CONSTRAINTS)
  20102. && 'require' === $linkType
  20103. && $linkConstraint->matches($unboundConstraint)
  20104. && !PlatformRepository::isPlatformPackage($package)
  20105. ) {
  20106. $this->warnings[] = $linkType.'.'.$package.' : unbound version constraints ('.$constraint.') should be avoided';
  20107. } elseif (
  20108. ($this->flags & self::CHECK_STRICT_CONSTRAINTS)
  20109. && 'require' === $linkType
  20110. && strpos($linkConstraint, '=') === 0
  20111. && $stableConstraint->versionCompare($stableConstraint, $linkConstraint, '<=')
  20112. ) {
  20113. $this->warnings[] = $linkType.'.'.$package.' : exact version constraints ('.$constraint.') should be avoided if the package follows semantic versioning';
  20114. }
  20115. }
  20116. }
  20117. }
  20118. }
  20119. if ($this->validateArray('suggest') && !empty($this->config['suggest'])) {
  20120. foreach ($this->config['suggest'] as $package => $description) {
  20121. if (!is_string($description)) {
  20122. $this->errors[] = 'suggest.'.$package.' : invalid value, must be a string describing why the package is suggested';
  20123. unset($this->config['suggest'][$package]);
  20124. }
  20125. }
  20126. }
  20127. if ($this->validateString('minimum-stability') && !empty($this->config['minimum-stability'])) {
  20128. if (!isset(BasePackage::$stabilities[$this->config['minimum-stability']])) {
  20129. $this->errors[] = 'minimum-stability : invalid value ('.$this->config['minimum-stability'].'), must be one of '.implode(', ', array_keys(BasePackage::$stabilities));
  20130. unset($this->config['minimum-stability']);
  20131. }
  20132. }
  20133. if ($this->validateArray('autoload') && !empty($this->config['autoload'])) {
  20134. $types = array('psr-0', 'psr-4', 'classmap', 'files', 'exclude-from-classmap');
  20135. foreach ($this->config['autoload'] as $type => $typeConfig) {
  20136. if (!in_array($type, $types)) {
  20137. $this->errors[] = 'autoload : invalid value ('.$type.'), must be one of '.implode(', ', $types);
  20138. unset($this->config['autoload'][$type]);
  20139. }
  20140. if ($type === 'psr-4') {
  20141. foreach ($typeConfig as $namespace => $dirs) {
  20142. if ($namespace !== '' && '\\' !== substr($namespace, -1)) {
  20143. $this->errors[] = 'autoload.psr-4 : invalid value ('.$namespace.'), namespaces must end with a namespace separator, should be '.$namespace.'\\\\';
  20144. }
  20145. }
  20146. }
  20147. }
  20148. }
  20149. if (!empty($this->config['autoload']['psr-4']) && !empty($this->config['target-dir'])) {
  20150. $this->errors[] = 'target-dir : this can not be used together with the autoload.psr-4 setting, remove target-dir to upgrade to psr-4';
  20151. unset($this->config['autoload']['psr-4']);
  20152. }
  20153. $this->validateFlatArray('include-path');
  20154. $this->validateArray('transport-options');
  20155. if (isset($this->config['extra']['branch-alias'])) {
  20156. if (!is_array($this->config['extra']['branch-alias'])) {
  20157. $this->errors[] = 'extra.branch-alias : must be an array of versions => aliases';
  20158. } else {
  20159. foreach ($this->config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {
  20160. if ('-dev' !== substr($targetBranch, -4)) {
  20161. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') must end in -dev';
  20162. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  20163. continue;
  20164. }
  20165. $validatedTargetBranch = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4));
  20166. if ('-dev' !== substr($validatedTargetBranch, -4)) {
  20167. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') must be a parseable number like 2.0-dev';
  20168. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  20169. continue;
  20170. }
  20171. if (($sourcePrefix = $this->versionParser->parseNumericAliasPrefix($sourceBranch))
  20172. && ($targetPrefix = $this->versionParser->parseNumericAliasPrefix($targetBranch))
  20173. && (stripos($targetPrefix, $sourcePrefix) !== 0)
  20174. ) {
  20175. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') is not a valid numeric alias for this version';
  20176. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  20177. }
  20178. }
  20179. }
  20180. }
  20181. if ($this->errors) {
  20182. throw new InvalidPackageException($this->errors, $this->warnings, $config);
  20183. }
  20184. $package = $this->loader->load($this->config, $class);
  20185. $this->config = null;
  20186. return $package;
  20187. }
  20188. public function getWarnings()
  20189. {
  20190. return $this->warnings;
  20191. }
  20192. public function getErrors()
  20193. {
  20194. return $this->errors;
  20195. }
  20196. public static function hasPackageNamingError($name, $isLink = false)
  20197. {
  20198. if (PlatformRepository::isPlatformPackage($name)) {
  20199. return;
  20200. }
  20201. if (!preg_match('{^[a-z0-9](?:[_.-]?[a-z0-9]+)*/[a-z0-9](?:(?:[_.]?|-{0,2})[a-z0-9]+)*$}iD', $name)) {
  20202. 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]+)*$".';
  20203. }
  20204. $reservedNames = array('nul', 'con', 'prn', 'aux', 'com1', 'com2', 'com3', 'com4', 'com5', 'com6', 'com7', 'com8', 'com9', 'lpt1', 'lpt2', 'lpt3', 'lpt4', 'lpt5', 'lpt6', 'lpt7', 'lpt8', 'lpt9');
  20205. $bits = explode('/', strtolower($name));
  20206. if (in_array($bits[0], $reservedNames, true) || in_array($bits[1], $reservedNames, true)) {
  20207. return $name.' is reserved, package and vendor names can not match any of: '.implode(', ', $reservedNames).'.';
  20208. }
  20209. if (preg_match('{\.json$}', $name)) {
  20210. return $name.' is invalid, package names can not end in .json, consider renaming it or perhaps using a -json suffix instead.';
  20211. }
  20212. if (preg_match('{[A-Z]}', $name)) {
  20213. if ($isLink) {
  20214. return $name.' is invalid, it should not contain uppercase characters. Please use '.strtolower($name).' instead.';
  20215. }
  20216. $suggestName = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
  20217. $suggestName = strtolower($suggestName);
  20218. return $name.' is invalid, it should not contain uppercase characters. We suggest using '.$suggestName.' instead.';
  20219. }
  20220. }
  20221. private function validateRegex($property, $regex, $mandatory = false)
  20222. {
  20223. if (!$this->validateString($property, $mandatory)) {
  20224. return false;
  20225. }
  20226. if (!preg_match('{^'.$regex.'$}u', $this->config[$property])) {
  20227. $message = $property.' : invalid value ('.$this->config[$property].'), must match '.$regex;
  20228. if ($mandatory) {
  20229. $this->errors[] = $message;
  20230. } else {
  20231. $this->warnings[] = $message;
  20232. }
  20233. unset($this->config[$property]);
  20234. return false;
  20235. }
  20236. return true;
  20237. }
  20238. private function validateString($property, $mandatory = false)
  20239. {
  20240. if (isset($this->config[$property]) && !is_string($this->config[$property])) {
  20241. $this->errors[] = $property.' : should be a string, '.gettype($this->config[$property]).' given';
  20242. unset($this->config[$property]);
  20243. return false;
  20244. }
  20245. if (!isset($this->config[$property]) || trim($this->config[$property]) === '') {
  20246. if ($mandatory) {
  20247. $this->errors[] = $property.' : must be present';
  20248. }
  20249. unset($this->config[$property]);
  20250. return false;
  20251. }
  20252. return true;
  20253. }
  20254. private function validateArray($property, $mandatory = false)
  20255. {
  20256. if (isset($this->config[$property]) && !is_array($this->config[$property])) {
  20257. $this->errors[] = $property.' : should be an array, '.gettype($this->config[$property]).' given';
  20258. unset($this->config[$property]);
  20259. return false;
  20260. }
  20261. if (!isset($this->config[$property]) || !count($this->config[$property])) {
  20262. if ($mandatory) {
  20263. $this->errors[] = $property.' : must be present and contain at least one element';
  20264. }
  20265. unset($this->config[$property]);
  20266. return false;
  20267. }
  20268. return true;
  20269. }
  20270. private function validateFlatArray($property, $regex = null, $mandatory = false)
  20271. {
  20272. if (!$this->validateArray($property, $mandatory)) {
  20273. return false;
  20274. }
  20275. $pass = true;
  20276. foreach ($this->config[$property] as $key => $value) {
  20277. if (!is_string($value) && !is_numeric($value)) {
  20278. $this->errors[] = $property.'.'.$key.' : must be a string or int, '.gettype($value).' given';
  20279. unset($this->config[$property][$key]);
  20280. $pass = false;
  20281. continue;
  20282. }
  20283. if ($regex && !preg_match('{^'.$regex.'$}u', $value)) {
  20284. $this->warnings[] = $property.'.'.$key.' : invalid value ('.$value.'), must match '.$regex;
  20285. unset($this->config[$property][$key]);
  20286. $pass = false;
  20287. }
  20288. }
  20289. return $pass;
  20290. }
  20291. private function validateUrl($property, $mandatory = false)
  20292. {
  20293. if (!$this->validateString($property, $mandatory)) {
  20294. return false;
  20295. }
  20296. if (!$this->filterUrl($this->config[$property])) {
  20297. $this->warnings[] = $property.' : invalid value ('.$this->config[$property].'), must be an http/https URL';
  20298. unset($this->config[$property]);
  20299. return false;
  20300. }
  20301. return true;
  20302. }
  20303. private function filterUrl($value, array $schemes = array('http', 'https'))
  20304. {
  20305. if ($value === '') {
  20306. return true;
  20307. }
  20308. $bits = parse_url($value);
  20309. if (empty($bits['scheme']) || empty($bits['host'])) {
  20310. return false;
  20311. }
  20312. if (!in_array($bits['scheme'], $schemes, true)) {
  20313. return false;
  20314. }
  20315. return true;
  20316. }
  20317. }
  20318. <?php
  20319. namespace Composer\Package;
  20320. use Composer\Json\JsonFile;
  20321. use Composer\Installer\InstallationManager;
  20322. use Composer\Repository\LockArrayRepository;
  20323. use Composer\Repository\RepositoryManager;
  20324. use Composer\Util\ProcessExecutor;
  20325. use Composer\Package\Dumper\ArrayDumper;
  20326. use Composer\Package\Loader\ArrayLoader;
  20327. use Composer\Plugin\PluginInterface;
  20328. use Composer\Util\Git as GitUtil;
  20329. use Composer\IO\IOInterface;
  20330. use Seld\JsonLint\ParsingException;
  20331. class Locker
  20332. {
  20333. private $lockFile;
  20334. private $installationManager;
  20335. private $hash;
  20336. private $contentHash;
  20337. private $loader;
  20338. private $dumper;
  20339. private $process;
  20340. private $lockDataCache;
  20341. private $virtualFileWritten;
  20342. public function __construct(IOInterface $io, JsonFile $lockFile, InstallationManager $installationManager, $composerFileContents, ProcessExecutor $process = null)
  20343. {
  20344. $this->lockFile = $lockFile;
  20345. $this->installationManager = $installationManager;
  20346. $this->hash = md5($composerFileContents);
  20347. $this->contentHash = self::getContentHash($composerFileContents);
  20348. $this->loader = new ArrayLoader(null, true);
  20349. $this->dumper = new ArrayDumper();
  20350. $this->process = $process ?: new ProcessExecutor($io);
  20351. }
  20352. public static function getContentHash($composerFileContents)
  20353. {
  20354. $content = json_decode($composerFileContents, true);
  20355. $relevantKeys = array(
  20356. 'name',
  20357. 'version',
  20358. 'require',
  20359. 'require-dev',
  20360. 'conflict',
  20361. 'replace',
  20362. 'provide',
  20363. 'minimum-stability',
  20364. 'prefer-stable',
  20365. 'repositories',
  20366. 'extra',
  20367. );
  20368. $relevantContent = array();
  20369. foreach (array_intersect($relevantKeys, array_keys($content)) as $key) {
  20370. $relevantContent[$key] = $content[$key];
  20371. }
  20372. if (isset($content['config']['platform'])) {
  20373. $relevantContent['config']['platform'] = $content['config']['platform'];
  20374. }
  20375. ksort($relevantContent);
  20376. return md5(json_encode($relevantContent));
  20377. }
  20378. public function isLocked()
  20379. {
  20380. if (!$this->virtualFileWritten && !$this->lockFile->exists()) {
  20381. return false;
  20382. }
  20383. $data = $this->getLockData();
  20384. return isset($data['packages']);
  20385. }
  20386. public function isFresh()
  20387. {
  20388. $lock = $this->lockFile->read();
  20389. if (!empty($lock['content-hash'])) {
  20390. return $this->contentHash === $lock['content-hash'];
  20391. }
  20392. if (!empty($lock['hash'])) {
  20393. return $this->hash === $lock['hash'];
  20394. }
  20395. return false;
  20396. }
  20397. public function getLockedRepository($withDevReqs = false)
  20398. {
  20399. $lockData = $this->getLockData();
  20400. $packages = new LockArrayRepository();
  20401. $lockedPackages = $lockData['packages'];
  20402. if ($withDevReqs) {
  20403. if (isset($lockData['packages-dev'])) {
  20404. $lockedPackages = array_merge($lockedPackages, $lockData['packages-dev']);
  20405. } else {
  20406. 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.');
  20407. }
  20408. }
  20409. if (empty($lockedPackages)) {
  20410. return $packages;
  20411. }
  20412. if (isset($lockedPackages[0]['name'])) {
  20413. $packageByName = array();
  20414. foreach ($lockedPackages as $info) {
  20415. $package = $this->loader->load($info);
  20416. $packages->addPackage($package);
  20417. $packageByName[$package->getName()] = $package;
  20418. if ($package instanceof AliasPackage) {
  20419. $packageByName[$package->getAliasOf()->getName()] = $package->getAliasOf();
  20420. }
  20421. }
  20422. if (isset($lockData['aliases'])) {
  20423. foreach ($lockData['aliases'] as $alias) {
  20424. if (isset($packageByName[$alias['package']])) {
  20425. $packages->addPackage(new AliasPackage($packageByName[$alias['package']], $alias['alias_normalized'], $alias['alias']));
  20426. }
  20427. }
  20428. }
  20429. return $packages;
  20430. }
  20431. throw new \RuntimeException('Your composer.lock is invalid. Run "composer update" to generate a new one.');
  20432. }
  20433. public function getPlatformRequirements($withDevReqs = false)
  20434. {
  20435. $lockData = $this->getLockData();
  20436. $requirements = array();
  20437. if (!empty($lockData['platform'])) {
  20438. $requirements = $this->loader->parseLinks(
  20439. '__root__',
  20440. '1.0.0',
  20441. Link::TYPE_REQUIRE,
  20442. isset($lockData['platform']) ? $lockData['platform'] : array()
  20443. );
  20444. }
  20445. if ($withDevReqs && !empty($lockData['platform-dev'])) {
  20446. $devRequirements = $this->loader->parseLinks(
  20447. '__root__',
  20448. '1.0.0',
  20449. Link::TYPE_REQUIRE,
  20450. isset($lockData['platform-dev']) ? $lockData['platform-dev'] : array()
  20451. );
  20452. $requirements = array_merge($requirements, $devRequirements);
  20453. }
  20454. return $requirements;
  20455. }
  20456. public function getMinimumStability()
  20457. {
  20458. $lockData = $this->getLockData();
  20459. return isset($lockData['minimum-stability']) ? $lockData['minimum-stability'] : 'stable';
  20460. }
  20461. public function getStabilityFlags()
  20462. {
  20463. $lockData = $this->getLockData();
  20464. return isset($lockData['stability-flags']) ? $lockData['stability-flags'] : array();
  20465. }
  20466. public function getPreferStable()
  20467. {
  20468. $lockData = $this->getLockData();
  20469. return isset($lockData['prefer-stable']) ? $lockData['prefer-stable'] : null;
  20470. }
  20471. public function getPreferLowest()
  20472. {
  20473. $lockData = $this->getLockData();
  20474. return isset($lockData['prefer-lowest']) ? $lockData['prefer-lowest'] : null;
  20475. }
  20476. public function getPlatformOverrides()
  20477. {
  20478. $lockData = $this->getLockData();
  20479. return isset($lockData['platform-overrides']) ? $lockData['platform-overrides'] : array();
  20480. }
  20481. public function getAliases()
  20482. {
  20483. $lockData = $this->getLockData();
  20484. return isset($lockData['aliases']) ? $lockData['aliases'] : array();
  20485. }
  20486. public function getLockData()
  20487. {
  20488. if (null !== $this->lockDataCache) {
  20489. return $this->lockDataCache;
  20490. }
  20491. if (!$this->lockFile->exists()) {
  20492. throw new \LogicException('No lockfile found. Unable to read locked packages');
  20493. }
  20494. return $this->lockDataCache = $this->lockFile->read();
  20495. }
  20496. public function setLockData(array $packages, $devPackages, array $platformReqs, $platformDevReqs, array $aliases, $minimumStability, array $stabilityFlags, $preferStable, $preferLowest, array $platformOverrides, $write = true)
  20497. {
  20498. $lock = array(
  20499. '_readme' => array('This file locks the dependencies of your project to a known state',
  20500. 'Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies',
  20501. 'This file is @gener'.'ated automatically', ),
  20502. 'content-hash' => $this->contentHash,
  20503. 'packages' => null,
  20504. 'packages-dev' => null,
  20505. 'aliases' => $aliases,
  20506. 'minimum-stability' => $minimumStability,
  20507. 'stability-flags' => $stabilityFlags,
  20508. 'prefer-stable' => $preferStable,
  20509. 'prefer-lowest' => $preferLowest,
  20510. );
  20511. $lock['packages'] = $this->lockPackages($packages);
  20512. if (null !== $devPackages) {
  20513. $lock['packages-dev'] = $this->lockPackages($devPackages);
  20514. }
  20515. $lock['platform'] = $platformReqs;
  20516. $lock['platform-dev'] = $platformDevReqs;
  20517. if ($platformOverrides) {
  20518. $lock['platform-overrides'] = $platformOverrides;
  20519. }
  20520. $lock['plugin-api-version'] = PluginInterface::PLUGIN_API_VERSION;
  20521. try {
  20522. $isLocked = $this->isLocked();
  20523. } catch (ParsingException $e) {
  20524. $isLocked = false;
  20525. }
  20526. if (!$isLocked || $lock !== $this->getLockData()) {
  20527. if ($write) {
  20528. $this->lockFile->write($lock);
  20529. $this->lockDataCache = null;
  20530. $this->virtualFileWritten = false;
  20531. } else {
  20532. $this->virtualFileWritten = true;
  20533. $this->lockDataCache = JsonFile::parseJson(JsonFile::encode($lock, 448 & JsonFile::JSON_PRETTY_PRINT));
  20534. }
  20535. return true;
  20536. }
  20537. return false;
  20538. }
  20539. private function lockPackages(array $packages)
  20540. {
  20541. $locked = array();
  20542. foreach ($packages as $package) {
  20543. if ($package instanceof AliasPackage) {
  20544. continue;
  20545. }
  20546. $name = $package->getPrettyName();
  20547. $version = $package->getPrettyVersion();
  20548. if (!$name || !$version) {
  20549. throw new \LogicException(sprintf(
  20550. 'Package "%s" has no version or name and can not be locked',
  20551. $package
  20552. ));
  20553. }
  20554. $spec = $this->dumper->dump($package);
  20555. unset($spec['version_normalized']);
  20556. $time = isset($spec['time']) ? $spec['time'] : null;
  20557. unset($spec['time']);
  20558. if ($package->isDev() && $package->getInstallationSource() === 'source') {
  20559. $time = $this->getPackageTime($package) ?: $time;
  20560. }
  20561. if (null !== $time) {
  20562. $spec['time'] = $time;
  20563. }
  20564. unset($spec['installation-source']);
  20565. $locked[] = $spec;
  20566. }
  20567. usort($locked, function ($a, $b) {
  20568. $comparison = strcmp($a['name'], $b['name']);
  20569. if (0 !== $comparison) {
  20570. return $comparison;
  20571. }
  20572. return strcmp($a['version'], $b['version']);
  20573. });
  20574. return $locked;
  20575. }
  20576. private function getPackageTime(PackageInterface $package)
  20577. {
  20578. if (!function_exists('proc_open')) {
  20579. return null;
  20580. }
  20581. $path = realpath($this->installationManager->getInstallPath($package));
  20582. $sourceType = $package->getSourceType();
  20583. $datetime = null;
  20584. if ($path && in_array($sourceType, array('git', 'hg'))) {
  20585. $sourceRef = $package->getSourceReference() ?: $package->getDistReference();
  20586. switch ($sourceType) {
  20587. case 'git':
  20588. GitUtil::cleanEnv();
  20589. 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)) {
  20590. $datetime = new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
  20591. }
  20592. break;
  20593. case 'hg':
  20594. if (0 === $this->process->execute('hg log --template "{date|hgdate}" -r '.ProcessExecutor::escape($sourceRef), $output, $path) && preg_match('{^\s*(\d+)\s*}', $output, $match)) {
  20595. $datetime = new \DateTime('@'.$match[1], new \DateTimeZone('UTC'));
  20596. }
  20597. break;
  20598. }
  20599. }
  20600. return $datetime ? $datetime->format(DATE_RFC3339) : null;
  20601. }
  20602. }
  20603. <?php
  20604. namespace Composer\Package;
  20605. use Composer\Package\Version\VersionParser;
  20606. use Composer\Util\ComposerMirror;
  20607. class Package extends BasePackage
  20608. {
  20609. protected $type;
  20610. protected $targetDir;
  20611. protected $installationSource;
  20612. protected $sourceType;
  20613. protected $sourceUrl;
  20614. protected $sourceReference;
  20615. protected $sourceMirrors;
  20616. protected $distType;
  20617. protected $distUrl;
  20618. protected $distReference;
  20619. protected $distSha1Checksum;
  20620. protected $distMirrors;
  20621. protected $version;
  20622. protected $prettyVersion;
  20623. protected $releaseDate;
  20624. protected $extra = array();
  20625. protected $binaries = array();
  20626. protected $dev;
  20627. protected $stability;
  20628. protected $notificationUrl;
  20629. protected $requires = array();
  20630. protected $conflicts = array();
  20631. protected $provides = array();
  20632. protected $replaces = array();
  20633. protected $devRequires = array();
  20634. protected $suggests = array();
  20635. protected $autoload = array();
  20636. protected $devAutoload = array();
  20637. protected $includePaths = array();
  20638. protected $archiveName;
  20639. protected $archiveExcludes = array();
  20640. protected $isDefaultBranch = false;
  20641. public function __construct($name, $version, $prettyVersion)
  20642. {
  20643. parent::__construct($name);
  20644. $this->version = $version;
  20645. $this->prettyVersion = $prettyVersion;
  20646. $this->stability = VersionParser::parseStability($version);
  20647. $this->dev = $this->stability === 'dev';
  20648. }
  20649. public function isDev()
  20650. {
  20651. return $this->dev;
  20652. }
  20653. public function setType($type)
  20654. {
  20655. $this->type = $type;
  20656. }
  20657. public function getType()
  20658. {
  20659. return $this->type ?: 'library';
  20660. }
  20661. public function getStability()
  20662. {
  20663. return $this->stability;
  20664. }
  20665. public function setTargetDir($targetDir)
  20666. {
  20667. $this->targetDir = $targetDir;
  20668. }
  20669. public function getTargetDir()
  20670. {
  20671. if (null === $this->targetDir) {
  20672. return;
  20673. }
  20674. return ltrim(preg_replace('{ (?:^|[\\\\/]+) \.\.? (?:[\\\\/]+|$) (?:\.\.? (?:[\\\\/]+|$) )*}x', '/', $this->targetDir), '/');
  20675. }
  20676. public function setExtra(array $extra)
  20677. {
  20678. $this->extra = $extra;
  20679. }
  20680. public function getExtra()
  20681. {
  20682. return $this->extra;
  20683. }
  20684. public function setBinaries(array $binaries)
  20685. {
  20686. $this->binaries = $binaries;
  20687. }
  20688. public function getBinaries()
  20689. {
  20690. return $this->binaries;
  20691. }
  20692. public function setInstallationSource($type)
  20693. {
  20694. $this->installationSource = $type;
  20695. }
  20696. public function getInstallationSource()
  20697. {
  20698. return $this->installationSource;
  20699. }
  20700. public function setSourceType($type)
  20701. {
  20702. $this->sourceType = $type;
  20703. }
  20704. public function getSourceType()
  20705. {
  20706. return $this->sourceType;
  20707. }
  20708. public function setSourceUrl($url)
  20709. {
  20710. $this->sourceUrl = $url;
  20711. }
  20712. public function getSourceUrl()
  20713. {
  20714. return $this->sourceUrl;
  20715. }
  20716. public function setSourceReference($reference)
  20717. {
  20718. $this->sourceReference = $reference;
  20719. }
  20720. public function getSourceReference()
  20721. {
  20722. return $this->sourceReference;
  20723. }
  20724. public function setSourceMirrors($mirrors)
  20725. {
  20726. $this->sourceMirrors = $mirrors;
  20727. }
  20728. public function getSourceMirrors()
  20729. {
  20730. return $this->sourceMirrors;
  20731. }
  20732. public function getSourceUrls()
  20733. {
  20734. return $this->getUrls($this->sourceUrl, $this->sourceMirrors, $this->sourceReference, $this->sourceType, 'source');
  20735. }
  20736. public function setDistType($type)
  20737. {
  20738. $this->distType = $type;
  20739. }
  20740. public function getDistType()
  20741. {
  20742. return $this->distType;
  20743. }
  20744. public function setDistUrl($url)
  20745. {
  20746. $this->distUrl = $url;
  20747. }
  20748. public function getDistUrl()
  20749. {
  20750. return $this->distUrl;
  20751. }
  20752. public function setDistReference($reference)
  20753. {
  20754. $this->distReference = $reference;
  20755. }
  20756. public function getDistReference()
  20757. {
  20758. return $this->distReference;
  20759. }
  20760. public function setDistSha1Checksum($sha1checksum)
  20761. {
  20762. $this->distSha1Checksum = $sha1checksum;
  20763. }
  20764. public function getDistSha1Checksum()
  20765. {
  20766. return $this->distSha1Checksum;
  20767. }
  20768. public function setDistMirrors($mirrors)
  20769. {
  20770. $this->distMirrors = $mirrors;
  20771. }
  20772. public function getDistMirrors()
  20773. {
  20774. return $this->distMirrors;
  20775. }
  20776. public function getDistUrls()
  20777. {
  20778. return $this->getUrls($this->distUrl, $this->distMirrors, $this->distReference, $this->distType, 'dist');
  20779. }
  20780. public function getVersion()
  20781. {
  20782. return $this->version;
  20783. }
  20784. public function getPrettyVersion()
  20785. {
  20786. return $this->prettyVersion;
  20787. }
  20788. public function setReleaseDate(\DateTime $releaseDate)
  20789. {
  20790. $this->releaseDate = $releaseDate;
  20791. }
  20792. public function getReleaseDate()
  20793. {
  20794. return $this->releaseDate;
  20795. }
  20796. public function setRequires(array $requires)
  20797. {
  20798. $this->requires = $requires;
  20799. }
  20800. public function getRequires()
  20801. {
  20802. return $this->requires;
  20803. }
  20804. public function setConflicts(array $conflicts)
  20805. {
  20806. $this->conflicts = $conflicts;
  20807. }
  20808. public function getConflicts()
  20809. {
  20810. return $this->conflicts;
  20811. }
  20812. public function setProvides(array $provides)
  20813. {
  20814. $this->provides = $provides;
  20815. }
  20816. public function getProvides()
  20817. {
  20818. return $this->provides;
  20819. }
  20820. public function setReplaces(array $replaces)
  20821. {
  20822. $this->replaces = $replaces;
  20823. }
  20824. public function getReplaces()
  20825. {
  20826. return $this->replaces;
  20827. }
  20828. public function setDevRequires(array $devRequires)
  20829. {
  20830. $this->devRequires = $devRequires;
  20831. }
  20832. public function getDevRequires()
  20833. {
  20834. return $this->devRequires;
  20835. }
  20836. public function setSuggests(array $suggests)
  20837. {
  20838. $this->suggests = $suggests;
  20839. }
  20840. public function getSuggests()
  20841. {
  20842. return $this->suggests;
  20843. }
  20844. public function setAutoload(array $autoload)
  20845. {
  20846. $this->autoload = $autoload;
  20847. }
  20848. public function getAutoload()
  20849. {
  20850. return $this->autoload;
  20851. }
  20852. public function setDevAutoload(array $devAutoload)
  20853. {
  20854. $this->devAutoload = $devAutoload;
  20855. }
  20856. public function getDevAutoload()
  20857. {
  20858. return $this->devAutoload;
  20859. }
  20860. public function setIncludePaths(array $includePaths)
  20861. {
  20862. $this->includePaths = $includePaths;
  20863. }
  20864. public function getIncludePaths()
  20865. {
  20866. return $this->includePaths;
  20867. }
  20868. public function setNotificationUrl($notificationUrl)
  20869. {
  20870. $this->notificationUrl = $notificationUrl;
  20871. }
  20872. public function getNotificationUrl()
  20873. {
  20874. return $this->notificationUrl;
  20875. }
  20876. public function setArchiveName($name)
  20877. {
  20878. $this->archiveName = $name;
  20879. }
  20880. public function getArchiveName()
  20881. {
  20882. return $this->archiveName;
  20883. }
  20884. public function setArchiveExcludes(array $excludes)
  20885. {
  20886. $this->archiveExcludes = $excludes;
  20887. }
  20888. public function getArchiveExcludes()
  20889. {
  20890. return $this->archiveExcludes;
  20891. }
  20892. public function setIsDefaultBranch($defaultBranch)
  20893. {
  20894. $this->isDefaultBranch = $defaultBranch;
  20895. }
  20896. public function isDefaultBranch()
  20897. {
  20898. return $this->isDefaultBranch;
  20899. }
  20900. public function setSourceDistReferences($reference)
  20901. {
  20902. $this->setSourceReference($reference);
  20903. if (preg_match('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com|(?:www\.)?gitlab\.com)/}i', $this->getDistUrl())) {
  20904. $this->setDistReference($reference);
  20905. $this->setDistUrl(preg_replace('{(?<=/|sha=)[a-f0-9]{40}(?=/|$)}i', $reference, $this->getDistUrl()));
  20906. } elseif ($this->getDistReference()) {
  20907. $this->setDistReference($reference);
  20908. }
  20909. }
  20910. public function replaceVersion($version, $prettyVersion)
  20911. {
  20912. $this->version = $version;
  20913. $this->prettyVersion = $prettyVersion;
  20914. $this->stability = VersionParser::parseStability($version);
  20915. $this->dev = $this->stability === 'dev';
  20916. }
  20917. protected function getUrls($url, $mirrors, $ref, $type, $urlType)
  20918. {
  20919. if (!$url) {
  20920. return array();
  20921. }
  20922. $urls = array($url);
  20923. if ($mirrors) {
  20924. foreach ($mirrors as $mirror) {
  20925. if ($urlType === 'dist') {
  20926. $mirrorUrl = ComposerMirror::processUrl($mirror['url'], $this->name, $this->version, $ref, $type);
  20927. } elseif ($urlType === 'source' && $type === 'git') {
  20928. $mirrorUrl = ComposerMirror::processGitUrl($mirror['url'], $this->name, $url, $type);
  20929. } elseif ($urlType === 'source' && $type === 'hg') {
  20930. $mirrorUrl = ComposerMirror::processHgUrl($mirror['url'], $this->name, $url, $type);
  20931. } else {
  20932. continue;
  20933. }
  20934. if (!\in_array($mirrorUrl, $urls)) {
  20935. $func = $mirror['preferred'] ? 'array_unshift' : 'array_push';
  20936. $func($urls, $mirrorUrl);
  20937. }
  20938. }
  20939. }
  20940. return $urls;
  20941. }
  20942. }
  20943. <?php
  20944. namespace Composer\Package;
  20945. use Composer\Repository\RepositoryInterface;
  20946. interface PackageInterface
  20947. {
  20948. const DISPLAY_SOURCE_REF_IF_DEV = 0;
  20949. const DISPLAY_SOURCE_REF = 1;
  20950. const DISPLAY_DIST_REF = 2;
  20951. public function getName();
  20952. public function getPrettyName();
  20953. public function getNames($provides = true);
  20954. public function setId($id);
  20955. public function getId();
  20956. public function isDev();
  20957. public function getType();
  20958. public function getTargetDir();
  20959. public function getExtra();
  20960. public function setInstallationSource($type);
  20961. public function getInstallationSource();
  20962. public function getSourceType();
  20963. public function getSourceUrl();
  20964. public function getSourceUrls();
  20965. public function getSourceReference();
  20966. public function getSourceMirrors();
  20967. public function getDistType();
  20968. public function getDistUrl();
  20969. public function getDistUrls();
  20970. public function getDistReference();
  20971. public function getDistSha1Checksum();
  20972. public function getDistMirrors();
  20973. public function getVersion();
  20974. public function getPrettyVersion();
  20975. public function getFullPrettyVersion($truncate = true, $displayMode = self::DISPLAY_SOURCE_REF_IF_DEV);
  20976. public function getReleaseDate();
  20977. public function getStability();
  20978. public function getRequires();
  20979. public function getConflicts();
  20980. public function getProvides();
  20981. public function getReplaces();
  20982. public function getDevRequires();
  20983. public function getSuggests();
  20984. public function getAutoload();
  20985. public function getDevAutoload();
  20986. public function getIncludePaths();
  20987. public function setRepository(RepositoryInterface $repository);
  20988. public function getRepository();
  20989. public function getBinaries();
  20990. public function getUniqueName();
  20991. public function getNotificationUrl();
  20992. public function __toString();
  20993. public function getPrettyString();
  20994. public function getArchiveName();
  20995. public function getArchiveExcludes();
  20996. public function isDefaultBranch();
  20997. public function getTransportOptions();
  20998. public function setSourceReference($reference);
  20999. public function setDistUrl($url);
  21000. public function setDistType($type);
  21001. public function setDistReference($reference);
  21002. public function setSourceDistReferences($reference);
  21003. }
  21004. <?php
  21005. namespace Composer\Package;
  21006. class RootAliasPackage extends AliasPackage implements RootPackageInterface
  21007. {
  21008. public function __construct(RootPackageInterface $aliasOf, $version, $prettyVersion)
  21009. {
  21010. parent::__construct($aliasOf, $version, $prettyVersion);
  21011. }
  21012. public function getAliases()
  21013. {
  21014. return $this->aliasOf->getAliases();
  21015. }
  21016. public function getMinimumStability()
  21017. {
  21018. return $this->aliasOf->getMinimumStability();
  21019. }
  21020. public function getStabilityFlags()
  21021. {
  21022. return $this->aliasOf->getStabilityFlags();
  21023. }
  21024. public function getReferences()
  21025. {
  21026. return $this->aliasOf->getReferences();
  21027. }
  21028. public function getPreferStable()
  21029. {
  21030. return $this->aliasOf->getPreferStable();
  21031. }
  21032. public function getConfig()
  21033. {
  21034. return $this->aliasOf->getConfig();
  21035. }
  21036. public function setRequires(array $require)
  21037. {
  21038. $this->requires = $this->replaceSelfVersionDependencies($require, Link::TYPE_REQUIRE);
  21039. $this->aliasOf->setRequires($require);
  21040. }
  21041. public function setDevRequires(array $devRequire)
  21042. {
  21043. $this->devRequires = $this->replaceSelfVersionDependencies($devRequire, Link::TYPE_DEV_REQUIRE);
  21044. $this->aliasOf->setDevRequires($devRequire);
  21045. }
  21046. public function setConflicts(array $conflicts)
  21047. {
  21048. $this->conflicts = $this->replaceSelfVersionDependencies($conflicts, Link::TYPE_CONFLICT);
  21049. $this->aliasOf->setConflicts($conflicts);
  21050. }
  21051. public function setProvides(array $provides)
  21052. {
  21053. $this->provides = $this->replaceSelfVersionDependencies($provides, Link::TYPE_PROVIDE);
  21054. $this->aliasOf->setProvides($provides);
  21055. }
  21056. public function setReplaces(array $replaces)
  21057. {
  21058. $this->replaces = $this->replaceSelfVersionDependencies($replaces, Link::TYPE_REPLACE);
  21059. $this->aliasOf->setReplaces($replaces);
  21060. }
  21061. public function setRepositories($repositories)
  21062. {
  21063. $this->aliasOf->setRepositories($repositories);
  21064. }
  21065. public function setAutoload(array $autoload)
  21066. {
  21067. $this->aliasOf->setAutoload($autoload);
  21068. }
  21069. public function setDevAutoload(array $devAutoload)
  21070. {
  21071. $this->aliasOf->setDevAutoload($devAutoload);
  21072. }
  21073. public function setStabilityFlags(array $stabilityFlags)
  21074. {
  21075. $this->aliasOf->setStabilityFlags($stabilityFlags);
  21076. }
  21077. public function setSuggests(array $suggests)
  21078. {
  21079. $this->aliasOf->setSuggests($suggests);
  21080. }
  21081. public function setExtra(array $extra)
  21082. {
  21083. $this->aliasOf->setExtra($extra);
  21084. }
  21085. public function __clone()
  21086. {
  21087. parent::__clone();
  21088. $this->aliasOf = clone $this->aliasOf;
  21089. }
  21090. }
  21091. <?php
  21092. namespace Composer\Package;
  21093. class RootPackage extends CompletePackage implements RootPackageInterface
  21094. {
  21095. protected $minimumStability = 'stable';
  21096. protected $preferStable = false;
  21097. protected $stabilityFlags = array();
  21098. protected $config = array();
  21099. protected $references = array();
  21100. protected $aliases = array();
  21101. public function setMinimumStability($minimumStability)
  21102. {
  21103. $this->minimumStability = $minimumStability;
  21104. }
  21105. public function getMinimumStability()
  21106. {
  21107. return $this->minimumStability;
  21108. }
  21109. public function setStabilityFlags(array $stabilityFlags)
  21110. {
  21111. $this->stabilityFlags = $stabilityFlags;
  21112. }
  21113. public function getStabilityFlags()
  21114. {
  21115. return $this->stabilityFlags;
  21116. }
  21117. public function setPreferStable($preferStable)
  21118. {
  21119. $this->preferStable = $preferStable;
  21120. }
  21121. public function getPreferStable()
  21122. {
  21123. return $this->preferStable;
  21124. }
  21125. public function setConfig(array $config)
  21126. {
  21127. $this->config = $config;
  21128. }
  21129. public function getConfig()
  21130. {
  21131. return $this->config;
  21132. }
  21133. public function setReferences(array $references)
  21134. {
  21135. $this->references = $references;
  21136. }
  21137. public function getReferences()
  21138. {
  21139. return $this->references;
  21140. }
  21141. public function setAliases(array $aliases)
  21142. {
  21143. $this->aliases = $aliases;
  21144. }
  21145. public function getAliases()
  21146. {
  21147. return $this->aliases;
  21148. }
  21149. }
  21150. <?php
  21151. namespace Composer\Package;
  21152. interface RootPackageInterface extends CompletePackageInterface
  21153. {
  21154. public function getAliases();
  21155. public function getMinimumStability();
  21156. public function getStabilityFlags();
  21157. public function getReferences();
  21158. public function getPreferStable();
  21159. public function getConfig();
  21160. public function setRequires(array $requires);
  21161. public function setDevRequires(array $devRequires);
  21162. public function setConflicts(array $conflicts);
  21163. public function setProvides(array $provides);
  21164. public function setReplaces(array $replaces);
  21165. public function setRepositories($repositories);
  21166. public function setAutoload(array $autoload);
  21167. public function setDevAutoload(array $devAutoload);
  21168. public function setStabilityFlags(array $stabilityFlags);
  21169. public function setSuggests(array $suggests);
  21170. public function setExtra(array $extra);
  21171. }
  21172. <?php
  21173. namespace Composer\Package\Version;
  21174. use Composer\Package\BasePackage;
  21175. class StabilityFilter
  21176. {
  21177. public static function isPackageAcceptable(array $acceptableStabilities, array $stabilityFlags, $names, $stability)
  21178. {
  21179. foreach ($names as $name) {
  21180. if (isset($stabilityFlags[$name])) {
  21181. if (BasePackage::$stabilities[$stability] <= $stabilityFlags[$name]) {
  21182. return true;
  21183. }
  21184. } elseif (isset($acceptableStabilities[$stability])) {
  21185. return true;
  21186. }
  21187. }
  21188. return false;
  21189. }
  21190. }
  21191. <?php
  21192. namespace Composer\Package\Version;
  21193. use Composer\Config;
  21194. use Composer\Repository\Vcs\HgDriver;
  21195. use Composer\IO\NullIO;
  21196. use Composer\Semver\VersionParser as SemverVersionParser;
  21197. use Composer\Util\Git as GitUtil;
  21198. use Composer\Util\HttpDownloader;
  21199. use Composer\Util\ProcessExecutor;
  21200. use Composer\Util\Svn as SvnUtil;
  21201. class VersionGuesser
  21202. {
  21203. private $config;
  21204. private $process;
  21205. private $versionParser;
  21206. public function __construct(Config $config, ProcessExecutor $process, SemverVersionParser $versionParser)
  21207. {
  21208. $this->config = $config;
  21209. $this->process = $process;
  21210. $this->versionParser = $versionParser;
  21211. }
  21212. public function guessVersion(array $packageConfig, $path)
  21213. {
  21214. if (!function_exists('proc_open')) {
  21215. return null;
  21216. }
  21217. $versionData = $this->guessGitVersion($packageConfig, $path);
  21218. if (null !== $versionData && null !== $versionData['version']) {
  21219. return $this->postprocess($versionData);
  21220. }
  21221. $versionData = $this->guessHgVersion($packageConfig, $path);
  21222. if (null !== $versionData && null !== $versionData['version']) {
  21223. return $this->postprocess($versionData);
  21224. }
  21225. $versionData = $this->guessFossilVersion($path);
  21226. if (null !== $versionData && null !== $versionData['version']) {
  21227. return $this->postprocess($versionData);
  21228. }
  21229. $versionData = $this->guessSvnVersion($packageConfig, $path);
  21230. if (null !== $versionData && null !== $versionData['version']) {
  21231. return $this->postprocess($versionData);
  21232. }
  21233. return null;
  21234. }
  21235. private function postprocess(array $versionData)
  21236. {
  21237. if (!empty($versionData['feature_version']) && $versionData['feature_version'] === $versionData['version'] && $versionData['feature_pretty_version'] === $versionData['pretty_version']) {
  21238. unset($versionData['feature_version'], $versionData['feature_pretty_version']);
  21239. }
  21240. if ('-dev' === substr($versionData['version'], -4) && preg_match('{\.9{7}}', $versionData['version'])) {
  21241. $versionData['pretty_version'] = preg_replace('{(\.9{7})+}', '.x', $versionData['version']);
  21242. }
  21243. if (!empty($versionData['feature_version']) && '-dev' === substr($versionData['feature_version'], -4) && preg_match('{\.9{7}}', $versionData['feature_version'])) {
  21244. $versionData['feature_pretty_version'] = preg_replace('{(\.9{7})+}', '.x', $versionData['feature_version']);
  21245. }
  21246. return $versionData;
  21247. }
  21248. private function guessGitVersion(array $packageConfig, $path)
  21249. {
  21250. GitUtil::cleanEnv();
  21251. $commit = null;
  21252. $version = null;
  21253. $prettyVersion = null;
  21254. $featureVersion = null;
  21255. $featurePrettyVersion = null;
  21256. $isDetached = false;
  21257. if (0 === $this->process->execute('git branch -a --no-color --no-abbrev -v', $output, $path)) {
  21258. $branches = array();
  21259. $isFeatureBranch = false;
  21260. foreach ($this->process->splitLines($output) as $branch) {
  21261. if ($branch && preg_match('{^(?:\* ) *(\(no branch\)|\(detached from \S+\)|\(HEAD detached at \S+\)|\S+) *([a-f0-9]+) .*$}', $branch, $match)) {
  21262. if (
  21263. $match[1] === '(no branch)'
  21264. || strpos($match[1], '(detached ') === 0
  21265. || strpos($match[1], '(HEAD detached at') === 0
  21266. ) {
  21267. $version = 'dev-' . $match[2];
  21268. $prettyVersion = $version;
  21269. $isFeatureBranch = true;
  21270. $isDetached = true;
  21271. } else {
  21272. $version = $this->versionParser->normalizeBranch($match[1]);
  21273. $prettyVersion = 'dev-' . $match[1];
  21274. $isFeatureBranch = $this->isFeatureBranch($packageConfig, $match[1]);
  21275. }
  21276. if ($match[2]) {
  21277. $commit = $match[2];
  21278. }
  21279. }
  21280. if ($branch && !preg_match('{^ *.+/HEAD }', $branch)) {
  21281. if (preg_match('{^(?:\* )? *((?:remotes/(?:origin|upstream)/)?[^\s/]+) *([a-f0-9]+) .*$}', $branch, $match)) {
  21282. $branches[] = $match[1];
  21283. }
  21284. }
  21285. }
  21286. if ($isFeatureBranch) {
  21287. $featureVersion = $version;
  21288. $featurePrettyVersion = $prettyVersion;
  21289. $result = $this->guessFeatureVersion($packageConfig, $version, $branches, 'git rev-list %candidate%..%branch%', $path);
  21290. $version = $result['version'];
  21291. $prettyVersion = $result['pretty_version'];
  21292. }
  21293. }
  21294. if (!$version || $isDetached) {
  21295. $result = $this->versionFromGitTags($path);
  21296. if ($result) {
  21297. $version = $result['version'];
  21298. $prettyVersion = $result['pretty_version'];
  21299. $featureVersion = null;
  21300. $featurePrettyVersion = null;
  21301. }
  21302. }
  21303. if (!$commit) {
  21304. $command = 'git log --pretty="%H" -n1 HEAD'.GitUtil::getNoShowSignatureFlag($this->process);
  21305. if (0 === $this->process->execute($command, $output, $path)) {
  21306. $commit = trim($output) ?: null;
  21307. }
  21308. }
  21309. if ($featureVersion) {
  21310. return array('version' => $version, 'commit' => $commit, 'pretty_version' => $prettyVersion, 'feature_version' => $featureVersion, 'feature_pretty_version' => $featurePrettyVersion);
  21311. }
  21312. return array('version' => $version, 'commit' => $commit, 'pretty_version' => $prettyVersion);
  21313. }
  21314. private function versionFromGitTags($path)
  21315. {
  21316. if (0 === $this->process->execute('git describe --exact-match --tags', $output, $path)) {
  21317. try {
  21318. $version = $this->versionParser->normalize(trim($output));
  21319. return array('version' => $version, 'pretty_version' => trim($output));
  21320. } catch (\Exception $e) {
  21321. }
  21322. }
  21323. return null;
  21324. }
  21325. private function guessHgVersion(array $packageConfig, $path)
  21326. {
  21327. if (0 === $this->process->execute('hg branch', $output, $path)) {
  21328. $branch = trim($output);
  21329. $version = $this->versionParser->normalizeBranch($branch);
  21330. $isFeatureBranch = 0 === strpos($version, 'dev-');
  21331. if (VersionParser::DEFAULT_BRANCH_ALIAS === $version) {
  21332. return array('version' => $version, 'commit' => null, 'pretty_version' => 'dev-'.$branch);
  21333. }
  21334. if (!$isFeatureBranch) {
  21335. return array('version' => $version, 'commit' => null, 'pretty_version' => $version);
  21336. }
  21337. $io = new NullIO();
  21338. $driver = new HgDriver(array('url' => $path), $io, $this->config, new HttpDownloader($io, $this->config), $this->process);
  21339. $branches = array_keys($driver->getBranches());
  21340. $result = $this->guessFeatureVersion($packageConfig, $version, $branches, 'hg log -r "not ancestors(\'%candidate%\') and ancestors(\'%branch%\')" --template "{node}\\n"', $path);
  21341. $result['commit'] = '';
  21342. $result['feature_version'] = $version;
  21343. $result['feature_pretty_version'] = $version;
  21344. return $result;
  21345. }
  21346. }
  21347. private function guessFeatureVersion(array $packageConfig, $version, array $branches, $scmCmdline, $path)
  21348. {
  21349. $prettyVersion = $version;
  21350. if (!isset($packageConfig['extra']['branch-alias'][$version])
  21351. || strpos(json_encode($packageConfig), '"self.version"')
  21352. ) {
  21353. $branch = preg_replace('{^dev-}', '', $version);
  21354. $length = PHP_INT_MAX;
  21355. if (!$this->isFeatureBranch($packageConfig, $branch)) {
  21356. return array('version' => $version, 'pretty_version' => $prettyVersion);
  21357. }
  21358. usort($branches, function ($a, $b) {
  21359. $aRemote = 0 === strpos($a, 'remotes/');
  21360. $bRemote = 0 === strpos($b, 'remotes/');
  21361. if ($aRemote !== $bRemote) {
  21362. return $aRemote ? 1 : -1;
  21363. }
  21364. return strnatcasecmp($b, $a);
  21365. });
  21366. foreach ($branches as $candidate) {
  21367. $candidateVersion = preg_replace('{^remotes/\S+/}', '', $candidate);
  21368. if ($candidate === $branch || $this->isFeatureBranch($packageConfig, $candidateVersion)) {
  21369. continue;
  21370. }
  21371. $cmdLine = str_replace(array('%candidate%', '%branch%'), array($candidate, $branch), $scmCmdline);
  21372. if (0 !== $this->process->execute($cmdLine, $output, $path)) {
  21373. continue;
  21374. }
  21375. if (strlen($output) < $length) {
  21376. $length = strlen($output);
  21377. $version = $this->versionParser->normalizeBranch($candidateVersion);
  21378. $prettyVersion = 'dev-' . $candidateVersion;
  21379. if ($length === 0) {
  21380. break;
  21381. }
  21382. }
  21383. }
  21384. }
  21385. return array('version' => $version, 'pretty_version' => $prettyVersion);
  21386. }
  21387. private function isFeatureBranch(array $packageConfig, $branchName)
  21388. {
  21389. $nonFeatureBranches = '';
  21390. if (!empty($packageConfig['non-feature-branches'])) {
  21391. $nonFeatureBranches = implode('|', $packageConfig['non-feature-branches']);
  21392. }
  21393. return !preg_match('{^(' . $nonFeatureBranches . '|master|main|latest|next|current|support|tip|trunk|default|develop|\d+\..+)$}', $branchName, $match);
  21394. }
  21395. private function guessFossilVersion($path)
  21396. {
  21397. $version = null;
  21398. $prettyVersion = null;
  21399. if (0 === $this->process->execute('fossil branch list', $output, $path)) {
  21400. $branch = trim($output);
  21401. $version = $this->versionParser->normalizeBranch($branch);
  21402. $prettyVersion = 'dev-' . $branch;
  21403. }
  21404. if (0 === $this->process->execute('fossil tag list', $output, $path)) {
  21405. try {
  21406. $version = $this->versionParser->normalize(trim($output));
  21407. $prettyVersion = trim($output);
  21408. } catch (\Exception $e) {
  21409. }
  21410. }
  21411. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  21412. }
  21413. private function guessSvnVersion(array $packageConfig, $path)
  21414. {
  21415. SvnUtil::cleanEnv();
  21416. if (0 === $this->process->execute('svn info --xml', $output, $path)) {
  21417. $trunkPath = isset($packageConfig['trunk-path']) ? preg_quote($packageConfig['trunk-path'], '#') : 'trunk';
  21418. $branchesPath = isset($packageConfig['branches-path']) ? preg_quote($packageConfig['branches-path'], '#') : 'branches';
  21419. $tagsPath = isset($packageConfig['tags-path']) ? preg_quote($packageConfig['tags-path'], '#') : 'tags';
  21420. $urlPattern = '#<url>.*/(' . $trunkPath . '|(' . $branchesPath . '|' . $tagsPath . ')/(.*))</url>#';
  21421. if (preg_match($urlPattern, $output, $matches)) {
  21422. if (isset($matches[2]) && ($branchesPath === $matches[2] || $tagsPath === $matches[2])) {
  21423. $version = $this->versionParser->normalizeBranch($matches[3]);
  21424. $prettyVersion = 'dev-' . $matches[3];
  21425. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  21426. }
  21427. $prettyVersion = trim($matches[1]);
  21428. if ($prettyVersion === 'trunk') {
  21429. $version = 'dev-trunk';
  21430. } else {
  21431. $version = $this->versionParser->normalize($prettyVersion);
  21432. }
  21433. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  21434. }
  21435. }
  21436. }
  21437. }
  21438. <?php
  21439. namespace Composer\Package\Version;
  21440. use Composer\Repository\PlatformRepository;
  21441. use Composer\Semver\VersionParser as SemverVersionParser;
  21442. use Composer\Semver\Semver;
  21443. class VersionParser extends SemverVersionParser
  21444. {
  21445. const DEFAULT_BRANCH_ALIAS = '9999999-dev';
  21446. private static $constraints = array();
  21447. public function parseConstraints($constraints)
  21448. {
  21449. if (!isset(self::$constraints[$constraints])) {
  21450. self::$constraints[$constraints] = parent::parseConstraints($constraints);
  21451. }
  21452. return self::$constraints[$constraints];
  21453. }
  21454. public function parseNameVersionPairs(array $pairs)
  21455. {
  21456. $pairs = array_values($pairs);
  21457. $result = array();
  21458. for ($i = 0, $count = count($pairs); $i < $count; $i++) {
  21459. $pair = preg_replace('{^([^=: ]+)[=: ](.*)$}', '$1 $2', trim($pairs[$i]));
  21460. if (false === strpos($pair, ' ') && isset($pairs[$i + 1]) && false === strpos($pairs[$i + 1], '/') && !PlatformRepository::isPlatformPackage($pairs[$i + 1])) {
  21461. $pair .= ' '.$pairs[$i + 1];
  21462. $i++;
  21463. }
  21464. if (strpos($pair, ' ')) {
  21465. list($name, $version) = explode(' ', $pair, 2);
  21466. $result[] = array('name' => $name, 'version' => $version);
  21467. } else {
  21468. $result[] = array('name' => $pair);
  21469. }
  21470. }
  21471. return $result;
  21472. }
  21473. public static function isUpgrade($normalizedFrom, $normalizedTo)
  21474. {
  21475. if ($normalizedFrom === $normalizedTo) {
  21476. return true;
  21477. }
  21478. $normalizedFrom = str_replace(array('dev-master', 'dev-trunk', 'dev-default'), VersionParser::DEFAULT_BRANCH_ALIAS, $normalizedFrom);
  21479. $normalizedTo = str_replace(array('dev-master', 'dev-trunk', 'dev-default'), VersionParser::DEFAULT_BRANCH_ALIAS, $normalizedTo);
  21480. if (strpos($normalizedFrom, 'dev-') === 0 || strpos($normalizedTo, 'dev-') === 0) {
  21481. return true;
  21482. }
  21483. $sorted = Semver::sort(array($normalizedTo, $normalizedFrom));
  21484. return $sorted[0] === $normalizedFrom;
  21485. }
  21486. }
  21487. <?php
  21488. namespace Composer\Package\Version;
  21489. use Composer\DependencyResolver\Pool;
  21490. use Composer\Package\BasePackage;
  21491. use Composer\Package\PackageInterface;
  21492. use Composer\Plugin\PluginInterface;
  21493. use Composer\Composer;
  21494. use Composer\Package\Loader\ArrayLoader;
  21495. use Composer\Package\Dumper\ArrayDumper;
  21496. use Composer\Repository\RepositorySet;
  21497. use Composer\Repository\PlatformRepository;
  21498. use Composer\Semver\Constraint\Constraint;
  21499. class VersionSelector
  21500. {
  21501. private $repositorySet;
  21502. private $platformConstraints = array();
  21503. private $parser;
  21504. public function __construct(RepositorySet $repositorySet, PlatformRepository $platformRepo = null)
  21505. {
  21506. $this->repositorySet = $repositorySet;
  21507. if ($platformRepo) {
  21508. foreach ($platformRepo->getPackages() as $package) {
  21509. $this->platformConstraints[$package->getName()][] = new Constraint('==', $package->getVersion());
  21510. }
  21511. }
  21512. }
  21513. public function findBestCandidate($packageName, $targetPackageVersion = null, $preferredStability = 'stable', $ignorePlatformReqs = false)
  21514. {
  21515. if (!isset(BasePackage::$stabilities[$preferredStability])) {
  21516. throw new \UnexpectedValueException('Expected a valid stability name as 3rd argument, got '.$preferredStability);
  21517. }
  21518. $constraint = $targetPackageVersion ? $this->getParser()->parseConstraints($targetPackageVersion) : null;
  21519. $candidates = $this->repositorySet->findPackages(strtolower($packageName), $constraint);
  21520. if ($this->platformConstraints && true !== $ignorePlatformReqs) {
  21521. $platformConstraints = $this->platformConstraints;
  21522. $ignorePlatformReqs = $ignorePlatformReqs ?: array();
  21523. $candidates = array_filter($candidates, function ($pkg) use ($platformConstraints, $ignorePlatformReqs) {
  21524. $reqs = $pkg->getRequires();
  21525. foreach ($reqs as $name => $link) {
  21526. if (!in_array($name, $ignorePlatformReqs, true) && isset($platformConstraints[$name])) {
  21527. foreach ($platformConstraints[$name] as $constraint) {
  21528. if ($link->getConstraint()->matches($constraint)) {
  21529. continue 2;
  21530. }
  21531. }
  21532. return false;
  21533. }
  21534. }
  21535. return true;
  21536. });
  21537. }
  21538. if (!$candidates) {
  21539. return false;
  21540. }
  21541. $package = reset($candidates);
  21542. $minPriority = BasePackage::$stabilities[$preferredStability];
  21543. foreach ($candidates as $candidate) {
  21544. $candidatePriority = $candidate->getStabilityPriority();
  21545. $currentPriority = $package->getStabilityPriority();
  21546. if ($minPriority < $candidatePriority && $currentPriority < $candidatePriority) {
  21547. continue;
  21548. }
  21549. if ($minPriority < $candidatePriority && $candidatePriority < $currentPriority) {
  21550. $package = $candidate;
  21551. continue;
  21552. }
  21553. if ($minPriority >= $candidatePriority && $minPriority < $currentPriority) {
  21554. $package = $candidate;
  21555. continue;
  21556. }
  21557. if (version_compare($package->getVersion(), $candidate->getVersion(), '<')) {
  21558. $package = $candidate;
  21559. }
  21560. }
  21561. return $package;
  21562. }
  21563. public function findRecommendedRequireVersion(PackageInterface $package)
  21564. {
  21565. $version = $package->getVersion();
  21566. if (!$package->isDev()) {
  21567. return $this->transformVersion($version, $package->getPrettyVersion(), $package->getStability());
  21568. }
  21569. $loader = new ArrayLoader($this->getParser());
  21570. $dumper = new ArrayDumper();
  21571. $extra = $loader->getBranchAlias($dumper->dump($package));
  21572. if ($extra) {
  21573. $extra = preg_replace('{^(\d+\.\d+\.\d+)(\.9999999)-dev$}', '$1.0', $extra, -1, $count);
  21574. if ($count) {
  21575. $extra = str_replace('.9999999', '.0', $extra);
  21576. return $this->transformVersion($extra, $extra, 'dev');
  21577. }
  21578. }
  21579. return $package->getPrettyVersion();
  21580. }
  21581. private function transformVersion($version, $prettyVersion, $stability)
  21582. {
  21583. $semanticVersionParts = explode('.', $version);
  21584. if (count($semanticVersionParts) == 4 && preg_match('{^0\D?}', $semanticVersionParts[3])) {
  21585. if ($semanticVersionParts[0] === '0') {
  21586. unset($semanticVersionParts[3]);
  21587. } else {
  21588. unset($semanticVersionParts[2], $semanticVersionParts[3]);
  21589. }
  21590. $version = implode('.', $semanticVersionParts);
  21591. } else {
  21592. return $prettyVersion;
  21593. }
  21594. if ($stability != 'stable') {
  21595. $version .= '@'.$stability;
  21596. }
  21597. return '^' . $version;
  21598. }
  21599. private function getParser()
  21600. {
  21601. if ($this->parser === null) {
  21602. $this->parser = new VersionParser();
  21603. }
  21604. return $this->parser;
  21605. }
  21606. }
  21607. <?php
  21608. namespace Composer\Platform;
  21609. use Composer\Util\Platform;
  21610. use Composer\Util\ProcessExecutor;
  21611. use Symfony\Component\Process\ExecutableFinder;
  21612. class HhvmDetector
  21613. {
  21614. private static $hhvmVersion;
  21615. private $executableFinder;
  21616. private $processExecutor;
  21617. public function __construct(ExecutableFinder $executableFinder = null, ProcessExecutor $processExecutor = null)
  21618. {
  21619. $this->executableFinder = $executableFinder;
  21620. $this->processExecutor = $processExecutor;
  21621. }
  21622. public function reset()
  21623. {
  21624. self::$hhvmVersion = null;
  21625. }
  21626. public function getVersion()
  21627. {
  21628. if (null !== self::$hhvmVersion) {
  21629. return self::$hhvmVersion ?: null;
  21630. }
  21631. self::$hhvmVersion = defined('HHVM_VERSION') ? HHVM_VERSION : null;
  21632. if (self::$hhvmVersion === null && !Platform::isWindows()) {
  21633. self::$hhvmVersion = false;
  21634. $this->executableFinder = $this->executableFinder ?: new ExecutableFinder();
  21635. $hhvmPath = $this->executableFinder->find('hhvm');
  21636. if ($hhvmPath !== null) {
  21637. $this->processExecutor = $this->processExecutor ?: new ProcessExecutor();
  21638. $exitCode = $this->processExecutor->execute(
  21639. ProcessExecutor::escape($hhvmPath).
  21640. ' --php -d hhvm.jit=0 -r "echo HHVM_VERSION;" 2>/dev/null',
  21641. self::$hhvmVersion
  21642. );
  21643. if ($exitCode !== 0) {
  21644. self::$hhvmVersion = false;
  21645. }
  21646. }
  21647. }
  21648. return self::$hhvmVersion;
  21649. }
  21650. }
  21651. <?php
  21652. namespace Composer\Platform;
  21653. class Runtime
  21654. {
  21655. public function hasConstant($constant, $class = null)
  21656. {
  21657. return defined(ltrim($class.'::'.$constant, ':'));
  21658. }
  21659. public function getConstant($constant, $class = null)
  21660. {
  21661. return constant(ltrim($class.'::'.$constant, ':'));
  21662. }
  21663. public function hasFunction($fn)
  21664. {
  21665. return function_exists($fn);
  21666. }
  21667. public function invoke($callable, array $arguments = array())
  21668. {
  21669. return call_user_func_array($callable, $arguments);
  21670. }
  21671. public function hasClass($class)
  21672. {
  21673. return class_exists($class, false);
  21674. }
  21675. public function construct($class, array $arguments = array())
  21676. {
  21677. if (empty($arguments)) {
  21678. return new $class;
  21679. }
  21680. $refl = new \ReflectionClass($class);
  21681. return $refl->newInstanceArgs($arguments);
  21682. }
  21683. public function getExtensions()
  21684. {
  21685. return get_loaded_extensions();
  21686. }
  21687. public function getExtensionVersion($extension)
  21688. {
  21689. return phpversion($extension);
  21690. }
  21691. public function getExtensionInfo($extension)
  21692. {
  21693. $reflector = new \ReflectionExtension($extension);
  21694. ob_start();
  21695. $reflector->info();
  21696. return ob_get_clean();
  21697. }
  21698. }
  21699. <?php
  21700. namespace Composer\Platform;
  21701. class Version
  21702. {
  21703. public static function parseOpenssl($opensslVersion, &$isFips)
  21704. {
  21705. $isFips = false;
  21706. if (!preg_match('/^(?<version>[0-9.]+)(?<patch>[a-z]{0,2})?(?<suffix>(?:-?(?:dev|pre|alpha|beta|rc|fips)[\d]*)*)?$/', $opensslVersion, $matches)) {
  21707. return null;
  21708. }
  21709. $isFips = strpos($matches['suffix'], 'fips') !== false;
  21710. $suffix = strtr('-'.ltrim($matches['suffix'], '-'), array('-fips' => '', '-pre' => '-alpha'));
  21711. $patch = self::convertAlphaVersionToIntVersion($matches['patch']);
  21712. return rtrim($matches['version'].'.'.$patch.$suffix, '-');
  21713. }
  21714. public static function parseLibjpeg($libjpegVersion)
  21715. {
  21716. if (!preg_match('/^(?<major>\d+)(?<minor>[a-z]*)$/', $libjpegVersion, $matches)) {
  21717. return null;
  21718. }
  21719. return $matches['major'].'.'.self::convertAlphaVersionToIntVersion($matches['minor']);
  21720. }
  21721. public static function parseZoneinfoVersion($zoneinfoVersion)
  21722. {
  21723. if (!preg_match('/^(?<year>\d{4})(?<revision>[a-z]*)$/', $zoneinfoVersion, $matches)) {
  21724. return null;
  21725. }
  21726. return $matches['year'].'.'.self::convertAlphaVersionToIntVersion($matches['revision']);
  21727. }
  21728. private static function convertAlphaVersionToIntVersion($alpha)
  21729. {
  21730. return strlen($alpha) * (-ord('a')+1) + array_sum(array_map('ord', str_split($alpha)));
  21731. }
  21732. public static function convertLibxpmVersionId($versionId)
  21733. {
  21734. return self::convertVersionId($versionId, 100);
  21735. }
  21736. public static function convertOpenldapVersionId($versionId)
  21737. {
  21738. return self::convertVersionId($versionId, 100);
  21739. }
  21740. private static function convertVersionId($versionId, $base)
  21741. {
  21742. return sprintf(
  21743. '%d.%d.%d',
  21744. $versionId / ($base * $base),
  21745. ($versionId / $base) % $base,
  21746. $versionId % $base
  21747. );
  21748. }
  21749. }
  21750. <?php
  21751. namespace Composer\Plugin\Capability;
  21752. interface Capability
  21753. {
  21754. }
  21755. <?php
  21756. namespace Composer\Plugin\Capability;
  21757. interface CommandProvider extends Capability
  21758. {
  21759. public function getCommands();
  21760. }
  21761. <?php
  21762. namespace Composer\Plugin;
  21763. interface Capable
  21764. {
  21765. public function getCapabilities();
  21766. }
  21767. <?php
  21768. namespace Composer\Plugin;
  21769. use Composer\EventDispatcher\Event;
  21770. use Symfony\Component\Console\Input\InputInterface;
  21771. use Symfony\Component\Console\Output\OutputInterface;
  21772. class CommandEvent extends Event
  21773. {
  21774. private $commandName;
  21775. private $input;
  21776. private $output;
  21777. public function __construct($name, $commandName, $input, $output, array $args = array(), array $flags = array())
  21778. {
  21779. parent::__construct($name, $args, $flags);
  21780. $this->commandName = $commandName;
  21781. $this->input = $input;
  21782. $this->output = $output;
  21783. }
  21784. public function getInput()
  21785. {
  21786. return $this->input;
  21787. }
  21788. public function getOutput()
  21789. {
  21790. return $this->output;
  21791. }
  21792. public function getCommandName()
  21793. {
  21794. return $this->commandName;
  21795. }
  21796. }
  21797. <?php
  21798. namespace Composer\Plugin;
  21799. class PluginEvents
  21800. {
  21801. const INIT = 'init';
  21802. const COMMAND = 'command';
  21803. const PRE_FILE_DOWNLOAD = 'pre-file-download';
  21804. const POST_FILE_DOWNLOAD = 'post-file-download';
  21805. const PRE_COMMAND_RUN = 'pre-command-run';
  21806. const PRE_POOL_CREATE = 'pre-pool-create';
  21807. }
  21808. <?php
  21809. namespace Composer\Plugin;
  21810. use Composer\Composer;
  21811. use Composer\IO\IOInterface;
  21812. interface PluginInterface
  21813. {
  21814. const PLUGIN_API_VERSION = '2.0.0';
  21815. public function activate(Composer $composer, IOInterface $io);
  21816. public function deactivate(Composer $composer, IOInterface $io);
  21817. public function uninstall(Composer $composer, IOInterface $io);
  21818. }
  21819. <?php
  21820. namespace Composer\Plugin;
  21821. use Composer\Composer;
  21822. use Composer\EventDispatcher\EventSubscriberInterface;
  21823. use Composer\IO\IOInterface;
  21824. use Composer\Package\CompletePackage;
  21825. use Composer\Package\Package;
  21826. use Composer\Package\Version\VersionParser;
  21827. use Composer\Repository\RepositoryInterface;
  21828. use Composer\Repository\InstalledRepository;
  21829. use Composer\Package\PackageInterface;
  21830. use Composer\Package\Link;
  21831. use Composer\Semver\Constraint\Constraint;
  21832. use Composer\Plugin\Capability\Capability;
  21833. use Composer\Util\PackageSorter;
  21834. class PluginManager
  21835. {
  21836. protected $composer;
  21837. protected $io;
  21838. protected $globalComposer;
  21839. protected $versionParser;
  21840. protected $disablePlugins = false;
  21841. protected $plugins = array();
  21842. protected $registeredPlugins = array();
  21843. private static $classCounter = 0;
  21844. public function __construct(IOInterface $io, Composer $composer, Composer $globalComposer = null, $disablePlugins = false)
  21845. {
  21846. $this->io = $io;
  21847. $this->composer = $composer;
  21848. $this->globalComposer = $globalComposer;
  21849. $this->versionParser = new VersionParser();
  21850. $this->disablePlugins = $disablePlugins;
  21851. }
  21852. public function loadInstalledPlugins()
  21853. {
  21854. if ($this->disablePlugins) {
  21855. return;
  21856. }
  21857. $repo = $this->composer->getRepositoryManager()->getLocalRepository();
  21858. $globalRepo = $this->globalComposer ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null;
  21859. if ($repo) {
  21860. $this->loadRepository($repo);
  21861. }
  21862. if ($globalRepo) {
  21863. $this->loadRepository($globalRepo);
  21864. }
  21865. }
  21866. public function getPlugins()
  21867. {
  21868. return $this->plugins;
  21869. }
  21870. public function getGlobalComposer()
  21871. {
  21872. return $this->globalComposer;
  21873. }
  21874. public function registerPackage(PackageInterface $package, $failOnMissingClasses = false)
  21875. {
  21876. if ($this->disablePlugins) {
  21877. return;
  21878. }
  21879. if ($package->getType() === 'composer-plugin') {
  21880. $requiresComposer = null;
  21881. foreach ($package->getRequires() as $link) {
  21882. if ('composer-plugin-api' === $link->getTarget()) {
  21883. $requiresComposer = $link->getConstraint();
  21884. break;
  21885. }
  21886. }
  21887. if (!$requiresComposer) {
  21888. throw new \RuntimeException("Plugin ".$package->getName()." is missing a require statement for a version of the composer-plugin-api package.");
  21889. }
  21890. $currentPluginApiVersion = $this->getPluginApiVersion();
  21891. $currentPluginApiConstraint = new Constraint('==', $this->versionParser->normalize($currentPluginApiVersion));
  21892. if ($requiresComposer->getPrettyString() === $this->getPluginApiVersion()) {
  21893. $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>');
  21894. } elseif (!$requiresComposer->matches($currentPluginApiConstraint)) {
  21895. $this->io->writeError('<warning>The "' . $package->getName() . '" plugin 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>');
  21896. return;
  21897. }
  21898. if ($package->getName() === 'symfony/flex' && preg_match('{^[0-9.]+$}', $package->getVersion()) && version_compare($package->getVersion(), '1.9.8', '<')) {
  21899. $this->io->writeError('<warning>The "' . $package->getName() . '" plugin was skipped because it is not compatible with Composer 2+. Make sure to update it to version 1.9.8 or greater.</warning>');
  21900. return;
  21901. }
  21902. }
  21903. $oldInstallerPlugin = ($package->getType() === 'composer-installer');
  21904. if (isset($this->registeredPlugins[$package->getName()])) {
  21905. return;
  21906. }
  21907. $extra = $package->getExtra();
  21908. if (empty($extra['class'])) {
  21909. throw new \UnexpectedValueException('Error while installing '.$package->getPrettyName().', composer-plugin packages should have a class defined in their extra key to be usable.');
  21910. }
  21911. $classes = is_array($extra['class']) ? $extra['class'] : array($extra['class']);
  21912. $localRepo = $this->composer->getRepositoryManager()->getLocalRepository();
  21913. $globalRepo = $this->globalComposer ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null;
  21914. $installedRepo = new InstalledRepository(array($localRepo));
  21915. if ($globalRepo) {
  21916. $installedRepo->addRepository($globalRepo);
  21917. }
  21918. $autoloadPackages = array($package->getName() => $package);
  21919. $autoloadPackages = $this->collectDependencies($installedRepo, $autoloadPackages, $package);
  21920. $generator = $this->composer->getAutoloadGenerator();
  21921. $autoloads = array();
  21922. foreach ($autoloadPackages as $autoloadPackage) {
  21923. $downloadPath = $this->getInstallPath($autoloadPackage, $globalRepo && $globalRepo->hasPackage($autoloadPackage));
  21924. $autoloads[] = array($autoloadPackage, $downloadPath);
  21925. }
  21926. $map = $generator->parseAutoloads($autoloads, new Package('dummy', '1.0.0.0', '1.0.0'));
  21927. $classLoader = $generator->createLoader($map);
  21928. $classLoader->register();
  21929. foreach ($classes as $class) {
  21930. if (class_exists($class, false)) {
  21931. $class = trim($class, '\\');
  21932. $path = $classLoader->findFile($class);
  21933. $code = file_get_contents($path);
  21934. $separatorPos = strrpos($class, '\\');
  21935. $className = $class;
  21936. if ($separatorPos) {
  21937. $className = substr($class, $separatorPos + 1);
  21938. }
  21939. $code = preg_replace('{^((?:final\s+)?(?:\s*))class\s+('.preg_quote($className).')}mi', '$1class $2_composer_tmp'.self::$classCounter, $code, 1);
  21940. $code = strtr($code, array(
  21941. '__FILE__' => var_export($path, true),
  21942. '__DIR__' => var_export(dirname($path), true),
  21943. '__CLASS__' => var_export($class, true),
  21944. ));
  21945. $code = preg_replace('/^\s*<\?(php)?/i', '', $code, 1);
  21946. eval($code);
  21947. $class .= '_composer_tmp'.self::$classCounter;
  21948. self::$classCounter++;
  21949. }
  21950. if ($oldInstallerPlugin) {
  21951. $installer = new $class($this->io, $this->composer);
  21952. $this->composer->getInstallationManager()->addInstaller($installer);
  21953. $this->registeredPlugins[$package->getName()] = $installer;
  21954. } elseif (class_exists($class)) {
  21955. $plugin = new $class();
  21956. $this->addPlugin($plugin);
  21957. $this->registeredPlugins[$package->getName()] = $plugin;
  21958. } elseif ($failOnMissingClasses) {
  21959. throw new \UnexpectedValueException('Plugin '.$package->getName().' could not be initialized, class not found: '.$class);
  21960. }
  21961. }
  21962. }
  21963. public function deactivatePackage(PackageInterface $package)
  21964. {
  21965. if ($this->disablePlugins) {
  21966. return;
  21967. }
  21968. $oldInstallerPlugin = ($package->getType() === 'composer-installer');
  21969. if (!isset($this->registeredPlugins[$package->getName()])) {
  21970. return;
  21971. }
  21972. if ($oldInstallerPlugin) {
  21973. $installer = $this->registeredPlugins[$package->getName()];
  21974. unset($this->registeredPlugins[$package->getName()]);
  21975. $this->composer->getInstallationManager()->removeInstaller($installer);
  21976. } else {
  21977. $plugin = $this->registeredPlugins[$package->getName()];
  21978. unset($this->registeredPlugins[$package->getName()]);
  21979. $this->removePlugin($plugin);
  21980. }
  21981. }
  21982. public function uninstallPackage(PackageInterface $package)
  21983. {
  21984. if ($this->disablePlugins) {
  21985. return;
  21986. }
  21987. $oldInstallerPlugin = ($package->getType() === 'composer-installer');
  21988. if (!isset($this->registeredPlugins[$package->getName()])) {
  21989. return;
  21990. }
  21991. if ($oldInstallerPlugin) {
  21992. $this->deactivatePackage($package);
  21993. } else {
  21994. $plugin = $this->registeredPlugins[$package->getName()];
  21995. unset($this->registeredPlugins[$package->getName()]);
  21996. $this->removePlugin($plugin);
  21997. $this->uninstallPlugin($plugin);
  21998. }
  21999. }
  22000. protected function getPluginApiVersion()
  22001. {
  22002. return PluginInterface::PLUGIN_API_VERSION;
  22003. }
  22004. public function addPlugin(PluginInterface $plugin)
  22005. {
  22006. $this->io->writeError('Loading plugin '.get_class($plugin), true, IOInterface::DEBUG);
  22007. $this->plugins[] = $plugin;
  22008. $plugin->activate($this->composer, $this->io);
  22009. if ($plugin instanceof EventSubscriberInterface) {
  22010. $this->composer->getEventDispatcher()->addSubscriber($plugin);
  22011. }
  22012. }
  22013. public function removePlugin(PluginInterface $plugin)
  22014. {
  22015. $index = array_search($plugin, $this->plugins, true);
  22016. if ($index === false) {
  22017. return;
  22018. }
  22019. $this->io->writeError('Unloading plugin '.get_class($plugin), true, IOInterface::DEBUG);
  22020. unset($this->plugins[$index]);
  22021. $plugin->deactivate($this->composer, $this->io);
  22022. $this->composer->getEventDispatcher()->removeListener($plugin);
  22023. }
  22024. public function uninstallPlugin(PluginInterface $plugin)
  22025. {
  22026. $this->io->writeError('Uninstalling plugin '.get_class($plugin), true, IOInterface::DEBUG);
  22027. $plugin->uninstall($this->composer, $this->io);
  22028. }
  22029. private function loadRepository(RepositoryInterface $repo)
  22030. {
  22031. $packages = $repo->getPackages();
  22032. $sortedPackages = PackageSorter::sortPackages($packages);
  22033. foreach ($sortedPackages as $package) {
  22034. if (!($package instanceof CompletePackage)) {
  22035. continue;
  22036. }
  22037. if ('composer-plugin' === $package->getType()) {
  22038. $this->registerPackage($package);
  22039. } elseif ('composer-installer' === $package->getType()) {
  22040. $this->registerPackage($package);
  22041. }
  22042. }
  22043. }
  22044. private function collectDependencies(InstalledRepository $installedRepo, array $collected, PackageInterface $package)
  22045. {
  22046. $requires = array_merge(
  22047. $package->getRequires(),
  22048. $package->getDevRequires()
  22049. );
  22050. foreach ($requires as $requireLink) {
  22051. foreach ($installedRepo->findPackagesWithReplacersAndProviders($requireLink->getTarget(), $requireLink->getConstraint()) as $requiredPackage) {
  22052. if (!isset($collected[$requiredPackage->getName()])) {
  22053. $collected[$requiredPackage->getName()] = $requiredPackage;
  22054. $collected = $this->collectDependencies($installedRepo, $collected, $requiredPackage);
  22055. }
  22056. }
  22057. }
  22058. return $collected;
  22059. }
  22060. private function getInstallPath(PackageInterface $package, $global = false)
  22061. {
  22062. if (!$global) {
  22063. return $this->composer->getInstallationManager()->getInstallPath($package);
  22064. }
  22065. return $this->globalComposer->getInstallationManager()->getInstallPath($package);
  22066. }
  22067. protected function getCapabilityImplementationClassName(PluginInterface $plugin, $capability)
  22068. {
  22069. if (!($plugin instanceof Capable)) {
  22070. return null;
  22071. }
  22072. $capabilities = (array) $plugin->getCapabilities();
  22073. if (!empty($capabilities[$capability]) && is_string($capabilities[$capability]) && trim($capabilities[$capability])) {
  22074. return trim($capabilities[$capability]);
  22075. }
  22076. if (
  22077. array_key_exists($capability, $capabilities)
  22078. && (empty($capabilities[$capability]) || !is_string($capabilities[$capability]) || !trim($capabilities[$capability]))
  22079. ) {
  22080. throw new \UnexpectedValueException('Plugin '.get_class($plugin).' provided invalid capability class name(s), got '.var_export($capabilities[$capability], 1));
  22081. }
  22082. }
  22083. public function getPluginCapability(PluginInterface $plugin, $capabilityClassName, array $ctorArgs = array())
  22084. {
  22085. if ($capabilityClass = $this->getCapabilityImplementationClassName($plugin, $capabilityClassName)) {
  22086. if (!class_exists($capabilityClass)) {
  22087. throw new \RuntimeException("Cannot instantiate Capability, as class $capabilityClass from plugin ".get_class($plugin)." does not exist.");
  22088. }
  22089. $ctorArgs['plugin'] = $plugin;
  22090. $capabilityObj = new $capabilityClass($ctorArgs);
  22091. if (!$capabilityObj instanceof Capability || !$capabilityObj instanceof $capabilityClassName) {
  22092. throw new \RuntimeException(
  22093. 'Class ' . $capabilityClass . ' must implement both Composer\Plugin\Capability\Capability and '. $capabilityClassName . '.'
  22094. );
  22095. }
  22096. return $capabilityObj;
  22097. }
  22098. }
  22099. public function getPluginCapabilities($capabilityClassName, array $ctorArgs = array())
  22100. {
  22101. $capabilities = array();
  22102. foreach ($this->getPlugins() as $plugin) {
  22103. if ($capability = $this->getPluginCapability($plugin, $capabilityClassName, $ctorArgs)) {
  22104. $capabilities[] = $capability;
  22105. }
  22106. }
  22107. return $capabilities;
  22108. }
  22109. }
  22110. <?php
  22111. namespace Composer\Plugin;
  22112. use Composer\EventDispatcher\Event;
  22113. use Composer\Package\PackageInterface;
  22114. class PostFileDownloadEvent extends Event
  22115. {
  22116. private $fileName;
  22117. private $checksum;
  22118. private $url;
  22119. private $package;
  22120. public function __construct($name, $fileName, $checksum, $url, PackageInterface $package)
  22121. {
  22122. parent::__construct($name);
  22123. $this->fileName = $fileName;
  22124. $this->checksum = $checksum;
  22125. $this->url = $url;
  22126. $this->package = $package;
  22127. }
  22128. public function getFileName()
  22129. {
  22130. return $this->fileName;
  22131. }
  22132. public function getChecksum() {
  22133. return $this->checksum;
  22134. }
  22135. public function getUrl() {
  22136. return $this->url;
  22137. }
  22138. public function getPackage() {
  22139. return $this->package;
  22140. }
  22141. }
  22142. <?php
  22143. namespace Composer\Plugin;
  22144. use Composer\EventDispatcher\Event;
  22145. use Symfony\Component\Console\Input\InputInterface;
  22146. class PreCommandRunEvent extends Event
  22147. {
  22148. private $input;
  22149. private $command;
  22150. public function __construct($name, InputInterface $input, $command)
  22151. {
  22152. parent::__construct($name);
  22153. $this->input = $input;
  22154. $this->command = $command;
  22155. }
  22156. public function getInput()
  22157. {
  22158. return $this->input;
  22159. }
  22160. public function getCommand()
  22161. {
  22162. return $this->command;
  22163. }
  22164. }
  22165. <?php
  22166. namespace Composer\Plugin;
  22167. use Composer\EventDispatcher\Event;
  22168. use Composer\Util\HttpDownloader;
  22169. class PreFileDownloadEvent extends Event
  22170. {
  22171. private $httpDownloader;
  22172. private $processedUrl;
  22173. private $customCacheKey;
  22174. private $type;
  22175. private $context;
  22176. public function __construct($name, HttpDownloader $httpDownloader, $processedUrl, $type, $context = null)
  22177. {
  22178. parent::__construct($name);
  22179. $this->httpDownloader = $httpDownloader;
  22180. $this->processedUrl = $processedUrl;
  22181. $this->type = $type;
  22182. $this->context = $context;
  22183. }
  22184. public function getHttpDownloader()
  22185. {
  22186. return $this->httpDownloader;
  22187. }
  22188. public function getProcessedUrl()
  22189. {
  22190. return $this->processedUrl;
  22191. }
  22192. public function setProcessedUrl($processedUrl)
  22193. {
  22194. $this->processedUrl = $processedUrl;
  22195. }
  22196. public function getCustomCacheKey()
  22197. {
  22198. return $this->customCacheKey;
  22199. }
  22200. public function setCustomCacheKey($customCacheKey)
  22201. {
  22202. $this->customCacheKey = $customCacheKey;
  22203. }
  22204. public function getType()
  22205. {
  22206. return $this->type;
  22207. }
  22208. public function getContext()
  22209. {
  22210. return $this->context;
  22211. }
  22212. }
  22213. <?php
  22214. namespace Composer\Plugin;
  22215. use Composer\EventDispatcher\Event;
  22216. use Symfony\Component\Console\Input\InputInterface;
  22217. use Composer\Repository\RepositoryInterface;
  22218. use Composer\DependencyResolver\Request;
  22219. use Composer\Package\PackageInterface;
  22220. class PrePoolCreateEvent extends Event
  22221. {
  22222. private $repositories;
  22223. private $request;
  22224. private $acceptableStabilities;
  22225. private $stabilityFlags;
  22226. private $rootAliases;
  22227. private $rootReferences;
  22228. private $packages;
  22229. private $unacceptableFixedPackages;
  22230. public function __construct($name, array $repositories, Request $request, array $acceptableStabilities, array $stabilityFlags, array $rootAliases, array $rootReferences, array $packages, array $unacceptableFixedPackages)
  22231. {
  22232. parent::__construct($name);
  22233. $this->repositories = $repositories;
  22234. $this->request = $request;
  22235. $this->acceptableStabilities = $acceptableStabilities;
  22236. $this->stabilityFlags = $stabilityFlags;
  22237. $this->rootAliases = $rootAliases;
  22238. $this->rootReferences = $rootReferences;
  22239. $this->packages = $packages;
  22240. $this->unacceptableFixedPackages = $unacceptableFixedPackages;
  22241. }
  22242. public function getRepositories()
  22243. {
  22244. return $this->repositories;
  22245. }
  22246. public function getRequest()
  22247. {
  22248. return $this->request;
  22249. }
  22250. public function getAcceptableStabilities()
  22251. {
  22252. return $this->acceptableStabilities;
  22253. }
  22254. public function getStabilityFlags()
  22255. {
  22256. return $this->stabilityFlags;
  22257. }
  22258. public function getRootAliases()
  22259. {
  22260. return $this->rootAliases;
  22261. }
  22262. public function getRootReferences()
  22263. {
  22264. return $this->rootReferences;
  22265. }
  22266. public function getPackages()
  22267. {
  22268. return $this->packages;
  22269. }
  22270. public function getUnacceptableFixedPackages()
  22271. {
  22272. return $this->unacceptableFixedPackages;
  22273. }
  22274. public function setPackages(array $packages)
  22275. {
  22276. $this->packages = $packages;
  22277. }
  22278. public function setUnacceptableFixedPackages(array $packages)
  22279. {
  22280. $this->unacceptableFixedPackages = $packages;
  22281. }
  22282. }
  22283. <?php
  22284. namespace Composer\Question;
  22285. use Symfony\Component\Console\Exception\InvalidArgumentException;
  22286. use Symfony\Component\Console\Question\Question;
  22287. class StrictConfirmationQuestion extends Question
  22288. {
  22289. private $trueAnswerRegex;
  22290. private $falseAnswerRegex;
  22291. public function __construct($question, $default = true, $trueAnswerRegex = '/^y(?:es)?$/i', $falseAnswerRegex = '/^no?$/i')
  22292. {
  22293. parent::__construct($question, (bool) $default);
  22294. $this->trueAnswerRegex = $trueAnswerRegex;
  22295. $this->falseAnswerRegex = $falseAnswerRegex;
  22296. $this->setNormalizer($this->getDefaultNormalizer());
  22297. $this->setValidator($this->getDefaultValidator());
  22298. }
  22299. private function getDefaultNormalizer()
  22300. {
  22301. $default = $this->getDefault();
  22302. $trueRegex = $this->trueAnswerRegex;
  22303. $falseRegex = $this->falseAnswerRegex;
  22304. return function ($answer) use ($default, $trueRegex, $falseRegex) {
  22305. if (is_bool($answer)) {
  22306. return $answer;
  22307. }
  22308. if (empty($answer) && !empty($default)) {
  22309. return $default;
  22310. }
  22311. if (preg_match($trueRegex, $answer)) {
  22312. return true;
  22313. }
  22314. if (preg_match($falseRegex, $answer)) {
  22315. return false;
  22316. }
  22317. return null;
  22318. };
  22319. }
  22320. private function getDefaultValidator()
  22321. {
  22322. return function ($answer) {
  22323. if (!is_bool($answer)) {
  22324. throw new InvalidArgumentException('Please answer yes, y, no, or n.');
  22325. }
  22326. return $answer;
  22327. };
  22328. }
  22329. }
  22330. <?php
  22331. namespace Composer\Repository;
  22332. use Composer\Package\AliasPackage;
  22333. use Composer\Package\PackageInterface;
  22334. use Composer\Package\CompletePackageInterface;
  22335. use Composer\Package\Version\VersionParser;
  22336. use Composer\Package\Version\StabilityFilter;
  22337. use Composer\Semver\Constraint\ConstraintInterface;
  22338. use Composer\Semver\Constraint\Constraint;
  22339. class ArrayRepository implements RepositoryInterface
  22340. {
  22341. protected $packages;
  22342. protected $packageMap;
  22343. public function __construct(array $packages = array())
  22344. {
  22345. foreach ($packages as $package) {
  22346. $this->addPackage($package);
  22347. }
  22348. }
  22349. public function getRepoName()
  22350. {
  22351. return 'array repo (defining '.$this->count().' package'.($this->count() > 1 ? 's' : '').')';
  22352. }
  22353. public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  22354. {
  22355. $packages = $this->getPackages();
  22356. $result = array();
  22357. $namesFound = array();
  22358. foreach ($packages as $package) {
  22359. if (array_key_exists($package->getName(), $packageMap)) {
  22360. if (
  22361. (!$packageMap[$package->getName()] || $packageMap[$package->getName()]->matches(new Constraint('==', $package->getVersion())))
  22362. && StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, $package->getNames(), $package->getStability())
  22363. && !isset($alreadyLoaded[$package->getName()][$package->getVersion()])
  22364. ) {
  22365. $result[spl_object_hash($package)] = $package;
  22366. if ($package instanceof AliasPackage && !isset($result[spl_object_hash($package->getAliasOf())])) {
  22367. $result[spl_object_hash($package->getAliasOf())] = $package->getAliasOf();
  22368. }
  22369. }
  22370. $namesFound[$package->getName()] = true;
  22371. }
  22372. }
  22373. foreach ($packages as $package) {
  22374. if ($package instanceof AliasPackage) {
  22375. if (isset($result[spl_object_hash($package->getAliasOf())])) {
  22376. $result[spl_object_hash($package)] = $package;
  22377. }
  22378. }
  22379. }
  22380. return array('namesFound' => array_keys($namesFound), 'packages' => $result);
  22381. }
  22382. public function findPackage($name, $constraint)
  22383. {
  22384. $name = strtolower($name);
  22385. if (!$constraint instanceof ConstraintInterface) {
  22386. $versionParser = new VersionParser();
  22387. $constraint = $versionParser->parseConstraints($constraint);
  22388. }
  22389. foreach ($this->getPackages() as $package) {
  22390. if ($name === $package->getName()) {
  22391. $pkgConstraint = new Constraint('==', $package->getVersion());
  22392. if ($constraint->matches($pkgConstraint)) {
  22393. return $package;
  22394. }
  22395. }
  22396. }
  22397. return null;
  22398. }
  22399. public function findPackages($name, $constraint = null)
  22400. {
  22401. $name = strtolower($name);
  22402. $packages = array();
  22403. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  22404. $versionParser = new VersionParser();
  22405. $constraint = $versionParser->parseConstraints($constraint);
  22406. }
  22407. foreach ($this->getPackages() as $package) {
  22408. if ($name === $package->getName()) {
  22409. if (null === $constraint || $constraint->matches(new Constraint('==', $package->getVersion()))) {
  22410. $packages[] = $package;
  22411. }
  22412. }
  22413. }
  22414. return $packages;
  22415. }
  22416. public function search($query, $mode = 0, $type = null)
  22417. {
  22418. $regex = '{(?:'.implode('|', preg_split('{\s+}', $query)).')}i';
  22419. $matches = array();
  22420. foreach ($this->getPackages() as $package) {
  22421. $name = $package->getName();
  22422. if (isset($matches[$name])) {
  22423. continue;
  22424. }
  22425. if (preg_match($regex, $name)
  22426. || ($mode === self::SEARCH_FULLTEXT && $package instanceof CompletePackageInterface && preg_match($regex, implode(' ', (array) $package->getKeywords()) . ' ' . $package->getDescription()))
  22427. ) {
  22428. if (null !== $type && $package->getType() !== $type) {
  22429. continue;
  22430. }
  22431. $matches[$name] = array(
  22432. 'name' => $package->getPrettyName(),
  22433. 'description' => $package instanceof CompletePackageInterface ? $package->getDescription() : null,
  22434. );
  22435. }
  22436. }
  22437. return array_values($matches);
  22438. }
  22439. public function hasPackage(PackageInterface $package)
  22440. {
  22441. if ($this->packageMap === null) {
  22442. $this->packageMap = array();
  22443. foreach ($this->getPackages() as $repoPackage) {
  22444. $this->packageMap[$repoPackage->getUniqueName()] = $repoPackage;
  22445. }
  22446. }
  22447. return isset($this->packageMap[$package->getUniqueName()]);
  22448. }
  22449. public function addPackage(PackageInterface $package)
  22450. {
  22451. if (null === $this->packages) {
  22452. $this->initialize();
  22453. }
  22454. $package->setRepository($this);
  22455. $this->packages[] = $package;
  22456. if ($package instanceof AliasPackage) {
  22457. $aliasedPackage = $package->getAliasOf();
  22458. if (null === $aliasedPackage->getRepository()) {
  22459. $this->addPackage($aliasedPackage);
  22460. }
  22461. }
  22462. $this->packageMap = null;
  22463. }
  22464. public function getProviders($packageName)
  22465. {
  22466. $result = array();
  22467. foreach ($this->getPackages() as $candidate) {
  22468. if (isset($result[$candidate->getName()])) {
  22469. continue;
  22470. }
  22471. foreach ($candidate->getProvides() as $link) {
  22472. if ($packageName === $link->getTarget()) {
  22473. $result[$candidate->getName()] = array(
  22474. 'name' => $candidate->getName(),
  22475. 'description' => $candidate->getDescription(),
  22476. 'type' => $candidate->getType(),
  22477. );
  22478. continue 2;
  22479. }
  22480. }
  22481. }
  22482. return $result;
  22483. }
  22484. protected function createAliasPackage(PackageInterface $package, $alias, $prettyAlias)
  22485. {
  22486. return new AliasPackage($package instanceof AliasPackage ? $package->getAliasOf() : $package, $alias, $prettyAlias);
  22487. }
  22488. public function removePackage(PackageInterface $package)
  22489. {
  22490. $packageId = $package->getUniqueName();
  22491. foreach ($this->getPackages() as $key => $repoPackage) {
  22492. if ($packageId === $repoPackage->getUniqueName()) {
  22493. array_splice($this->packages, $key, 1);
  22494. $this->packageMap = null;
  22495. return;
  22496. }
  22497. }
  22498. }
  22499. public function getPackages()
  22500. {
  22501. if (null === $this->packages) {
  22502. $this->initialize();
  22503. }
  22504. return $this->packages;
  22505. }
  22506. public function count()
  22507. {
  22508. if (null === $this->packages) {
  22509. $this->initialize();
  22510. }
  22511. return count($this->packages);
  22512. }
  22513. protected function initialize()
  22514. {
  22515. $this->packages = array();
  22516. }
  22517. }
  22518. <?php
  22519. namespace Composer\Repository;
  22520. use Composer\IO\IOInterface;
  22521. use Composer\Json\JsonFile;
  22522. use Composer\Package\Loader\ArrayLoader;
  22523. use Composer\Package\Loader\LoaderInterface;
  22524. use Composer\Util\Tar;
  22525. use Composer\Util\Zip;
  22526. class ArtifactRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  22527. {
  22528. protected $loader;
  22529. protected $lookup;
  22530. protected $repoConfig;
  22531. private $io;
  22532. public function __construct(array $repoConfig, IOInterface $io)
  22533. {
  22534. parent::__construct();
  22535. if (!extension_loaded('zip')) {
  22536. throw new \RuntimeException('The artifact repository requires PHP\'s zip extension');
  22537. }
  22538. $this->loader = new ArrayLoader();
  22539. $this->lookup = $repoConfig['url'];
  22540. $this->io = $io;
  22541. $this->repoConfig = $repoConfig;
  22542. }
  22543. public function getRepoName()
  22544. {
  22545. return 'artifact repo ('.$this->lookup.')';
  22546. }
  22547. public function getRepoConfig()
  22548. {
  22549. return $this->repoConfig;
  22550. }
  22551. protected function initialize()
  22552. {
  22553. parent::initialize();
  22554. $this->scanDirectory($this->lookup);
  22555. }
  22556. private function scanDirectory($path)
  22557. {
  22558. $io = $this->io;
  22559. $directory = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
  22560. $iterator = new \RecursiveIteratorIterator($directory);
  22561. $regex = new \RegexIterator($iterator, '/^.+\.(zip|phar|tar|gz|tgz)$/i');
  22562. foreach ($regex as $file) {
  22563. if (!$file->isFile()) {
  22564. continue;
  22565. }
  22566. $package = $this->getComposerInformation($file);
  22567. if (!$package) {
  22568. $io->writeError("File <comment>{$file->getBasename()}</comment> doesn't seem to hold a package", true, IOInterface::VERBOSE);
  22569. continue;
  22570. }
  22571. $template = 'Found package <info>%s</info> (<comment>%s</comment>) in file <info>%s</info>';
  22572. $io->writeError(sprintf($template, $package->getName(), $package->getPrettyVersion(), $file->getBasename()), true, IOInterface::VERBOSE);
  22573. $this->addPackage($package);
  22574. }
  22575. }
  22576. private function getComposerInformation(\SplFileInfo $file)
  22577. {
  22578. $json = null;
  22579. $fileType = null;
  22580. $fileExtension = pathinfo($file->getPathname(), PATHINFO_EXTENSION);
  22581. if (in_array($fileExtension, array('gz', 'tar', 'tgz'), true)) {
  22582. $fileType = 'tar';
  22583. } else if ($fileExtension === 'zip') {
  22584. $fileType = 'zip';
  22585. } else {
  22586. throw new \RuntimeException('Files with "'.$fileExtension.'" extensions aren\'t supported. Only ZIP and TAR/TAR.GZ/TGZ archives are supported.');
  22587. }
  22588. try {
  22589. if ($fileType === 'tar') {
  22590. $json = Tar::getComposerJson($file->getPathname());
  22591. } else {
  22592. $json = Zip::getComposerJson($file->getPathname());
  22593. }
  22594. } catch (\Exception $exception) {
  22595. $this->io->write('Failed loading package '.$file->getPathname().': '.$exception->getMessage(), false, IOInterface::VERBOSE);
  22596. }
  22597. if (null === $json) {
  22598. return false;
  22599. }
  22600. $package = JsonFile::parseJson($json, $file->getPathname().'#composer.json');
  22601. $package['dist'] = array(
  22602. 'type' => $fileType,
  22603. 'url' => strtr($file->getPathname(), '\\', '/'),
  22604. 'shasum' => sha1_file($file->getRealPath()),
  22605. );
  22606. try {
  22607. $package = $this->loader->load($package);
  22608. } catch (\UnexpectedValueException $e) {
  22609. throw new \UnexpectedValueException('Failed loading package in '.$file.': '.$e->getMessage(), 0, $e);
  22610. }
  22611. return $package;
  22612. }
  22613. }
  22614. <?php
  22615. namespace Composer\Repository;
  22616. use Composer\Package\BasePackage;
  22617. use Composer\Package\Loader\ArrayLoader;
  22618. use Composer\Package\PackageInterface;
  22619. use Composer\Package\AliasPackage;
  22620. use Composer\Package\Version\VersionParser;
  22621. use Composer\Package\Version\StabilityFilter;
  22622. use Composer\Json\JsonFile;
  22623. use Composer\Cache;
  22624. use Composer\Config;
  22625. use Composer\IO\IOInterface;
  22626. use Composer\Semver\CompilingMatcher;
  22627. use Composer\Util\HttpDownloader;
  22628. use Composer\Util\Loop;
  22629. use Composer\Plugin\PluginEvents;
  22630. use Composer\Plugin\PreFileDownloadEvent;
  22631. use Composer\EventDispatcher\EventDispatcher;
  22632. use Composer\Downloader\TransportException;
  22633. use Composer\Semver\Constraint\ConstraintInterface;
  22634. use Composer\Semver\Constraint\Constraint;
  22635. use Composer\Semver\Constraint\MatchAllConstraint;
  22636. use Composer\Util\Http\Response;
  22637. use Composer\Util\MetadataMinifier;
  22638. use Composer\Util\Url;
  22639. class ComposerRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  22640. {
  22641. private $repoConfig;
  22642. private $options;
  22643. private $url;
  22644. private $baseUrl;
  22645. private $io;
  22646. private $httpDownloader;
  22647. private $loop;
  22648. protected $cache;
  22649. protected $notifyUrl;
  22650. protected $searchUrl;
  22651. protected $providersApiUrl;
  22652. protected $hasProviders = false;
  22653. protected $providersUrl;
  22654. protected $listUrl;
  22655. protected $hasAvailablePackageList = false;
  22656. protected $availablePackages;
  22657. protected $availablePackagePatterns;
  22658. protected $lazyProvidersUrl;
  22659. protected $providerListing;
  22660. protected $loader;
  22661. private $allowSslDowngrade = false;
  22662. private $eventDispatcher;
  22663. private $sourceMirrors;
  22664. private $distMirrors;
  22665. private $degradedMode = false;
  22666. private $rootData;
  22667. private $hasPartialPackages;
  22668. private $partialPackagesByName;
  22669. public $freshMetadataUrls = array();
  22670. public $packagesNotFoundCache = array();
  22671. public $versionParser;
  22672. public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null)
  22673. {
  22674. parent::__construct();
  22675. if (!preg_match('{^[\w.]+\??://}', $repoConfig['url'])) {
  22676. $repoConfig['url'] = 'http://'.$repoConfig['url'];
  22677. }
  22678. $repoConfig['url'] = rtrim($repoConfig['url'], '/');
  22679. if (strpos($repoConfig['url'], 'https?') === 0) {
  22680. $repoConfig['url'] = (extension_loaded('openssl') ? 'https' : 'http') . substr($repoConfig['url'], 6);
  22681. }
  22682. $urlBits = parse_url($repoConfig['url']);
  22683. if ($urlBits === false || empty($urlBits['scheme'])) {
  22684. throw new \UnexpectedValueException('Invalid url given for Composer repository: '.$repoConfig['url']);
  22685. }
  22686. if (!isset($repoConfig['options'])) {
  22687. $repoConfig['options'] = array();
  22688. }
  22689. if (isset($repoConfig['allow_ssl_downgrade']) && true === $repoConfig['allow_ssl_downgrade']) {
  22690. $this->allowSslDowngrade = true;
  22691. }
  22692. $this->options = $repoConfig['options'];
  22693. $this->url = $repoConfig['url'];
  22694. if (preg_match('{^(?P<proto>https?)://packagist\.org/?$}i', $this->url, $match)) {
  22695. $this->url = $match['proto'].'://repo.packagist.org';
  22696. }
  22697. $this->baseUrl = rtrim(preg_replace('{(?:/[^/\\\\]+\.json)?(?:[?#].*)?$}', '', $this->url), '/');
  22698. $this->io = $io;
  22699. $this->cache = new Cache($io, $config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', Url::sanitize($this->url)), 'a-z0-9.$~');
  22700. $this->cache->setReadOnly($config->get('cache-read-only'));
  22701. $this->versionParser = new VersionParser();
  22702. $this->loader = new ArrayLoader($this->versionParser);
  22703. $this->httpDownloader = $httpDownloader;
  22704. $this->eventDispatcher = $eventDispatcher;
  22705. $this->repoConfig = $repoConfig;
  22706. $this->loop = new Loop($this->httpDownloader);
  22707. }
  22708. public function getRepoName()
  22709. {
  22710. return 'composer repo ('.Url::sanitize($this->url).')';
  22711. }
  22712. public function getRepoConfig()
  22713. {
  22714. return $this->repoConfig;
  22715. }
  22716. public function findPackage($name, $constraint)
  22717. {
  22718. $hasProviders = $this->hasProviders();
  22719. $name = strtolower($name);
  22720. if (!$constraint instanceof ConstraintInterface) {
  22721. $constraint = $this->versionParser->parseConstraints($constraint);
  22722. }
  22723. if ($this->lazyProvidersUrl) {
  22724. if ($this->hasPartialPackages() && isset($this->partialPackagesByName[$name])) {
  22725. return $this->filterPackages($this->whatProvides($name), $constraint, true);
  22726. }
  22727. if ($this->hasAvailablePackageList && !$this->lazyProvidersRepoContains($name)) {
  22728. return;
  22729. }
  22730. $packages = $this->loadAsyncPackages(array($name => $constraint));
  22731. return reset($packages['packages']);
  22732. }
  22733. if ($hasProviders) {
  22734. foreach ($this->getProviderNames() as $providerName) {
  22735. if ($name === $providerName) {
  22736. return $this->filterPackages($this->whatProvides($providerName), $constraint, true);
  22737. }
  22738. }
  22739. return;
  22740. }
  22741. return parent::findPackage($name, $constraint);
  22742. }
  22743. public function findPackages($name, $constraint = null)
  22744. {
  22745. $hasProviders = $this->hasProviders();
  22746. $name = strtolower($name);
  22747. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  22748. $constraint = $this->versionParser->parseConstraints($constraint);
  22749. }
  22750. if ($this->lazyProvidersUrl) {
  22751. if ($this->hasPartialPackages() && isset($this->partialPackagesByName[$name])) {
  22752. return $this->filterPackages($this->whatProvides($name), $constraint);
  22753. }
  22754. if ($this->hasAvailablePackageList && !$this->lazyProvidersRepoContains($name)) {
  22755. return array();
  22756. }
  22757. $result = $this->loadAsyncPackages(array($name => $constraint));
  22758. return $result['packages'];
  22759. }
  22760. if ($hasProviders) {
  22761. foreach ($this->getProviderNames() as $providerName) {
  22762. if ($name === $providerName) {
  22763. return $this->filterPackages($this->whatProvides($providerName), $constraint);
  22764. }
  22765. }
  22766. return array();
  22767. }
  22768. return parent::findPackages($name, $constraint);
  22769. }
  22770. private function filterPackages(array $packages, $constraint = null, $returnFirstMatch = false)
  22771. {
  22772. if (null === $constraint) {
  22773. if ($returnFirstMatch) {
  22774. return reset($packages);
  22775. }
  22776. return $packages;
  22777. }
  22778. $filteredPackages = array();
  22779. foreach ($packages as $package) {
  22780. $pkgConstraint = new Constraint('==', $package->getVersion());
  22781. if ($constraint->matches($pkgConstraint)) {
  22782. if ($returnFirstMatch) {
  22783. return $package;
  22784. }
  22785. $filteredPackages[] = $package;
  22786. }
  22787. }
  22788. if ($returnFirstMatch) {
  22789. return null;
  22790. }
  22791. return $filteredPackages;
  22792. }
  22793. public function getPackages()
  22794. {
  22795. $hasProviders = $this->hasProviders();
  22796. if ($this->lazyProvidersUrl) {
  22797. if (is_array($this->availablePackages) && !$this->availablePackagePatterns) {
  22798. $packageMap = array();
  22799. foreach ($this->availablePackages as $name) {
  22800. $packageMap[$name] = new MatchAllConstraint();
  22801. }
  22802. $result = $this->loadAsyncPackages($packageMap);
  22803. return array_values($result['packages']);
  22804. }
  22805. if ($this->hasPartialPackages()) {
  22806. return array_values($this->partialPackagesByName);
  22807. }
  22808. 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.');
  22809. }
  22810. if ($hasProviders) {
  22811. throw new \LogicException('Composer repositories that have providers can not load the complete list of packages, use getPackageNames instead.');
  22812. }
  22813. return parent::getPackages();
  22814. }
  22815. public function getPackageNames($packageFilter = null)
  22816. {
  22817. $hasProviders = $this->hasProviders();
  22818. $packageFilterCb = function ($name) {
  22819. return true;
  22820. };
  22821. if (null !== $packageFilter) {
  22822. $packageFilterRegex = '{^'.str_replace('\\*', '.*?', preg_quote($packageFilter)).'$}i';
  22823. $packageFilterCb = function ($name) use ($packageFilterRegex) {
  22824. return (bool) preg_match($packageFilterRegex, $name);
  22825. };
  22826. }
  22827. if ($this->lazyProvidersUrl) {
  22828. if (is_array($this->availablePackages)) {
  22829. return array_filter(array_keys($this->availablePackages), $packageFilterCb);
  22830. }
  22831. if ($this->listUrl) {
  22832. $url = $this->listUrl;
  22833. if ($packageFilter) {
  22834. $url .= '?filter='.urlencode($packageFilter);
  22835. }
  22836. $result = $this->httpDownloader->get($url, $this->options)->decodeJson();
  22837. return $result['packageNames'];
  22838. }
  22839. if ($this->hasPartialPackages()) {
  22840. return array_filter(array_keys($this->partialPackagesByName), $packageFilterCb);
  22841. }
  22842. return array();
  22843. }
  22844. if ($hasProviders) {
  22845. return array_filter($this->getProviderNames(), $packageFilterCb);
  22846. }
  22847. $names = array();
  22848. foreach ($this->getPackages() as $package) {
  22849. if ($packageFilterCb($package->getName())) {
  22850. $names[] = $package->getPrettyName();
  22851. }
  22852. }
  22853. return $names;
  22854. }
  22855. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  22856. {
  22857. $hasProviders = $this->hasProviders();
  22858. if (!$hasProviders && !$this->hasPartialPackages() && !$this->lazyProvidersUrl) {
  22859. return parent::loadPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  22860. }
  22861. $packages = array();
  22862. $namesFound = array();
  22863. if ($hasProviders || $this->hasPartialPackages()) {
  22864. foreach ($packageNameMap as $name => $constraint) {
  22865. $matches = array();
  22866. if (!$hasProviders && !isset($this->partialPackagesByName[$name])) {
  22867. continue;
  22868. }
  22869. $candidates = $this->whatProvides($name, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  22870. foreach ($candidates as $candidate) {
  22871. if ($candidate->getName() !== $name) {
  22872. throw new \LogicException('whatProvides should never return a package with a different name than the requested one');
  22873. }
  22874. $namesFound[$name] = true;
  22875. if (!$constraint || $constraint->matches(new Constraint('==', $candidate->getVersion()))) {
  22876. $matches[spl_object_hash($candidate)] = $candidate;
  22877. if ($candidate instanceof AliasPackage && !isset($matches[spl_object_hash($candidate->getAliasOf())])) {
  22878. $matches[spl_object_hash($candidate->getAliasOf())] = $candidate->getAliasOf();
  22879. }
  22880. }
  22881. }
  22882. foreach ($candidates as $candidate) {
  22883. if ($candidate instanceof AliasPackage) {
  22884. if (isset($matches[spl_object_hash($candidate->getAliasOf())])) {
  22885. $matches[spl_object_hash($candidate)] = $candidate;
  22886. }
  22887. }
  22888. }
  22889. $packages = array_merge($packages, $matches);
  22890. unset($packageNameMap[$name]);
  22891. }
  22892. }
  22893. if ($this->lazyProvidersUrl && count($packageNameMap)) {
  22894. if ($this->hasAvailablePackageList) {
  22895. foreach ($packageNameMap as $name => $constraint) {
  22896. if (!$this->lazyProvidersRepoContains(strtolower($name))) {
  22897. unset($packageNameMap[$name]);
  22898. }
  22899. }
  22900. }
  22901. $result = $this->loadAsyncPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  22902. $packages = array_merge($packages, $result['packages']);
  22903. $namesFound = array_merge($namesFound, $result['namesFound']);
  22904. }
  22905. return array('namesFound' => array_keys($namesFound), 'packages' => $packages);
  22906. }
  22907. public function search($query, $mode = 0, $type = null)
  22908. {
  22909. $this->loadRootServerFile();
  22910. if ($this->searchUrl && $mode === self::SEARCH_FULLTEXT) {
  22911. $url = str_replace(array('%query%', '%type%'), array($query, $type), $this->searchUrl);
  22912. $search = $this->httpDownloader->get($url, $this->options)->decodeJson();
  22913. if (empty($search['results'])) {
  22914. return array();
  22915. }
  22916. $results = array();
  22917. foreach ($search['results'] as $result) {
  22918. if (empty($result['virtual'])) {
  22919. $results[] = $result;
  22920. }
  22921. }
  22922. return $results;
  22923. }
  22924. if ($this->hasProviders() || $this->lazyProvidersUrl) {
  22925. $results = array();
  22926. $regex = '{(?:'.implode('|', preg_split('{\s+}', $query)).')}i';
  22927. foreach ($this->getPackageNames() as $name) {
  22928. if (preg_match($regex, $name)) {
  22929. $results[] = array('name' => $name);
  22930. }
  22931. }
  22932. return $results;
  22933. }
  22934. return parent::search($query, $mode);
  22935. }
  22936. public function getProviders($packageName)
  22937. {
  22938. $this->loadRootServerFile();
  22939. $result = array();
  22940. if ($this->providersApiUrl) {
  22941. $apiResult = $this->httpDownloader->get(str_replace('%package%', $packageName, $this->providersApiUrl), $this->options)->decodeJson();
  22942. foreach ($apiResult['providers'] as $provider) {
  22943. $result[$provider['name']] = $provider;
  22944. }
  22945. return $result;
  22946. }
  22947. if ($this->hasPartialPackages()) {
  22948. foreach ($this->partialPackagesByName as $versions) {
  22949. foreach ($versions as $candidate) {
  22950. if (isset($result[$candidate['name']]) || !isset($candidate['provide'][$packageName])) {
  22951. continue;
  22952. }
  22953. $result[$candidate['name']] = array(
  22954. 'name' => $candidate['name'],
  22955. 'description' => isset($candidate['description']) ? $candidate['description'] : '',
  22956. 'type' => isset($candidate['type']) ? $candidate['type'] : '',
  22957. );
  22958. }
  22959. }
  22960. }
  22961. if ($this->packages) {
  22962. $result = array_merge($result, parent::getProviders($packageName));
  22963. }
  22964. return $result;
  22965. }
  22966. private function getProviderNames()
  22967. {
  22968. $this->loadRootServerFile();
  22969. if (null === $this->providerListing) {
  22970. $this->loadProviderListings($this->loadRootServerFile());
  22971. }
  22972. if ($this->lazyProvidersUrl) {
  22973. return array();
  22974. }
  22975. if ($this->providersUrl) {
  22976. return array_keys($this->providerListing);
  22977. }
  22978. return array();
  22979. }
  22980. private function configurePackageTransportOptions(PackageInterface $package)
  22981. {
  22982. foreach ($package->getDistUrls() as $url) {
  22983. if (strpos($url, $this->baseUrl) === 0) {
  22984. $package->setTransportOptions($this->options);
  22985. return;
  22986. }
  22987. }
  22988. }
  22989. private function hasProviders()
  22990. {
  22991. $this->loadRootServerFile();
  22992. return $this->hasProviders;
  22993. }
  22994. private function whatProvides($name, array $acceptableStabilities = null, array $stabilityFlags = null, array $alreadyLoaded = array())
  22995. {
  22996. if (!$this->hasPartialPackages() || !isset($this->partialPackagesByName[$name])) {
  22997. if (PlatformRepository::isPlatformPackage($name) || '__root__' === $name) {
  22998. return array();
  22999. }
  23000. if (null === $this->providerListing) {
  23001. $this->loadProviderListings($this->loadRootServerFile());
  23002. }
  23003. $useLastModifiedCheck = false;
  23004. if ($this->lazyProvidersUrl && !isset($this->providerListing[$name])) {
  23005. $hash = null;
  23006. $url = str_replace('%package%', $name, $this->lazyProvidersUrl);
  23007. $cacheKey = 'provider-'.strtr($name, '/', '$').'.json';
  23008. $useLastModifiedCheck = true;
  23009. } elseif ($this->providersUrl) {
  23010. if (!isset($this->providerListing[$name])) {
  23011. return array();
  23012. }
  23013. $hash = $this->providerListing[$name]['sha256'];
  23014. $url = str_replace(array('%package%', '%hash%'), array($name, $hash), $this->providersUrl);
  23015. $cacheKey = 'provider-'.strtr($name, '/', '$').'.json';
  23016. } else {
  23017. return array();
  23018. }
  23019. $packages = null;
  23020. if ($cacheKey) {
  23021. if (!$useLastModifiedCheck && $hash && $this->cache->sha256($cacheKey) === $hash) {
  23022. $packages = json_decode($this->cache->read($cacheKey), true);
  23023. } elseif ($useLastModifiedCheck) {
  23024. if ($contents = $this->cache->read($cacheKey)) {
  23025. $contents = json_decode($contents, true);
  23026. if (isset($alreadyLoaded[$name])) {
  23027. $packages = $contents;
  23028. } elseif (isset($contents['last-modified'])) {
  23029. $response = $this->fetchFileIfLastModified($url, $cacheKey, $contents['last-modified']);
  23030. $packages = true === $response ? $contents : $response;
  23031. }
  23032. }
  23033. }
  23034. }
  23035. if (!$packages) {
  23036. try {
  23037. $packages = $this->fetchFile($url, $cacheKey, $hash, $useLastModifiedCheck);
  23038. } catch (TransportException $e) {
  23039. if ($this->lazyProvidersUrl && in_array($e->getStatusCode(), array(404, 499), true)) {
  23040. $packages = array('packages' => array());
  23041. if ($e->getStatusCode() === 499) {
  23042. $this->io->error('<warning>' . $e->getMessage() . '</warning>');
  23043. }
  23044. } else {
  23045. throw $e;
  23046. }
  23047. }
  23048. }
  23049. $loadingPartialPackage = false;
  23050. } else {
  23051. $packages = array('packages' => array('versions' => $this->partialPackagesByName[$name]));
  23052. $loadingPartialPackage = true;
  23053. }
  23054. $result = array();
  23055. $versionsToLoad = array();
  23056. foreach ($packages['packages'] as $versions) {
  23057. foreach ($versions as $version) {
  23058. $normalizedName = strtolower($version['name']);
  23059. if ($normalizedName !== $name) {
  23060. continue;
  23061. }
  23062. if (!$loadingPartialPackage && $this->hasPartialPackages() && isset($this->partialPackagesByName[$normalizedName])) {
  23063. continue;
  23064. }
  23065. if (!isset($versionsToLoad[$version['uid']])) {
  23066. if (!isset($version['version_normalized'])) {
  23067. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  23068. } elseif ($version['version_normalized'] === VersionParser::DEFAULT_BRANCH_ALIAS) {
  23069. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  23070. }
  23071. if (isset($alreadyLoaded[$name][$version['version_normalized']])) {
  23072. continue;
  23073. }
  23074. if ($this->isVersionAcceptable(null, $normalizedName, $version, $acceptableStabilities, $stabilityFlags)) {
  23075. $versionsToLoad[$version['uid']] = $version;
  23076. }
  23077. }
  23078. }
  23079. }
  23080. $loadedPackages = $this->createPackages($versionsToLoad);
  23081. $uids = array_keys($versionsToLoad);
  23082. foreach ($loadedPackages as $index => $package) {
  23083. $package->setRepository($this);
  23084. $uid = $uids[$index];
  23085. if ($package instanceof AliasPackage) {
  23086. $aliased = $package->getAliasOf();
  23087. $aliased->setRepository($this);
  23088. $result[$uid] = $aliased;
  23089. $result[$uid.'-alias'] = $package;
  23090. } else {
  23091. $result[$uid] = $package;
  23092. }
  23093. }
  23094. return $result;
  23095. }
  23096. protected function initialize()
  23097. {
  23098. parent::initialize();
  23099. $repoData = $this->loadDataFromServer();
  23100. foreach ($this->createPackages($repoData) as $package) {
  23101. $this->addPackage($package);
  23102. }
  23103. }
  23104. public function addPackage(PackageInterface $package)
  23105. {
  23106. parent::addPackage($package);
  23107. $this->configurePackageTransportOptions($package);
  23108. }
  23109. private function loadAsyncPackages(array $packageNames, array $acceptableStabilities = null, array $stabilityFlags = null, array $alreadyLoaded = array())
  23110. {
  23111. $this->loadRootServerFile();
  23112. $packages = array();
  23113. $namesFound = array();
  23114. $promises = array();
  23115. $repo = $this;
  23116. if (!$this->lazyProvidersUrl) {
  23117. throw new \LogicException('loadAsyncPackages only supports v2 protocol composer repos with a metadata-url');
  23118. }
  23119. foreach ($packageNames as $name => $constraint) {
  23120. if ($acceptableStabilities === null || $stabilityFlags === null || StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, array($name), 'dev')) {
  23121. $packageNames[$name.'~dev'] = $constraint;
  23122. }
  23123. if (isset($acceptableStabilities['dev']) && count($acceptableStabilities) === 1 && count($stabilityFlags) === 0) {
  23124. unset($packageNames[$name]);
  23125. }
  23126. }
  23127. foreach ($packageNames as $name => $constraint) {
  23128. $name = strtolower($name);
  23129. $realName = preg_replace('{~dev$}', '', $name);
  23130. if (PlatformRepository::isPlatformPackage($realName) || '__root__' === $realName) {
  23131. continue;
  23132. }
  23133. $url = str_replace('%package%', $name, $this->lazyProvidersUrl);
  23134. $cacheKey = 'provider-'.strtr($name, '/', '~').'.json';
  23135. $lastModified = null;
  23136. if ($contents = $this->cache->read($cacheKey)) {
  23137. $contents = json_decode($contents, true);
  23138. $lastModified = isset($contents['last-modified']) ? $contents['last-modified'] : null;
  23139. }
  23140. $promises[] = $this->asyncFetchFile($url, $cacheKey, $lastModified)
  23141. ->then(function ($response) use (&$packages, &$namesFound, $contents, $realName, $constraint, $repo, $acceptableStabilities, $stabilityFlags, $alreadyLoaded) {
  23142. if (true === $response) {
  23143. $response = $contents;
  23144. }
  23145. if (!isset($response['packages'][$realName])) {
  23146. return;
  23147. }
  23148. $versions = $response['packages'][$realName];
  23149. if (isset($response['minified']) && $response['minified'] === 'composer/2.0') {
  23150. $versions = MetadataMinifier::expand($versions);
  23151. }
  23152. $namesFound[$realName] = true;
  23153. $versionsToLoad = array();
  23154. foreach ($versions as $version) {
  23155. if (!isset($version['version_normalized'])) {
  23156. $version['version_normalized'] = $repo->versionParser->normalize($version['version']);
  23157. } elseif ($version['version_normalized'] === VersionParser::DEFAULT_BRANCH_ALIAS) {
  23158. $version['version_normalized'] = $repo->versionParser->normalize($version['version']);
  23159. }
  23160. if (isset($alreadyLoaded[$realName][$version['version_normalized']])) {
  23161. continue;
  23162. }
  23163. if ($repo->isVersionAcceptable($constraint, $realName, $version, $acceptableStabilities, $stabilityFlags)) {
  23164. $versionsToLoad[] = $version;
  23165. }
  23166. }
  23167. $loadedPackages = $repo->createPackages($versionsToLoad);
  23168. foreach ($loadedPackages as $package) {
  23169. $package->setRepository($repo);
  23170. $packages[spl_object_hash($package)] = $package;
  23171. if ($package instanceof AliasPackage && !isset($packages[spl_object_hash($package->getAliasOf())])) {
  23172. $package->getAliasOf()->setRepository($repo);
  23173. $packages[spl_object_hash($package->getAliasOf())] = $package->getAliasOf();
  23174. }
  23175. }
  23176. });
  23177. }
  23178. $this->loop->wait($promises);
  23179. return array('namesFound' => $namesFound, 'packages' => $packages);
  23180. }
  23181. public function isVersionAcceptable($constraint, $name, $versionData, array $acceptableStabilities = null, array $stabilityFlags = null)
  23182. {
  23183. $versions = array($versionData['version_normalized']);
  23184. if ($alias = $this->loader->getBranchAlias($versionData)) {
  23185. $versions[] = $alias;
  23186. }
  23187. foreach ($versions as $version) {
  23188. if (null !== $acceptableStabilities && null !== $stabilityFlags && !StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, array($name), VersionParser::parseStability($version))) {
  23189. continue;
  23190. }
  23191. if ($constraint && !CompilingMatcher::match($constraint, Constraint::OP_EQ, $version)) {
  23192. continue;
  23193. }
  23194. return true;
  23195. }
  23196. return false;
  23197. }
  23198. protected function loadRootServerFile()
  23199. {
  23200. if (null !== $this->rootData) {
  23201. return $this->rootData;
  23202. }
  23203. if (!extension_loaded('openssl') && strpos($this->url, 'https') === 0) {
  23204. throw new \RuntimeException('You must enable the openssl extension in your php.ini to load information from '.$this->url);
  23205. }
  23206. $jsonUrlParts = parse_url($this->url);
  23207. if (isset($jsonUrlParts['path']) && false !== strpos($jsonUrlParts['path'], '.json')) {
  23208. $jsonUrl = $this->url;
  23209. } else {
  23210. $jsonUrl = $this->url . '/packages.json';
  23211. }
  23212. $data = $this->fetchFile($jsonUrl, 'packages.json');
  23213. if (!empty($data['notify-batch'])) {
  23214. $this->notifyUrl = $this->canonicalizeUrl($data['notify-batch']);
  23215. } elseif (!empty($data['notify'])) {
  23216. $this->notifyUrl = $this->canonicalizeUrl($data['notify']);
  23217. }
  23218. if (!empty($data['search'])) {
  23219. $this->searchUrl = $this->canonicalizeUrl($data['search']);
  23220. }
  23221. if (!empty($data['mirrors'])) {
  23222. foreach ($data['mirrors'] as $mirror) {
  23223. if (!empty($mirror['git-url'])) {
  23224. $this->sourceMirrors['git'][] = array('url' => $mirror['git-url'], 'preferred' => !empty($mirror['preferred']));
  23225. }
  23226. if (!empty($mirror['hg-url'])) {
  23227. $this->sourceMirrors['hg'][] = array('url' => $mirror['hg-url'], 'preferred' => !empty($mirror['preferred']));
  23228. }
  23229. if (!empty($mirror['dist-url'])) {
  23230. $this->distMirrors[] = array(
  23231. 'url' => $this->canonicalizeUrl($mirror['dist-url']),
  23232. 'preferred' => !empty($mirror['preferred']),
  23233. );
  23234. }
  23235. }
  23236. }
  23237. if (!empty($data['providers-lazy-url'])) {
  23238. $this->lazyProvidersUrl = $this->canonicalizeUrl($data['providers-lazy-url']);
  23239. $this->hasProviders = true;
  23240. $this->hasPartialPackages = !empty($data['packages']) && is_array($data['packages']);
  23241. }
  23242. if (!empty($data['metadata-url'])) {
  23243. $this->lazyProvidersUrl = $this->canonicalizeUrl($data['metadata-url']);
  23244. $this->providersUrl = null;
  23245. $this->hasProviders = false;
  23246. $this->hasPartialPackages = !empty($data['packages']) && is_array($data['packages']);
  23247. $this->allowSslDowngrade = false;
  23248. if (!empty($data['available-packages'])) {
  23249. $availPackages = array_map('strtolower', $data['available-packages']);
  23250. $this->availablePackages = array_combine($availPackages, $availPackages);
  23251. $this->hasAvailablePackageList = true;
  23252. }
  23253. if (!empty($data['available-package-patterns'])) {
  23254. $this->availablePackagePatterns = array_map(function ($pattern) {
  23255. return BasePackage::packageNameToRegexp($pattern);
  23256. }, $data['available-package-patterns']);
  23257. $this->hasAvailablePackageList = true;
  23258. }
  23259. unset($data['providers-url'], $data['providers'], $data['providers-includes']);
  23260. }
  23261. if ($this->allowSslDowngrade) {
  23262. $this->url = str_replace('https://', 'http://', $this->url);
  23263. $this->baseUrl = str_replace('https://', 'http://', $this->baseUrl);
  23264. }
  23265. if (!empty($data['providers-url'])) {
  23266. $this->providersUrl = $this->canonicalizeUrl($data['providers-url']);
  23267. $this->hasProviders = true;
  23268. }
  23269. if (!empty($data['list'])) {
  23270. $this->listUrl = $this->canonicalizeUrl($data['list']);
  23271. }
  23272. if (!empty($data['providers']) || !empty($data['providers-includes'])) {
  23273. $this->hasProviders = true;
  23274. }
  23275. if (!empty($data['providers-api'])) {
  23276. $this->providersApiUrl = $this->canonicalizeUrl($data['providers-api']);
  23277. }
  23278. return $this->rootData = $data;
  23279. }
  23280. private function canonicalizeUrl($url)
  23281. {
  23282. if ('/' === $url[0]) {
  23283. if (preg_match('{^[^:]++://[^/]*+}', $this->url, $matches)) {
  23284. return $matches[0] . $url;
  23285. }
  23286. return $this->url;
  23287. }
  23288. return $url;
  23289. }
  23290. private function loadDataFromServer()
  23291. {
  23292. $data = $this->loadRootServerFile();
  23293. return $this->loadIncludes($data);
  23294. }
  23295. private function hasPartialPackages()
  23296. {
  23297. if ($this->hasPartialPackages && null === $this->partialPackagesByName) {
  23298. $this->initializePartialPackages();
  23299. }
  23300. return $this->hasPartialPackages;
  23301. }
  23302. private function loadProviderListings($data)
  23303. {
  23304. if (isset($data['providers'])) {
  23305. if (!is_array($this->providerListing)) {
  23306. $this->providerListing = array();
  23307. }
  23308. $this->providerListing = array_merge($this->providerListing, $data['providers']);
  23309. }
  23310. if ($this->providersUrl && isset($data['provider-includes'])) {
  23311. $includes = $data['provider-includes'];
  23312. foreach ($includes as $include => $metadata) {
  23313. $url = $this->baseUrl . '/' . str_replace('%hash%', $metadata['sha256'], $include);
  23314. $cacheKey = str_replace(array('%hash%','$'), '', $include);
  23315. if ($this->cache->sha256($cacheKey) === $metadata['sha256']) {
  23316. $includedData = json_decode($this->cache->read($cacheKey), true);
  23317. } else {
  23318. $includedData = $this->fetchFile($url, $cacheKey, $metadata['sha256']);
  23319. }
  23320. $this->loadProviderListings($includedData);
  23321. }
  23322. }
  23323. }
  23324. private function loadIncludes($data)
  23325. {
  23326. $packages = array();
  23327. if (!isset($data['packages']) && !isset($data['includes'])) {
  23328. foreach ($data as $pkg) {
  23329. foreach ($pkg['versions'] as $metadata) {
  23330. $packages[] = $metadata;
  23331. }
  23332. }
  23333. return $packages;
  23334. }
  23335. if (isset($data['packages'])) {
  23336. foreach ($data['packages'] as $package => $versions) {
  23337. foreach ($versions as $version => $metadata) {
  23338. $packages[] = $metadata;
  23339. }
  23340. }
  23341. }
  23342. if (isset($data['includes'])) {
  23343. foreach ($data['includes'] as $include => $metadata) {
  23344. if (isset($metadata['sha1']) && $this->cache->sha1($include) === $metadata['sha1']) {
  23345. $includedData = json_decode($this->cache->read($include), true);
  23346. } else {
  23347. $includedData = $this->fetchFile($include);
  23348. }
  23349. $packages = array_merge($packages, $this->loadIncludes($includedData));
  23350. }
  23351. }
  23352. return $packages;
  23353. }
  23354. public function createPackages(array $packages, $class = 'Composer\Package\CompletePackage')
  23355. {
  23356. if (!$packages) {
  23357. return array();
  23358. }
  23359. try {
  23360. foreach ($packages as &$data) {
  23361. if (!isset($data['notification-url'])) {
  23362. $data['notification-url'] = $this->notifyUrl;
  23363. }
  23364. }
  23365. $packages = $this->loader->loadPackages($packages, $class);
  23366. foreach ($packages as $package) {
  23367. if (isset($this->sourceMirrors[$package->getSourceType()])) {
  23368. $package->setSourceMirrors($this->sourceMirrors[$package->getSourceType()]);
  23369. }
  23370. $package->setDistMirrors($this->distMirrors);
  23371. $this->configurePackageTransportOptions($package);
  23372. }
  23373. return $packages;
  23374. } catch (\Exception $e) {
  23375. throw new \RuntimeException('Could not load packages '.(isset($packages[0]['name']) ? $packages[0]['name'] : json_encode($packages)).' in '.$this->url.': ['.get_class($e).'] '.$e->getMessage(), 0, $e);
  23376. }
  23377. }
  23378. protected function fetchFile($filename, $cacheKey = null, $sha256 = null, $storeLastModifiedTime = false)
  23379. {
  23380. if (null === $cacheKey) {
  23381. $cacheKey = $filename;
  23382. $filename = $this->baseUrl.'/'.$filename;
  23383. }
  23384. if (($pos = strpos($filename, '$')) && preg_match('{^https?://}i', $filename)) {
  23385. $filename = substr($filename, 0, $pos) . '%24' . substr($filename, $pos + 1);
  23386. }
  23387. $retries = 3;
  23388. while ($retries--) {
  23389. try {
  23390. if ($this->eventDispatcher) {
  23391. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata');
  23392. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  23393. $filename = $preFileDownloadEvent->getProcessedUrl();
  23394. }
  23395. $response = $this->httpDownloader->get($filename, $this->options);
  23396. $json = $response->getBody();
  23397. if ($sha256 && $sha256 !== hash('sha256', $json)) {
  23398. if ($this->allowSslDowngrade) {
  23399. $this->url = str_replace('http://', 'https://', $this->url);
  23400. $this->baseUrl = str_replace('http://', 'https://', $this->baseUrl);
  23401. $filename = str_replace('http://', 'https://', $filename);
  23402. }
  23403. if ($retries) {
  23404. usleep(100000);
  23405. continue;
  23406. }
  23407. 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.');
  23408. }
  23409. $data = $response->decodeJson();
  23410. HttpDownloader::outputWarnings($this->io, $this->url, $data);
  23411. if ($cacheKey && !$this->cache->isReadOnly()) {
  23412. if ($storeLastModifiedTime) {
  23413. $lastModifiedDate = $response->getHeader('last-modified');
  23414. if ($lastModifiedDate) {
  23415. $data['last-modified'] = $lastModifiedDate;
  23416. $json = json_encode($data);
  23417. }
  23418. }
  23419. $this->cache->write($cacheKey, $json);
  23420. }
  23421. $response->collect();
  23422. break;
  23423. } catch (\Exception $e) {
  23424. if ($e instanceof \LogicException) {
  23425. throw $e;
  23426. }
  23427. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  23428. throw $e;
  23429. }
  23430. if ($retries) {
  23431. usleep(100000);
  23432. continue;
  23433. }
  23434. if ($e instanceof RepositorySecurityException) {
  23435. throw $e;
  23436. }
  23437. if ($cacheKey && ($contents = $this->cache->read($cacheKey))) {
  23438. if (!$this->degradedMode) {
  23439. $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>');
  23440. }
  23441. $this->degradedMode = true;
  23442. $data = JsonFile::parseJson($contents, $this->cache->getRoot().$cacheKey);
  23443. break;
  23444. }
  23445. throw $e;
  23446. }
  23447. }
  23448. if (!isset($data)) {
  23449. throw new \LogicException("ComposerRepository: Undefined \$data. Please report at https://github.com/composer/composer/issues/new.");
  23450. }
  23451. return $data;
  23452. }
  23453. private function fetchFileIfLastModified($filename, $cacheKey, $lastModifiedTime)
  23454. {
  23455. $retries = 3;
  23456. while ($retries--) {
  23457. try {
  23458. if ($this->eventDispatcher) {
  23459. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata');
  23460. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  23461. $filename = $preFileDownloadEvent->getProcessedUrl();
  23462. }
  23463. $options = $this->options;
  23464. if (isset($options['http']['header'])) {
  23465. $options['http']['header'] = (array) $options['http']['header'];
  23466. }
  23467. $options['http']['header'][] = 'If-Modified-Since: '.$lastModifiedTime;
  23468. $response = $this->httpDownloader->get($filename, $options);
  23469. $json = $response->getBody();
  23470. if ($json === '' && $response->getStatusCode() === 304) {
  23471. return true;
  23472. }
  23473. $data = $response->decodeJson();
  23474. HttpDownloader::outputWarnings($this->io, $this->url, $data);
  23475. $lastModifiedDate = $response->getHeader('last-modified');
  23476. $response->collect();
  23477. if ($lastModifiedDate) {
  23478. $data['last-modified'] = $lastModifiedDate;
  23479. $json = json_encode($data);
  23480. }
  23481. if (!$this->cache->isReadOnly()) {
  23482. $this->cache->write($cacheKey, $json);
  23483. }
  23484. return $data;
  23485. } catch (\Exception $e) {
  23486. if ($e instanceof \LogicException) {
  23487. throw $e;
  23488. }
  23489. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  23490. throw $e;
  23491. }
  23492. if ($retries) {
  23493. usleep(100000);
  23494. continue;
  23495. }
  23496. if (!$this->degradedMode) {
  23497. $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>');
  23498. }
  23499. $this->degradedMode = true;
  23500. return true;
  23501. }
  23502. }
  23503. }
  23504. private function asyncFetchFile($filename, $cacheKey, $lastModifiedTime = null)
  23505. {
  23506. $retries = 3;
  23507. if (isset($this->packagesNotFoundCache[$filename])) {
  23508. return \React\Promise\resolve(array('packages' => array()));
  23509. }
  23510. if (isset($this->freshMetadataUrls[$filename]) && $lastModifiedTime) {
  23511. return \React\Promise\resolve(true);
  23512. }
  23513. $httpDownloader = $this->httpDownloader;
  23514. if ($this->eventDispatcher) {
  23515. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata');
  23516. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  23517. $filename = $preFileDownloadEvent->getProcessedUrl();
  23518. }
  23519. $options = $this->options;
  23520. if ($lastModifiedTime) {
  23521. if (isset($options['http']['header'])) {
  23522. $options['http']['header'] = (array) $options['http']['header'];
  23523. }
  23524. $options['http']['header'][] = 'If-Modified-Since: '.$lastModifiedTime;
  23525. }
  23526. $io = $this->io;
  23527. $url = $this->url;
  23528. $cache = $this->cache;
  23529. $degradedMode =& $this->degradedMode;
  23530. $repo = $this;
  23531. $accept = function ($response) use ($io, $url, $filename, $cache, $cacheKey, $repo) {
  23532. if ($response->getStatusCode() === 404) {
  23533. $repo->packagesNotFoundCache[$filename] = true;
  23534. return array('packages' => array());
  23535. }
  23536. $json = $response->getBody();
  23537. if ($json === '' && $response->getStatusCode() === 304) {
  23538. $repo->freshMetadataUrls[$filename] = true;
  23539. return true;
  23540. }
  23541. $data = $response->decodeJson();
  23542. HttpDownloader::outputWarnings($io, $url, $data);
  23543. $lastModifiedDate = $response->getHeader('last-modified');
  23544. $response->collect();
  23545. if ($lastModifiedDate) {
  23546. $data['last-modified'] = $lastModifiedDate;
  23547. $json = JsonFile::encode($data, JsonFile::JSON_UNESCAPED_SLASHES | JsonFile::JSON_UNESCAPED_UNICODE);
  23548. }
  23549. if (!$cache->isReadOnly()) {
  23550. $cache->write($cacheKey, $json);
  23551. }
  23552. $repo->freshMetadataUrls[$filename] = true;
  23553. return $data;
  23554. };
  23555. $reject = function ($e) use (&$retries, $httpDownloader, $filename, $options, &$reject, $accept, $io, $url, &$degradedMode, $repo) {
  23556. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  23557. $repo->packagesNotFoundCache[$filename] = true;
  23558. return false;
  23559. }
  23560. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  23561. $retries = 0;
  23562. }
  23563. if (--$retries > 0) {
  23564. usleep(100000);
  23565. return $httpDownloader->add($filename, $options)->then($accept, $reject);
  23566. }
  23567. if (!$degradedMode) {
  23568. $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>');
  23569. }
  23570. $degradedMode = true;
  23571. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  23572. return $accept(new Response(array('url' => $url), 404, array(), ''));
  23573. }
  23574. throw $e;
  23575. };
  23576. return $httpDownloader->add($filename, $options)->then($accept, $reject);
  23577. }
  23578. private function initializePartialPackages()
  23579. {
  23580. $rootData = $this->loadRootServerFile();
  23581. $this->partialPackagesByName = array();
  23582. foreach ($rootData['packages'] as $package => $versions) {
  23583. foreach ($versions as $version) {
  23584. $this->partialPackagesByName[strtolower($version['name'])][] = $version;
  23585. }
  23586. }
  23587. $this->rootData = true;
  23588. }
  23589. protected function lazyProvidersRepoContains($name)
  23590. {
  23591. if (!$this->hasAvailablePackageList) {
  23592. throw new \LogicException('lazyProvidersRepoContains should not be called unless hasAvailablePackageList is true');
  23593. }
  23594. if (is_array($this->availablePackages) && isset($this->availablePackages[$name])) {
  23595. return true;
  23596. }
  23597. if (is_array($this->availablePackagePatterns)) {
  23598. foreach ($this->availablePackagePatterns as $providerRegex) {
  23599. if (preg_match($providerRegex, $name)) {
  23600. return true;
  23601. }
  23602. }
  23603. }
  23604. return false;
  23605. }
  23606. }
  23607. <?php
  23608. namespace Composer\Repository;
  23609. use Composer\Package\PackageInterface;
  23610. class CompositeRepository implements RepositoryInterface
  23611. {
  23612. private $repositories;
  23613. public function __construct(array $repositories)
  23614. {
  23615. $this->repositories = array();
  23616. foreach ($repositories as $repo) {
  23617. $this->addRepository($repo);
  23618. }
  23619. }
  23620. public function getRepoName()
  23621. {
  23622. return 'composite repo ('.implode(', ', array_map(function ($repo) { return $repo->getRepoName(); }, $this->repositories)).')';
  23623. }
  23624. public function getRepositories()
  23625. {
  23626. return $this->repositories;
  23627. }
  23628. public function hasPackage(PackageInterface $package)
  23629. {
  23630. foreach ($this->repositories as $repository) {
  23631. if ($repository->hasPackage($package)) {
  23632. return true;
  23633. }
  23634. }
  23635. return false;
  23636. }
  23637. public function findPackage($name, $constraint)
  23638. {
  23639. foreach ($this->repositories as $repository) {
  23640. $package = $repository->findPackage($name, $constraint);
  23641. if (null !== $package) {
  23642. return $package;
  23643. }
  23644. }
  23645. return null;
  23646. }
  23647. public function findPackages($name, $constraint = null)
  23648. {
  23649. $packages = array();
  23650. foreach ($this->repositories as $repository) {
  23651. $packages[] = $repository->findPackages($name, $constraint);
  23652. }
  23653. return $packages ? call_user_func_array('array_merge', $packages) : array();
  23654. }
  23655. public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  23656. {
  23657. $packages = array();
  23658. $namesFound = array();
  23659. foreach ($this->repositories as $repository) {
  23660. $result = $repository->loadPackages($packageMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  23661. $packages[] = $result['packages'];
  23662. $namesFound[] = $result['namesFound'];
  23663. }
  23664. return array(
  23665. 'packages' => $packages ? call_user_func_array('array_merge', $packages) : array(),
  23666. 'namesFound' => $namesFound ? array_unique(call_user_func_array('array_merge', $namesFound)) : array(),
  23667. );
  23668. }
  23669. public function search($query, $mode = 0, $type = null)
  23670. {
  23671. $matches = array();
  23672. foreach ($this->repositories as $repository) {
  23673. $matches[] = $repository->search($query, $mode, $type);
  23674. }
  23675. return $matches ? call_user_func_array('array_merge', $matches) : array();
  23676. }
  23677. public function getPackages()
  23678. {
  23679. $packages = array();
  23680. foreach ($this->repositories as $repository) {
  23681. $packages[] = $repository->getPackages();
  23682. }
  23683. return $packages ? call_user_func_array('array_merge', $packages) : array();
  23684. }
  23685. public function getProviders($packageName)
  23686. {
  23687. $results = array();
  23688. foreach ($this->repositories as $repository) {
  23689. $results[] = $repository->getProviders($packageName);
  23690. }
  23691. return $results ? call_user_func_array('array_merge', $results) : array();
  23692. }
  23693. public function removePackage(PackageInterface $package)
  23694. {
  23695. foreach ($this->repositories as $repository) {
  23696. $repository->removePackage($package);
  23697. }
  23698. }
  23699. public function count()
  23700. {
  23701. $total = 0;
  23702. foreach ($this->repositories as $repository) {
  23703. $total += $repository->count();
  23704. }
  23705. return $total;
  23706. }
  23707. public function addRepository(RepositoryInterface $repository)
  23708. {
  23709. if ($repository instanceof self) {
  23710. foreach ($repository->getRepositories() as $repo) {
  23711. $this->addRepository($repo);
  23712. }
  23713. } else {
  23714. $this->repositories[] = $repository;
  23715. }
  23716. }
  23717. }
  23718. <?php
  23719. namespace Composer\Repository;
  23720. interface ConfigurableRepositoryInterface
  23721. {
  23722. public function getRepoConfig();
  23723. }
  23724. <?php
  23725. namespace Composer\Repository;
  23726. use Composer\Json\JsonFile;
  23727. use Composer\Package\Loader\ArrayLoader;
  23728. use Composer\Package\RootPackageInterface;
  23729. use Composer\Package\AliasPackage;
  23730. use Composer\Package\Dumper\ArrayDumper;
  23731. use Composer\Installer\InstallationManager;
  23732. use Composer\Util\Filesystem;
  23733. class FilesystemRepository extends WritableArrayRepository
  23734. {
  23735. protected $file;
  23736. private $dumpVersions;
  23737. private $rootPackage;
  23738. public function __construct(JsonFile $repositoryFile, $dumpVersions = false, RootPackageInterface $rootPackage = null)
  23739. {
  23740. parent::__construct();
  23741. $this->file = $repositoryFile;
  23742. $this->dumpVersions = $dumpVersions;
  23743. $this->rootPackage = $rootPackage;
  23744. if ($dumpVersions && !$rootPackage) {
  23745. throw new \InvalidArgumentException('Expected a root package instance if $dumpVersions is true');
  23746. }
  23747. }
  23748. protected function initialize()
  23749. {
  23750. parent::initialize();
  23751. if (!$this->file->exists()) {
  23752. return;
  23753. }
  23754. try {
  23755. $data = $this->file->read();
  23756. if (isset($data['packages'])) {
  23757. $packages = $data['packages'];
  23758. } else {
  23759. $packages = $data;
  23760. }
  23761. if (isset($packages['packages'])) {
  23762. $packages = $packages['packages'];
  23763. }
  23764. if (!is_array($packages)) {
  23765. throw new \UnexpectedValueException('Could not parse package list from the repository');
  23766. }
  23767. } catch (\Exception $e) {
  23768. throw new InvalidRepositoryException('Invalid repository data in '.$this->file->getPath().', packages could not be loaded: ['.get_class($e).'] '.$e->getMessage());
  23769. }
  23770. $loader = new ArrayLoader(null, true);
  23771. foreach ($packages as $packageData) {
  23772. $package = $loader->load($packageData);
  23773. $this->addPackage($package);
  23774. }
  23775. }
  23776. public function reload()
  23777. {
  23778. $this->packages = null;
  23779. $this->initialize();
  23780. }
  23781. public function write($devMode, InstallationManager $installationManager)
  23782. {
  23783. $data = array('packages' => array(), 'dev' => $devMode);
  23784. $dumper = new ArrayDumper();
  23785. $fs = new Filesystem();
  23786. $repoDir = dirname($fs->normalizePath($this->file->getPath()));
  23787. foreach ($this->getCanonicalPackages() as $package) {
  23788. $pkgArray = $dumper->dump($package);
  23789. $path = $installationManager->getInstallPath($package);
  23790. $pkgArray['install-path'] = ('' !== $path && null !== $path) ? $fs->findShortestPath($repoDir, $fs->isAbsolutePath($path) ? $path : getcwd() . '/' . $path, true) : null;
  23791. $data['packages'][] = $pkgArray;
  23792. }
  23793. usort($data['packages'], function ($a, $b) {
  23794. return strcmp($a['name'], $b['name']);
  23795. });
  23796. $this->file->write($data);
  23797. if ($this->dumpVersions) {
  23798. $versions = array('versions' => array());
  23799. $packages = $this->getPackages();
  23800. $packages[] = $rootPackage = $this->rootPackage;
  23801. while ($rootPackage instanceof AliasPackage) {
  23802. $rootPackage = $rootPackage->getAliasOf();
  23803. $packages[] = $rootPackage;
  23804. }
  23805. foreach ($packages as $package) {
  23806. if ($package instanceof AliasPackage) {
  23807. continue;
  23808. }
  23809. $reference = null;
  23810. if ($package->getInstallationSource()) {
  23811. $reference = $package->getInstallationSource() === 'source' ? $package->getSourceReference() : $package->getDistReference();
  23812. }
  23813. if (null === $reference) {
  23814. $reference = ($package->getSourceReference() ?: $package->getDistReference()) ?: null;
  23815. }
  23816. $versions['versions'][$package->getName()] = array(
  23817. 'pretty_version' => $package->getPrettyVersion(),
  23818. 'version' => $package->getVersion(),
  23819. 'aliases' => array(),
  23820. 'reference' => $reference,
  23821. );
  23822. if ($package instanceof RootPackageInterface) {
  23823. $versions['root'] = $versions['versions'][$package->getName()];
  23824. $versions['root']['name'] = $package->getName();
  23825. }
  23826. }
  23827. foreach ($packages as $package) {
  23828. foreach ($package->getReplaces() as $replace) {
  23829. if (PlatformRepository::isPlatformPackage($replace->getTarget())) {
  23830. continue;
  23831. }
  23832. $replaced = $replace->getPrettyConstraint();
  23833. if ($replaced === 'self.version') {
  23834. $replaced = $package->getPrettyVersion();
  23835. }
  23836. if (!isset($versions['versions'][$replace->getTarget()]['replaced']) || !in_array($replaced, $versions['versions'][$replace->getTarget()]['replaced'], true)) {
  23837. $versions['versions'][$replace->getTarget()]['replaced'][] = $replaced;
  23838. }
  23839. }
  23840. foreach ($package->getProvides() as $provide) {
  23841. if (PlatformRepository::isPlatformPackage($provide->getTarget())) {
  23842. continue;
  23843. }
  23844. $provided = $provide->getPrettyConstraint();
  23845. if ($provided === 'self.version') {
  23846. $provided = $package->getPrettyVersion();
  23847. }
  23848. if (!isset($versions['versions'][$provide->getTarget()]['provided']) || !in_array($provided, $versions['versions'][$provide->getTarget()]['provided'], true)) {
  23849. $versions['versions'][$provide->getTarget()]['provided'][] = $provided;
  23850. }
  23851. }
  23852. }
  23853. foreach ($packages as $package) {
  23854. if (!$package instanceof AliasPackage) {
  23855. continue;
  23856. }
  23857. $versions['versions'][$package->getName()]['aliases'][] = $package->getPrettyVersion();
  23858. if ($package instanceof RootPackageInterface) {
  23859. $versions['root']['aliases'][] = $package->getPrettyVersion();
  23860. }
  23861. }
  23862. ksort($versions['versions']);
  23863. ksort($versions);
  23864. $fs->filePutContentsIfModified($repoDir.'/installed.php', '<?php return '.var_export($versions, true).';'."\n");
  23865. $installedVersionsClass = file_get_contents(__DIR__.'/../InstalledVersions.php');
  23866. $installedVersionsClass = str_replace('private static $installed;', 'private static $installed = '.var_export($versions, true).';', $installedVersionsClass);
  23867. $fs->filePutContentsIfModified($repoDir.'/InstalledVersions.php', $installedVersionsClass);
  23868. }
  23869. }
  23870. }
  23871. <?php
  23872. namespace Composer\Repository;
  23873. use Composer\Package\PackageInterface;
  23874. use Composer\Package\BasePackage;
  23875. class FilterRepository implements RepositoryInterface
  23876. {
  23877. private $only = array();
  23878. private $exclude = array();
  23879. private $canonical = true;
  23880. private $repo;
  23881. public function __construct(RepositoryInterface $repo, array $options)
  23882. {
  23883. if (isset($options['only'])) {
  23884. if (!is_array($options['only'])) {
  23885. throw new \InvalidArgumentException('"only" key for repository '.$repo->getRepoName().' should be an array');
  23886. }
  23887. $this->only = '{^'.implode('|', array_map(function ($val) {
  23888. return BasePackage::packageNameToRegexp($val, '%s');
  23889. }, $options['only'])) .'$}iD';
  23890. }
  23891. if (isset($options['exclude'])) {
  23892. if (!is_array($options['exclude'])) {
  23893. throw new \InvalidArgumentException('"exclude" key for repository '.$repo->getRepoName().' should be an array');
  23894. }
  23895. $this->exclude = '{^'.implode('|', array_map(function ($val) {
  23896. return BasePackage::packageNameToRegexp($val, '%s');
  23897. }, $options['exclude'])) .'$}iD';
  23898. }
  23899. if ($this->exclude && $this->only) {
  23900. throw new \InvalidArgumentException('Only one of "only" and "exclude" can be specified for repository '.$repo->getRepoName());
  23901. }
  23902. if (isset($options['canonical'])) {
  23903. if (!is_bool($options['canonical'])) {
  23904. throw new \InvalidArgumentException('"canonical" key for repository '.$repo->getRepoName().' should be a boolean');
  23905. }
  23906. $this->canonical = $options['canonical'];
  23907. }
  23908. $this->repo = $repo;
  23909. }
  23910. public function getRepoName()
  23911. {
  23912. return $this->repo->getRepoName();
  23913. }
  23914. public function getRepository()
  23915. {
  23916. return $this->repo;
  23917. }
  23918. public function hasPackage(PackageInterface $package)
  23919. {
  23920. return $this->repo->hasPackage($package);
  23921. }
  23922. public function findPackage($name, $constraint)
  23923. {
  23924. if (!$this->isAllowed($name)) {
  23925. return null;
  23926. }
  23927. return $this->repo->findPackage($name, $constraint);
  23928. }
  23929. public function findPackages($name, $constraint = null)
  23930. {
  23931. if (!$this->isAllowed($name)) {
  23932. return array();
  23933. }
  23934. return $this->repo->findPackages($name, $constraint);
  23935. }
  23936. public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  23937. {
  23938. foreach ($packageMap as $name => $constraint) {
  23939. if (!$this->isAllowed($name)) {
  23940. unset($packageMap[$name]);
  23941. }
  23942. }
  23943. if (!$packageMap) {
  23944. return array('namesFound' => array(), 'packages' => array());
  23945. }
  23946. $result = $this->repo->loadPackages($packageMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  23947. if (!$this->canonical) {
  23948. $result['namesFound'] = array();
  23949. }
  23950. return $result;
  23951. }
  23952. public function search($query, $mode = 0, $type = null)
  23953. {
  23954. $result = array();
  23955. foreach ($this->repo->search($query, $mode, $type) as $package) {
  23956. if ($this->isAllowed($package['name'])) {
  23957. $result[] = $package;
  23958. }
  23959. }
  23960. return $result;
  23961. }
  23962. public function getPackages()
  23963. {
  23964. $result = array();
  23965. foreach ($this->repo->getPackages() as $package) {
  23966. if ($this->isAllowed($package->getName())) {
  23967. $result[] = $package;
  23968. }
  23969. }
  23970. return $result;
  23971. }
  23972. public function getProviders($packageName)
  23973. {
  23974. $result = array();
  23975. foreach ($this->repo->getProviders($packageName) as $provider) {
  23976. if ($this->isAllowed($provider['name'])) {
  23977. $result[] = $provider;
  23978. }
  23979. }
  23980. return $result;
  23981. }
  23982. public function removePackage(PackageInterface $package)
  23983. {
  23984. return $this->repo->removePackage($package);
  23985. }
  23986. public function count()
  23987. {
  23988. if ($this->repo->count() > 0) {
  23989. return count($this->getPackages());
  23990. }
  23991. return 0;
  23992. }
  23993. private function isAllowed($name)
  23994. {
  23995. if (!$this->only && !$this->exclude) {
  23996. return true;
  23997. }
  23998. if ($this->only) {
  23999. return (bool) preg_match($this->only, $name);
  24000. }
  24001. return !preg_match($this->exclude, $name);
  24002. }
  24003. }
  24004. <?php
  24005. namespace Composer\Repository;
  24006. class InstalledArrayRepository extends WritableArrayRepository implements InstalledRepositoryInterface
  24007. {
  24008. public function getRepoName()
  24009. {
  24010. return 'installed '.parent::getRepoName();
  24011. }
  24012. public function isFresh()
  24013. {
  24014. return $this->count() === 0;
  24015. }
  24016. }
  24017. <?php
  24018. namespace Composer\Repository;
  24019. class InstalledFilesystemRepository extends FilesystemRepository implements InstalledRepositoryInterface
  24020. {
  24021. public function getRepoName()
  24022. {
  24023. return 'installed '.parent::getRepoName();
  24024. }
  24025. public function isFresh()
  24026. {
  24027. return !$this->file->exists();
  24028. }
  24029. }
  24030. <?php
  24031. namespace Composer\Repository;
  24032. use Composer\Package\Version\VersionParser;
  24033. use Composer\Semver\Constraint\ConstraintInterface;
  24034. use Composer\Semver\Constraint\Constraint;
  24035. use Composer\Semver\Constraint\MatchAllConstraint;
  24036. use Composer\Package\AliasPackage;
  24037. use Composer\Package\RootPackageInterface;
  24038. use Composer\Package\Link;
  24039. class InstalledRepository extends CompositeRepository
  24040. {
  24041. public function findPackagesWithReplacersAndProviders($name, $constraint = null)
  24042. {
  24043. $name = strtolower($name);
  24044. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  24045. $versionParser = new VersionParser();
  24046. $constraint = $versionParser->parseConstraints($constraint);
  24047. }
  24048. $matches = array();
  24049. foreach ($this->getRepositories() as $repo) {
  24050. foreach ($repo->getPackages() as $candidate) {
  24051. if ($name === $candidate->getName()) {
  24052. if (null === $constraint || $constraint->matches(new Constraint('==', $candidate->getVersion()))) {
  24053. $matches[] = $candidate;
  24054. }
  24055. continue;
  24056. }
  24057. foreach (array_merge($candidate->getProvides(), $candidate->getReplaces()) as $link) {
  24058. if (
  24059. $name === $link->getTarget()
  24060. && ($constraint === null || $link->getConstraint() === null || $constraint->matches($link->getConstraint()))
  24061. ) {
  24062. $matches[] = $candidate;
  24063. continue 2;
  24064. }
  24065. }
  24066. }
  24067. }
  24068. return $matches;
  24069. }
  24070. public function getDependents($needle, $constraint = null, $invert = false, $recurse = true, $packagesFound = null)
  24071. {
  24072. $needles = array_map('strtolower', (array) $needle);
  24073. $results = array();
  24074. if (null === $packagesFound) {
  24075. $packagesFound = $needles;
  24076. }
  24077. $rootPackage = null;
  24078. foreach ($this->getPackages() as $package) {
  24079. if ($package instanceof RootPackageInterface) {
  24080. $rootPackage = $package;
  24081. break;
  24082. }
  24083. }
  24084. foreach ($this->getPackages() as $package) {
  24085. $links = $package->getRequires();
  24086. $packagesInTree = $packagesFound;
  24087. if (!$invert) {
  24088. $links += $package->getReplaces();
  24089. foreach ($package->getReplaces() as $link) {
  24090. foreach ($needles as $needle) {
  24091. if ($link->getSource() === $needle) {
  24092. if ($constraint === null || ($link->getConstraint()->matches($constraint) === !$invert)) {
  24093. if (in_array($link->getTarget(), $packagesInTree)) {
  24094. $results[] = array($package, $link, false);
  24095. continue;
  24096. }
  24097. $packagesInTree[] = $link->getTarget();
  24098. $dependents = $recurse ? $this->getDependents($link->getTarget(), null, false, true, $packagesInTree) : array();
  24099. $results[] = array($package, $link, $dependents);
  24100. $needles[] = $link->getTarget();
  24101. }
  24102. }
  24103. }
  24104. }
  24105. }
  24106. if ($package instanceof RootPackageInterface) {
  24107. $links += $package->getDevRequires();
  24108. }
  24109. foreach ($links as $link) {
  24110. foreach ($needles as $needle) {
  24111. if ($link->getTarget() === $needle) {
  24112. if ($constraint === null || ($link->getConstraint()->matches($constraint) === !$invert)) {
  24113. if (in_array($link->getSource(), $packagesInTree)) {
  24114. $results[] = array($package, $link, false);
  24115. continue;
  24116. }
  24117. $packagesInTree[] = $link->getSource();
  24118. $dependents = $recurse ? $this->getDependents($link->getSource(), null, false, true, $packagesInTree) : array();
  24119. $results[] = array($package, $link, $dependents);
  24120. }
  24121. }
  24122. }
  24123. }
  24124. if ($invert && in_array($package->getName(), $needles)) {
  24125. foreach ($package->getConflicts() as $link) {
  24126. foreach ($this->findPackages($link->getTarget()) as $pkg) {
  24127. $version = new Constraint('=', $pkg->getVersion());
  24128. if ($link->getConstraint()->matches($version) === $invert) {
  24129. $results[] = array($package, $link, false);
  24130. }
  24131. }
  24132. }
  24133. }
  24134. if ($invert && $constraint && in_array($package->getName(), $needles) && $constraint->matches(new Constraint('=', $package->getVersion()))) {
  24135. foreach ($package->getRequires() as $link) {
  24136. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  24137. if ($this->findPackage($link->getTarget(), $link->getConstraint())) {
  24138. continue;
  24139. }
  24140. $platformPkg = $this->findPackage($link->getTarget(), '*');
  24141. $description = $platformPkg ? 'but '.$platformPkg->getPrettyVersion().' is installed' : 'but it is missing';
  24142. $results[] = array($package, new Link($package->getName(), $link->getTarget(), new MatchAllConstraint, Link::TYPE_REQUIRE, $link->getPrettyConstraint().' '.$description), false);
  24143. continue;
  24144. }
  24145. foreach ($this->getPackages() as $pkg) {
  24146. if (!in_array($link->getTarget(), $pkg->getNames())) {
  24147. continue;
  24148. }
  24149. $version = new Constraint('=', $pkg->getVersion());
  24150. if (!$link->getConstraint()->matches($version)) {
  24151. if ($rootPackage) {
  24152. foreach (array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires()) as $rootReq) {
  24153. if (in_array($rootReq->getTarget(), $pkg->getNames()) && !$rootReq->getConstraint()->matches($link->getConstraint())) {
  24154. $results[] = array($package, $link, false);
  24155. $results[] = array($rootPackage, $rootReq, false);
  24156. continue 3;
  24157. }
  24158. }
  24159. $results[] = array($package, $link, false);
  24160. $results[] = array($rootPackage, new Link($rootPackage->getName(), $link->getTarget(), new MatchAllConstraint, 'does not require', 'but ' . $pkg->getPrettyVersion() . ' is installed'), false);
  24161. } else {
  24162. $results[] = array($package, $link, false);
  24163. }
  24164. }
  24165. continue 2;
  24166. }
  24167. }
  24168. }
  24169. }
  24170. ksort($results);
  24171. return $results;
  24172. }
  24173. public function getRepoName()
  24174. {
  24175. return 'installed repo ('.implode(', ', array_map(function ($repo) { return $repo->getRepoName(); }, $this->getRepositories())).')';
  24176. }
  24177. public function addRepository(RepositoryInterface $repository)
  24178. {
  24179. if (
  24180. $repository instanceof LockArrayRepository
  24181. || $repository instanceof InstalledRepositoryInterface
  24182. || $repository instanceof RootPackageRepository
  24183. || $repository instanceof PlatformRepository
  24184. ) {
  24185. return parent::addRepository($repository);
  24186. }
  24187. throw new \LogicException('An InstalledRepository can not contain a repository of type '.get_class($repository).' ('.$repository->getRepoName().')');
  24188. }
  24189. }
  24190. <?php
  24191. namespace Composer\Repository;
  24192. interface InstalledRepositoryInterface extends WritableRepositoryInterface
  24193. {
  24194. public function isFresh();
  24195. }
  24196. <?php
  24197. namespace Composer\Repository;
  24198. class InvalidRepositoryException extends \Exception
  24199. {
  24200. }
  24201. <?php
  24202. namespace Composer\Repository;
  24203. class LockArrayRepository extends ArrayRepository
  24204. {
  24205. public function getRepoName()
  24206. {
  24207. return 'lock repo';
  24208. }
  24209. }
  24210. <?php
  24211. namespace Composer\Repository;
  24212. use Composer\Package\Loader\ArrayLoader;
  24213. use Composer\Package\Loader\ValidatingArrayLoader;
  24214. class PackageRepository extends ArrayRepository
  24215. {
  24216. private $config;
  24217. public function __construct(array $config)
  24218. {
  24219. parent::__construct();
  24220. $this->config = $config['package'];
  24221. if (!is_numeric(key($this->config))) {
  24222. $this->config = array($this->config);
  24223. }
  24224. }
  24225. protected function initialize()
  24226. {
  24227. parent::initialize();
  24228. $loader = new ValidatingArrayLoader(new ArrayLoader(null, true), false);
  24229. foreach ($this->config as $package) {
  24230. try {
  24231. $package = $loader->load($package);
  24232. } catch (\Exception $e) {
  24233. throw new InvalidRepositoryException('A repository of type "package" contains an invalid package definition: '.$e->getMessage()."\n\nInvalid package definition:\n".json_encode($package));
  24234. }
  24235. $this->addPackage($package);
  24236. }
  24237. }
  24238. public function getRepoName()
  24239. {
  24240. return preg_replace('{^array }', 'package ', parent::getRepoName());
  24241. }
  24242. }
  24243. <?php
  24244. namespace Composer\Repository;
  24245. use Composer\Config;
  24246. use Composer\IO\IOInterface;
  24247. use Composer\Json\JsonFile;
  24248. use Composer\Package\Loader\ArrayLoader;
  24249. use Composer\Package\Version\VersionGuesser;
  24250. use Composer\Package\Version\VersionParser;
  24251. use Composer\Util\Platform;
  24252. use Composer\Util\ProcessExecutor;
  24253. use Composer\Util\Filesystem;
  24254. use Composer\Util\Url;
  24255. use Composer\Util\Git as GitUtil;
  24256. class PathRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  24257. {
  24258. private $loader;
  24259. private $versionGuesser;
  24260. private $url;
  24261. private $repoConfig;
  24262. private $process;
  24263. private $options;
  24264. public function __construct(array $repoConfig, IOInterface $io, Config $config)
  24265. {
  24266. if (!isset($repoConfig['url'])) {
  24267. throw new \RuntimeException('You must specify the `url` configuration for the path repository');
  24268. }
  24269. $this->loader = new ArrayLoader(null, true);
  24270. $this->url = Platform::expandPath($repoConfig['url']);
  24271. $this->process = new ProcessExecutor($io);
  24272. $this->versionGuesser = new VersionGuesser($config, $this->process, new VersionParser());
  24273. $this->repoConfig = $repoConfig;
  24274. $this->options = isset($repoConfig['options']) ? $repoConfig['options'] : array();
  24275. if (!isset($this->options['relative'])) {
  24276. $filesystem = new Filesystem();
  24277. $this->options['relative'] = !$filesystem->isAbsolutePath($this->url);
  24278. }
  24279. parent::__construct();
  24280. }
  24281. public function getRepoName()
  24282. {
  24283. return 'path repo ('.Url::sanitize($this->repoConfig['url']).')';
  24284. }
  24285. public function getRepoConfig()
  24286. {
  24287. return $this->repoConfig;
  24288. }
  24289. protected function initialize()
  24290. {
  24291. parent::initialize();
  24292. $urlMatches = $this->getUrlMatches();
  24293. if (empty($urlMatches)) {
  24294. if (preg_match('{[*{}]}', $this->url)) {
  24295. $url = $this->url;
  24296. while (preg_match('{[*{}]}', $url)) {
  24297. $url = dirname($url);
  24298. }
  24299. if (is_dir($url)) {
  24300. return;
  24301. }
  24302. }
  24303. throw new \RuntimeException('The `url` supplied for the path (' . $this->url . ') repository does not exist');
  24304. }
  24305. foreach ($urlMatches as $url) {
  24306. $path = realpath($url) . DIRECTORY_SEPARATOR;
  24307. $composerFilePath = $path.'composer.json';
  24308. if (!file_exists($composerFilePath)) {
  24309. continue;
  24310. }
  24311. $json = file_get_contents($composerFilePath);
  24312. $package = JsonFile::parseJson($json, $composerFilePath);
  24313. $package['dist'] = array(
  24314. 'type' => 'path',
  24315. 'url' => $url,
  24316. 'reference' => sha1($json . serialize($this->options)),
  24317. );
  24318. $package['transport-options'] = $this->options;
  24319. if (!isset($package['version']) && isset($package['extra']['branch-version'])) {
  24320. $package['version'] = preg_replace('{(\.x)?(-dev)?$}', '', $package['extra']['branch-version']).'.x-dev';
  24321. }
  24322. if (!isset($package['version']) && ($rootVersion = getenv('COMPOSER_ROOT_VERSION'))) {
  24323. if (
  24324. 0 === $this->process->execute('git rev-parse HEAD', $ref1, $path)
  24325. && 0 === $this->process->execute('git rev-parse HEAD', $ref2)
  24326. && $ref1 === $ref2
  24327. ) {
  24328. $package['version'] = $rootVersion;
  24329. }
  24330. }
  24331. $output = '';
  24332. if (is_dir($path . DIRECTORY_SEPARATOR . '.git') && 0 === $this->process->execute('git log -n1 --pretty=%H'.GitUtil::getNoShowSignatureFlag($this->process), $output, $path)) {
  24333. $package['dist']['reference'] = trim($output);
  24334. }
  24335. if (!isset($package['version'])) {
  24336. $versionData = $this->versionGuesser->guessVersion($package, $path);
  24337. if (is_array($versionData) && $versionData['pretty_version']) {
  24338. if (!empty($versionData['feature_pretty_version'])) {
  24339. $package['version'] = $versionData['feature_pretty_version'];
  24340. $this->addPackage($this->loader->load($package));
  24341. }
  24342. $package['version'] = $versionData['pretty_version'];
  24343. } else {
  24344. $package['version'] = 'dev-master';
  24345. }
  24346. }
  24347. $package = $this->loader->load($package);
  24348. $this->addPackage($package);
  24349. }
  24350. }
  24351. private function getUrlMatches()
  24352. {
  24353. $flags = GLOB_MARK | GLOB_ONLYDIR;
  24354. if (defined('GLOB_BRACE')) {
  24355. $flags |= GLOB_BRACE;
  24356. } elseif (strpos($this->url, '{') !== false || strpos($this->url, '}') !== false) {
  24357. throw new \RuntimeException('The operating system does not support GLOB_BRACE which is required for the url '. $this->url);
  24358. }
  24359. return array_map(function ($val) {
  24360. return rtrim(str_replace(DIRECTORY_SEPARATOR, '/', $val), '/');
  24361. }, glob($this->url, $flags));
  24362. }
  24363. }
  24364. <?php
  24365. namespace Composer\Repository;
  24366. use Composer\IO\IOInterface;
  24367. use Composer\Semver\VersionParser as SemverVersionParser;
  24368. use Composer\Package\Version\VersionParser;
  24369. use Composer\Package\CompletePackage;
  24370. use Composer\EventDispatcher\EventDispatcher;
  24371. use Composer\Package\Link;
  24372. use Composer\Semver\Constraint\Constraint;
  24373. use Composer\Util\HttpDownloader;
  24374. use Composer\Config;
  24375. use Composer\Factory;
  24376. class PearRepository extends ArrayRepository
  24377. {
  24378. public function __construct()
  24379. {
  24380. throw new \RuntimeException('The PEAR repository has been removed from Composer 2.0');
  24381. }
  24382. }
  24383. <?php
  24384. namespace Composer\Repository;
  24385. use Composer\Composer;
  24386. use Composer\Package\CompletePackage;
  24387. use Composer\Package\Link;
  24388. use Composer\Package\PackageInterface;
  24389. use Composer\Package\Version\VersionParser;
  24390. use Composer\Platform\HhvmDetector;
  24391. use Composer\Platform\Runtime;
  24392. use Composer\Platform\Version;
  24393. use Composer\Plugin\PluginInterface;
  24394. use Composer\Semver\Constraint\Constraint;
  24395. use Composer\Util\Silencer;
  24396. use Composer\XdebugHandler\XdebugHandler;
  24397. class PlatformRepository extends ArrayRepository
  24398. {
  24399. const PLATFORM_PACKAGE_REGEX = '{^(?:php(?:-64bit|-ipv6|-zts|-debug)?|hhvm|(?:ext|lib)-[a-z0-9](?:[_.-]?[a-z0-9]+)*|composer-(?:plugin|runtime)-api)$}iD';
  24400. private $versionParser;
  24401. private $overrides = array();
  24402. private $runtime;
  24403. private $hhvmDetector;
  24404. public function __construct(array $packages = array(), array $overrides = array(), Runtime $runtime = null, HhvmDetector $hhvmDetector = null)
  24405. {
  24406. $this->runtime = $runtime ?: new Runtime();
  24407. $this->hhvmDetector = $hhvmDetector ?: new HhvmDetector();
  24408. foreach ($overrides as $name => $version) {
  24409. $this->overrides[strtolower($name)] = array('name' => $name, 'version' => $version);
  24410. }
  24411. parent::__construct($packages);
  24412. }
  24413. public function getRepoName()
  24414. {
  24415. return 'platform repo';
  24416. }
  24417. protected function initialize()
  24418. {
  24419. parent::initialize();
  24420. $this->versionParser = new VersionParser();
  24421. foreach ($this->overrides as $override) {
  24422. if (!self::isPlatformPackage($override['name'])) {
  24423. throw new \InvalidArgumentException('Invalid platform package name in config.platform: '.$override['name']);
  24424. }
  24425. $this->addOverriddenPackage($override);
  24426. }
  24427. $prettyVersion = PluginInterface::PLUGIN_API_VERSION;
  24428. $version = $this->versionParser->normalize($prettyVersion);
  24429. $composerPluginApi = new CompletePackage('composer-plugin-api', $version, $prettyVersion);
  24430. $composerPluginApi->setDescription('The Composer Plugin API');
  24431. $this->addPackage($composerPluginApi);
  24432. $prettyVersion = Composer::RUNTIME_API_VERSION;
  24433. $version = $this->versionParser->normalize($prettyVersion);
  24434. $composerRuntimeApi = new CompletePackage('composer-runtime-api', $version, $prettyVersion);
  24435. $composerRuntimeApi->setDescription('The Composer Runtime API');
  24436. $this->addPackage($composerRuntimeApi);
  24437. try {
  24438. $prettyVersion = $this->runtime->getConstant('PHP_VERSION');
  24439. $version = $this->versionParser->normalize($prettyVersion);
  24440. } catch (\UnexpectedValueException $e) {
  24441. $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', $this->runtime->getConstant('PHP_VERSION'));
  24442. $version = $this->versionParser->normalize($prettyVersion);
  24443. }
  24444. $php = new CompletePackage('php', $version, $prettyVersion);
  24445. $php->setDescription('The PHP interpreter');
  24446. $this->addPackage($php);
  24447. if ($this->runtime->getConstant('PHP_DEBUG')) {
  24448. $phpdebug = new CompletePackage('php-debug', $version, $prettyVersion);
  24449. $phpdebug->setDescription('The PHP interpreter, with debugging symbols');
  24450. $this->addPackage($phpdebug);
  24451. }
  24452. if ($this->runtime->hasConstant('PHP_ZTS') && $this->runtime->getConstant('PHP_ZTS')) {
  24453. $phpzts = new CompletePackage('php-zts', $version, $prettyVersion);
  24454. $phpzts->setDescription('The PHP interpreter, with Zend Thread Safety');
  24455. $this->addPackage($phpzts);
  24456. }
  24457. if ($this->runtime->getConstant('PHP_INT_SIZE') === 8) {
  24458. $php64 = new CompletePackage('php-64bit', $version, $prettyVersion);
  24459. $php64->setDescription('The PHP interpreter, 64bit');
  24460. $this->addPackage($php64);
  24461. }
  24462. if ($this->runtime->hasConstant('AF_INET6') || Silencer::call(array($this->runtime, 'invoke'), 'inet_pton', array('::')) !== false) {
  24463. $phpIpv6 = new CompletePackage('php-ipv6', $version, $prettyVersion);
  24464. $phpIpv6->setDescription('The PHP interpreter, with IPv6 support');
  24465. $this->addPackage($phpIpv6);
  24466. }
  24467. $loadedExtensions = $this->runtime->getExtensions();
  24468. foreach ($loadedExtensions as $name) {
  24469. if (in_array($name, array('standard', 'Core'))) {
  24470. continue;
  24471. }
  24472. $this->addExtension($name, $this->runtime->getExtensionVersion($name));
  24473. }
  24474. if (!in_array('xdebug', $loadedExtensions, true) && ($prettyVersion = XdebugHandler::getSkippedVersion())) {
  24475. $this->addExtension('xdebug', $prettyVersion);
  24476. }
  24477. foreach ($loadedExtensions as $name) {
  24478. switch ($name) {
  24479. case 'amqp':
  24480. $info = $this->runtime->getExtensionInfo($name);
  24481. if (preg_match('/^librabbitmq version => (?<version>.+)$/im', $info, $librabbitmqMatches)) {
  24482. $this->addLibrary($name.'-librabbitmq', $librabbitmqMatches['version'], 'AMQP librabbitmq version');
  24483. }
  24484. if (preg_match('/^AMQP protocol version => (?<version>.+)$/im', $info, $protocolMatches)) {
  24485. $this->addLibrary($name.'-protocol', str_replace('-', '.', $protocolMatches['version']), 'AMQP protocol version');
  24486. }
  24487. break;
  24488. case 'bz2':
  24489. $info = $this->runtime->getExtensionInfo($name);
  24490. if (preg_match('/^BZip2 Version => (?<version>.*),/im', $info, $matches)) {
  24491. $this->addLibrary($name, $matches['version']);
  24492. }
  24493. break;
  24494. case 'curl':
  24495. $curlVersion = $this->runtime->invoke('curl_version');
  24496. $this->addLibrary($name, $curlVersion['version']);
  24497. $info = $this->runtime->getExtensionInfo($name);
  24498. if (preg_match('{^SSL Version => (?<library>[^/]+)/(?<version>.+)$}im', $info, $sslMatches)) {
  24499. $library = strtolower($sslMatches['library']);
  24500. if ($library === 'openssl') {
  24501. $parsedVersion = Version::parseOpenssl($sslMatches['version'], $isFips);
  24502. $this->addLibrary($name.'-openssl'.($isFips ? '-fips': ''), $parsedVersion, 'curl OpenSSL version ('.$parsedVersion.')', array(), $isFips ? array('curl-openssl'): array());
  24503. } else {
  24504. $this->addLibrary($name.'-'.$library, $sslMatches['version'], 'curl '.$library.' version ('.$sslMatches['version'].')', array('curl-openssl'));
  24505. }
  24506. }
  24507. if (preg_match('{^libSSH Version => (?<library>[^/]+)/(?<version>.+?)(?:/.*)?$}im', $info, $sshMatches)) {
  24508. $this->addLibrary($name.'-'.strtolower($sshMatches['library']), $sshMatches['version'], 'curl '.$sshMatches['library'].' version');
  24509. }
  24510. if (preg_match('{^ZLib Version => (?<version>.+)$}im', $info, $zlibMatches)) {
  24511. $this->addLibrary($name.'-zlib', $zlibMatches['version'], 'curl zlib version');
  24512. }
  24513. break;
  24514. case 'date':
  24515. $info = $this->runtime->getExtensionInfo($name);
  24516. if (preg_match('/^timelib version => (?<version>.+)$/im', $info, $timelibMatches)) {
  24517. $this->addLibrary($name.'-timelib', $timelibMatches['version'], 'date timelib version');
  24518. }
  24519. if (preg_match('/^Timezone Database => (?<source>internal|external)$/im', $info, $zoneinfoSourceMatches)) {
  24520. $external = $zoneinfoSourceMatches['source'] === 'external';
  24521. if (preg_match('/^"Olson" Timezone Database Version => (?<version>.+?)(\.system)?$/im', $info, $zoneinfoMatches)) {
  24522. if ($external && in_array('timezonedb', $loadedExtensions, true)) {
  24523. $this->addLibrary('timezonedb-zoneinfo', $zoneinfoMatches['version'], 'zoneinfo ("Olson") database for date (replaced by timezonedb)', array($name.'-zoneinfo'));
  24524. } else {
  24525. $this->addLibrary($name.'-zoneinfo', $zoneinfoMatches['version'], 'zoneinfo ("Olson") database for date');
  24526. }
  24527. }
  24528. }
  24529. break;
  24530. case 'fileinfo':
  24531. $info = $this->runtime->getExtensionInfo($name);
  24532. if (preg_match('/^libmagic => (?<version>.+)$/im', $info, $magicMatches)) {
  24533. $this->addLibrary($name.'-libmagic', $magicMatches['version'], 'fileinfo libmagic version');
  24534. }
  24535. break;
  24536. case 'gd':
  24537. $this->addLibrary($name, $this->runtime->getConstant('GD_VERSION'));
  24538. $info = $this->runtime->getExtensionInfo($name);
  24539. if (preg_match('/^libJPEG Version => (?<version>.+?)(?: compatible)?$/im', $info, $libjpegMatches)) {
  24540. $this->addLibrary($name.'-libjpeg', Version::parseLibjpeg($libjpegMatches['version']), 'libjpeg version for gd');
  24541. }
  24542. if (preg_match('/^libPNG Version => (?<version>.+)$/im', $info, $libpngMatches)) {
  24543. $this->addLibrary($name.'-libpng', $libpngMatches['version'], 'libpng version for gd');
  24544. }
  24545. if (preg_match('/^FreeType Version => (?<version>.+)$/im', $info, $freetypeMatches)) {
  24546. $this->addLibrary($name.'-freetype', $freetypeMatches['version'], 'freetype version for gd');
  24547. }
  24548. if (preg_match('/^libXpm Version => (?<versionId>\d+)$/im', $info, $libxpmMatches)) {
  24549. $this->addLibrary($name.'-libxpm', Version::convertLibxpmVersionId($libxpmMatches['versionId']), 'libxpm version for gd');
  24550. }
  24551. break;
  24552. case 'gmp':
  24553. $this->addLibrary($name, $this->runtime->getConstant('GMP_VERSION'));
  24554. break;
  24555. case 'iconv':
  24556. $this->addLibrary($name, $this->runtime->getConstant('ICONV_VERSION'));
  24557. break;
  24558. case 'intl':
  24559. $info = $this->runtime->getExtensionInfo($name);
  24560. $description = 'The ICU unicode and globalization support library';
  24561. if ($this->runtime->hasConstant('INTL_ICU_VERSION')) {
  24562. $this->addLibrary('icu', $this->runtime->getConstant('INTL_ICU_VERSION'), $description);
  24563. } elseif (preg_match('/^ICU version => (?<version>.+)$/im', $info, $matches)) {
  24564. $this->addLibrary('icu', $matches['version'], $description);
  24565. }
  24566. if (preg_match('/^ICU TZData version => (?<version>.*)$/im', $info, $zoneinfoMatches)) {
  24567. $this->addLibrary('icu-zoneinfo', Version::parseZoneinfoVersion($zoneinfoMatches['version']), 'zoneinfo ("Olson") database for icu');
  24568. }
  24569. if ($this->runtime->hasClass('ResourceBundle')) {
  24570. $cldrVersion = $this->runtime->invoke(array('ResourceBundle', 'create'), array('root', 'ICUDATA', false))->get('Version');
  24571. $this->addLibrary('icu-cldr', $cldrVersion, 'ICU CLDR project version');
  24572. }
  24573. if ($this->runtime->hasClass('IntlChar')) {
  24574. $this->addLibrary('icu-unicode', implode('.', array_slice($this->runtime->invoke(array('IntlChar', 'getUnicodeVersion')), 0, 3)), 'ICU unicode version');
  24575. }
  24576. break;
  24577. case 'imagick':
  24578. $imageMagickVersion = $this->runtime->construct('Imagick')->getVersion();
  24579. preg_match('/^ImageMagick (?<version>[\d.]+)(?:-(?<patch>\d+))?/', $imageMagickVersion['versionString'], $matches);
  24580. $version = $matches['version'];
  24581. if (isset($matches['patch'])) {
  24582. $version .= '.'.$matches['patch'];
  24583. }
  24584. $this->addLibrary($name.'-imagemagick', $version, null, array('imagick'));
  24585. break;
  24586. case 'ldap':
  24587. $info = $this->runtime->getExtensionInfo($name);
  24588. if (preg_match('/^Vendor Version => (?<versionId>\d+)$/im', $info, $matches) && preg_match('/^Vendor Name => (?<vendor>.+)$/im', $info, $vendorMatches)) {
  24589. $this->addLibrary($name.'-'.strtolower($vendorMatches['vendor']), Version::convertOpenldapVersionId($matches['versionId']), $vendorMatches['vendor'].' version of ldap');
  24590. }
  24591. break;
  24592. case 'libxml':
  24593. $libxmlProvides = array_map(function($extension) {
  24594. return $extension . '-libxml';
  24595. }, array_intersect($loadedExtensions, array('dom', 'simplexml', 'xml', 'xmlreader', 'xmlwriter')));
  24596. $this->addLibrary($name, $this->runtime->getConstant('LIBXML_DOTTED_VERSION'), 'libxml library version', array(), $libxmlProvides);
  24597. break;
  24598. case 'mbstring':
  24599. $info = $this->runtime->getExtensionInfo($name);
  24600. if (preg_match('/^libmbfl version => (?<version>.+)$/im', $info, $libmbflMatches)) {
  24601. $this->addLibrary($name.'-libmbfl', $libmbflMatches['version'], 'mbstring libmbfl version');
  24602. }
  24603. if ($this->runtime->hasConstant('MB_ONIGURUMA_VERSION')) {
  24604. $this->addLibrary($name.'-oniguruma', $this->runtime->getConstant('MB_ONIGURUMA_VERSION'), 'mbstring oniguruma version');
  24605. } elseif (preg_match('/^(?:oniguruma|Multibyte regex \(oniguruma\)) version => (?<version>.+)$/im', $info, $onigurumaMatches)) {
  24606. $this->addLibrary($name.'-oniguruma', $onigurumaMatches['version'], 'mbstring oniguruma version');
  24607. }
  24608. break;
  24609. case 'memcached':
  24610. $info = $this->runtime->getExtensionInfo($name);
  24611. if (preg_match('/^libmemcached version => (?<version>.+)$/im', $info, $matches)) {
  24612. $this->addLibrary($name.'-libmemcached', $matches['version'], 'libmemcached version');
  24613. }
  24614. break;
  24615. case 'openssl':
  24616. if (preg_match('{^(?:OpenSSL|LibreSSL)?\s*(?<version>\S+)}i', $this->runtime->getConstant('OPENSSL_VERSION_TEXT'), $matches)) {
  24617. $parsedVersion = Version::parseOpenssl($matches['version'], $isFips);
  24618. $this->addLibrary($name.($isFips ? '-fips' : ''), $parsedVersion, $this->runtime->getConstant('OPENSSL_VERSION_TEXT'), array(), $isFips ? array($name) : array());
  24619. }
  24620. break;
  24621. case 'pcre':
  24622. $this->addLibrary($name, preg_replace('{^(\S+).*}', '$1', $this->runtime->getConstant('PCRE_VERSION')));
  24623. $info = $this->runtime->getExtensionInfo($name);
  24624. if (preg_match('/^PCRE Unicode Version => (?<version>.+)$/im', $info, $pcreUnicodeMatches)) {
  24625. $this->addLibrary($name.'-unicode', $pcreUnicodeMatches['version'], 'PCRE Unicode version support');
  24626. }
  24627. break;
  24628. case 'mysqlnd':
  24629. case 'pdo_mysql':
  24630. $info = $this->runtime->getExtensionInfo($name);
  24631. if (preg_match('/^(?:Client API version|Version) => mysqlnd (?<version>.+?) /mi', $info, $matches)) {
  24632. $this->addLibrary($name.'-mysqlnd', $matches['version'], 'mysqlnd library version for '.$name);
  24633. }
  24634. break;
  24635. case 'mongodb':
  24636. $info = $this->runtime->getExtensionInfo($name);
  24637. if (preg_match('/^libmongoc bundled version => (?<version>.+)$/im', $info, $libmongocMatches)) {
  24638. $this->addLibrary($name.'-libmongoc', $libmongocMatches['version'], 'libmongoc version of mongodb');
  24639. }
  24640. if (preg_match('/^libbson bundled version => (?<version>.+)$/im', $info, $libbsonMatches)) {
  24641. $this->addLibrary($name.'-libbson', $libbsonMatches['version'], 'libbson version of mongodb');
  24642. }
  24643. break;
  24644. case 'pgsql':
  24645. case 'pdo_pgsql':
  24646. $info = $this->runtime->getExtensionInfo($name);
  24647. if (preg_match('/^PostgreSQL\(libpq\) Version => (?<version>.*)$/im', $info, $matches)) {
  24648. $this->addLibrary($name.'-libpq', $matches['version'], 'libpq for '.$name);
  24649. }
  24650. break;
  24651. case 'libsodium':
  24652. case 'sodium':
  24653. $this->addLibrary('libsodium', $this->runtime->getConstant('SODIUM_LIBRARY_VERSION'));
  24654. break;
  24655. case 'sqlite3':
  24656. case 'pdo_sqlite':
  24657. $info = $this->runtime->getExtensionInfo($name);
  24658. if (preg_match('/^SQLite Library => (?<version>.+)$/im', $info, $matches)) {
  24659. $this->addLibrary($name.'-sqlite', $matches['version']);
  24660. }
  24661. break;
  24662. case 'ssh2':
  24663. $info = $this->runtime->getExtensionInfo($name);
  24664. if (preg_match('/^libssh2 version => (?<version>.+)$/im', $info, $matches)) {
  24665. $this->addLibrary($name.'-libssh2', $matches['version']);
  24666. }
  24667. break;
  24668. case 'xsl':
  24669. $this->addLibrary('libxslt', $this->runtime->getConstant('LIBXSLT_DOTTED_VERSION'), null, array('xsl'));
  24670. $info = $this->runtime->getExtensionInfo('xsl');
  24671. if (preg_match('/^libxslt compiled against libxml Version => (?<version>.+)$/im', $info, $matches)) {
  24672. $this->addLibrary('libxslt-libxml', $matches['version'], 'libxml version libxslt is compiled against');
  24673. }
  24674. break;
  24675. case 'yaml':
  24676. $info = $this->runtime->getExtensionInfo('yaml');
  24677. if (preg_match('/^LibYAML Version => (?<version>.+)$/im', $info, $matches)) {
  24678. $this->addLibrary($name.'-libyaml', $matches['version'], 'libyaml version of yaml');
  24679. }
  24680. break;
  24681. case 'zip':
  24682. if ($this->runtime->hasConstant('LIBZIP_VERSION', 'ZipArchive')) {
  24683. $this->addLibrary($name.'-libzip', $this->runtime->getConstant('LIBZIP_VERSION','ZipArchive'), null, array('zip'));
  24684. }
  24685. break;
  24686. case 'zlib':
  24687. if ($this->runtime->hasConstant('ZLIB_VERSION')) {
  24688. $this->addLibrary($name, $this->runtime->getConstant('ZLIB_VERSION'));
  24689. } elseif (preg_match('/^Linked Version => (?<version>.+)$/im', $this->runtime->getExtensionInfo($name), $matches)) {
  24690. $this->addLibrary($name, $matches['version']);
  24691. }
  24692. break;
  24693. default:
  24694. break;
  24695. }
  24696. }
  24697. $hhvmVersion = $this->hhvmDetector->getVersion();
  24698. if ($hhvmVersion) {
  24699. try {
  24700. $prettyVersion = $hhvmVersion;
  24701. $version = $this->versionParser->normalize($prettyVersion);
  24702. } catch (\UnexpectedValueException $e) {
  24703. $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', $hhvmVersion);
  24704. $version = $this->versionParser->normalize($prettyVersion);
  24705. }
  24706. $hhvm = new CompletePackage('hhvm', $version, $prettyVersion);
  24707. $hhvm->setDescription('The HHVM Runtime (64bit)');
  24708. $this->addPackage($hhvm);
  24709. }
  24710. }
  24711. public function addPackage(PackageInterface $package)
  24712. {
  24713. if (isset($this->overrides[$package->getName()])) {
  24714. $overrider = $this->findPackage($package->getName(), '*');
  24715. if ($package->getVersion() === $overrider->getVersion()) {
  24716. $actualText = 'same as actual';
  24717. } else {
  24718. $actualText = 'actual: '.$package->getPrettyVersion();
  24719. }
  24720. $overrider->setDescription($overrider->getDescription().', '.$actualText);
  24721. return;
  24722. }
  24723. if (isset($this->overrides['php']) && 0 === strpos($package->getName(), 'php-')) {
  24724. $overrider = $this->addOverriddenPackage($this->overrides['php'], $package->getPrettyName());
  24725. if ($package->getVersion() === $overrider->getVersion()) {
  24726. $actualText = 'same as actual';
  24727. } else {
  24728. $actualText = 'actual: '.$package->getPrettyVersion();
  24729. }
  24730. $overrider->setDescription($overrider->getDescription().', '.$actualText);
  24731. return;
  24732. }
  24733. parent::addPackage($package);
  24734. }
  24735. private function addOverriddenPackage(array $override, $name = null)
  24736. {
  24737. $version = $this->versionParser->normalize($override['version']);
  24738. $package = new CompletePackage($name ?: $override['name'], $version, $override['version']);
  24739. $package->setDescription('Package overridden via config.platform');
  24740. $package->setExtra(array('config.platform' => true));
  24741. parent::addPackage($package);
  24742. return $package;
  24743. }
  24744. private function addExtension($name, $prettyVersion)
  24745. {
  24746. $extraDescription = null;
  24747. try {
  24748. $version = $this->versionParser->normalize($prettyVersion);
  24749. } catch (\UnexpectedValueException $e) {
  24750. $extraDescription = ' (actual version: '.$prettyVersion.')';
  24751. if (preg_match('{^(\d+\.\d+\.\d+(?:\.\d+)?)}', $prettyVersion, $match)) {
  24752. $prettyVersion = $match[1];
  24753. } else {
  24754. $prettyVersion = '0';
  24755. }
  24756. $version = $this->versionParser->normalize($prettyVersion);
  24757. }
  24758. $packageName = $this->buildPackageName($name);
  24759. $ext = new CompletePackage($packageName, $version, $prettyVersion);
  24760. $ext->setDescription('The '.$name.' PHP extension'.$extraDescription);
  24761. if ($name === 'uuid') {
  24762. $ext->setReplaces(array(
  24763. new Link('ext-uuid', 'lib-uuid', new Constraint('=', $version), Link::TYPE_REPLACE, $ext->getPrettyVersion())
  24764. ));
  24765. }
  24766. $this->addPackage($ext);
  24767. }
  24768. private function buildPackageName($name)
  24769. {
  24770. return 'ext-' . str_replace(' ', '-', strtolower($name));
  24771. }
  24772. private function addLibrary($name, $prettyVersion, $description = null, array $replaces = array(), array $provides = array())
  24773. {
  24774. try {
  24775. $version = $this->versionParser->normalize($prettyVersion);
  24776. } catch (\UnexpectedValueException $e) {
  24777. return;
  24778. }
  24779. if ($description === null) {
  24780. $description = 'The '.$name.' library';
  24781. }
  24782. $lib = new CompletePackage('lib-'.$name, $version, $prettyVersion);
  24783. $lib->setDescription($description);
  24784. $links = function ($alias) use ($name, $version, $lib) {
  24785. return new Link('lib-'.$name, 'lib-'.$alias, new Constraint('=', $version), Link::TYPE_REPLACE, $lib->getPrettyVersion());
  24786. };
  24787. $lib->setReplaces(array_map($links, $replaces));
  24788. $lib->setProvides(array_map($links, $provides));
  24789. $this->addPackage($lib);
  24790. }
  24791. public static function isPlatformPackage($name)
  24792. {
  24793. static $cache = array();
  24794. if (isset($cache[$name])) {
  24795. return $cache[$name];
  24796. }
  24797. return $cache[$name] = (bool) preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name);
  24798. }
  24799. }
  24800. <?php
  24801. namespace Composer\Repository;
  24802. use Composer\Factory;
  24803. use Composer\IO\IOInterface;
  24804. use Composer\Config;
  24805. use Composer\EventDispatcher\EventDispatcher;
  24806. use Composer\Util\HttpDownloader;
  24807. use Composer\Util\ProcessExecutor;
  24808. use Composer\Json\JsonFile;
  24809. class RepositoryFactory
  24810. {
  24811. public static function configFromString(IOInterface $io, Config $config, $repository, $allowFilesystem = false)
  24812. {
  24813. if (0 === strpos($repository, 'http')) {
  24814. $repoConfig = array('type' => 'composer', 'url' => $repository);
  24815. } elseif ("json" === pathinfo($repository, PATHINFO_EXTENSION)) {
  24816. $json = new JsonFile($repository, Factory::createHttpDownloader($io, $config));
  24817. $data = $json->read();
  24818. if (!empty($data['packages']) || !empty($data['includes']) || !empty($data['provider-includes'])) {
  24819. $repoConfig = array('type' => 'composer', 'url' => 'file://' . strtr(realpath($repository), '\\', '/'));
  24820. } elseif ($allowFilesystem) {
  24821. $repoConfig = array('type' => 'filesystem', 'json' => $json);
  24822. } else {
  24823. throw new \InvalidArgumentException("Invalid repository URL ($repository) given. This file does not contain a valid composer repository.");
  24824. }
  24825. } elseif (strpos($repository, '{') === 0) {
  24826. $repoConfig = JsonFile::parseJson($repository);
  24827. } else {
  24828. throw new \InvalidArgumentException("Invalid repository url ($repository) given. Has to be a .json file, an http url or a JSON object.");
  24829. }
  24830. return $repoConfig;
  24831. }
  24832. public static function fromString(IOInterface $io, Config $config, $repository, $allowFilesystem = false, RepositoryManager $rm = null)
  24833. {
  24834. $repoConfig = static::configFromString($io, $config, $repository, $allowFilesystem);
  24835. return static::createRepo($io, $config, $repoConfig, $rm);
  24836. }
  24837. public static function createRepo(IOInterface $io, Config $config, array $repoConfig, RepositoryManager $rm = null)
  24838. {
  24839. if (!$rm) {
  24840. $rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config));
  24841. }
  24842. $repos = static::createRepos($rm, array($repoConfig));
  24843. return reset($repos);
  24844. }
  24845. public static function defaultRepos(IOInterface $io = null, Config $config = null, RepositoryManager $rm = null)
  24846. {
  24847. if (!$config) {
  24848. $config = Factory::createConfig($io);
  24849. }
  24850. if ($io) {
  24851. $io->loadConfiguration($config);
  24852. }
  24853. if (!$rm) {
  24854. if (!$io) {
  24855. throw new \InvalidArgumentException('This function requires either an IOInterface or a RepositoryManager');
  24856. }
  24857. $rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config));
  24858. }
  24859. return static::createRepos($rm, $config->getRepositories());
  24860. }
  24861. public static function manager(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, ProcessExecutor $process = null)
  24862. {
  24863. $rm = new RepositoryManager($io, $config, $httpDownloader, $eventDispatcher, $process);
  24864. $rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
  24865. $rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');
  24866. $rm->setRepositoryClass('package', 'Composer\Repository\PackageRepository');
  24867. $rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
  24868. $rm->setRepositoryClass('git', 'Composer\Repository\VcsRepository');
  24869. $rm->setRepositoryClass('git-bitbucket', 'Composer\Repository\VcsRepository');
  24870. $rm->setRepositoryClass('github', 'Composer\Repository\VcsRepository');
  24871. $rm->setRepositoryClass('gitlab', 'Composer\Repository\VcsRepository');
  24872. $rm->setRepositoryClass('svn', 'Composer\Repository\VcsRepository');
  24873. $rm->setRepositoryClass('fossil', 'Composer\Repository\VcsRepository');
  24874. $rm->setRepositoryClass('perforce', 'Composer\Repository\VcsRepository');
  24875. $rm->setRepositoryClass('hg', 'Composer\Repository\VcsRepository');
  24876. $rm->setRepositoryClass('hg-bitbucket', 'Composer\Repository\VcsRepository');
  24877. $rm->setRepositoryClass('artifact', 'Composer\Repository\ArtifactRepository');
  24878. $rm->setRepositoryClass('path', 'Composer\Repository\PathRepository');
  24879. return $rm;
  24880. }
  24881. private static function createRepos(RepositoryManager $rm, array $repoConfigs)
  24882. {
  24883. $repos = array();
  24884. foreach ($repoConfigs as $index => $repo) {
  24885. if (is_string($repo)) {
  24886. throw new \UnexpectedValueException('"repositories" should be an array of repository definitions, only a single repository was given');
  24887. }
  24888. if (!is_array($repo)) {
  24889. throw new \UnexpectedValueException('Repository "'.$index.'" ('.json_encode($repo).') should be an array, '.gettype($repo).' given');
  24890. }
  24891. if (!isset($repo['type'])) {
  24892. throw new \UnexpectedValueException('Repository "'.$index.'" ('.json_encode($repo).') must have a type defined');
  24893. }
  24894. $name = self::generateRepositoryName($index, $repo, $repos);
  24895. if ($repo['type'] === 'filesystem') {
  24896. $repos[$name] = new FilesystemRepository($repo['json']);
  24897. } else {
  24898. $repos[$name] = $rm->createRepository($repo['type'], $repo, $index);
  24899. }
  24900. }
  24901. return $repos;
  24902. }
  24903. public static function generateRepositoryName($index, array $repo, array $existingRepos)
  24904. {
  24905. $name = is_int($index) && isset($repo['url']) ? preg_replace('{^https?://}i', '', $repo['url']) : $index;
  24906. while (isset($existingRepos[$name])) {
  24907. $name .= '2';
  24908. }
  24909. return $name;
  24910. }
  24911. }
  24912. <?php
  24913. namespace Composer\Repository;
  24914. use Composer\Package\PackageInterface;
  24915. use Composer\Package\BasePackage;
  24916. use Composer\Semver\Constraint\ConstraintInterface;
  24917. interface RepositoryInterface extends \Countable
  24918. {
  24919. const SEARCH_FULLTEXT = 0;
  24920. const SEARCH_NAME = 1;
  24921. public function hasPackage(PackageInterface $package);
  24922. public function findPackage($name, $constraint);
  24923. public function findPackages($name, $constraint = null);
  24924. public function getPackages();
  24925. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array());
  24926. public function search($query, $mode = 0, $type = null);
  24927. public function getProviders($packageName);
  24928. public function getRepoName();
  24929. }
  24930. <?php
  24931. namespace Composer\Repository;
  24932. use Composer\IO\IOInterface;
  24933. use Composer\Config;
  24934. use Composer\EventDispatcher\EventDispatcher;
  24935. use Composer\Package\PackageInterface;
  24936. use Composer\Util\HttpDownloader;
  24937. use Composer\Util\ProcessExecutor;
  24938. class RepositoryManager
  24939. {
  24940. private $localRepository;
  24941. private $repositories = array();
  24942. private $repositoryClasses = array();
  24943. private $io;
  24944. private $config;
  24945. private $httpDownloader;
  24946. private $eventDispatcher;
  24947. private $process;
  24948. public function __construct(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, ProcessExecutor $process = null)
  24949. {
  24950. $this->io = $io;
  24951. $this->config = $config;
  24952. $this->httpDownloader = $httpDownloader;
  24953. $this->eventDispatcher = $eventDispatcher;
  24954. $this->process = $process ?: new ProcessExecutor($io);
  24955. }
  24956. public function findPackage($name, $constraint)
  24957. {
  24958. foreach ($this->repositories as $repository) {
  24959. if ($package = $repository->findPackage($name, $constraint)) {
  24960. return $package;
  24961. }
  24962. }
  24963. return null;
  24964. }
  24965. public function findPackages($name, $constraint)
  24966. {
  24967. $packages = array();
  24968. foreach ($this->getRepositories() as $repository) {
  24969. $packages = array_merge($packages, $repository->findPackages($name, $constraint));
  24970. }
  24971. return $packages;
  24972. }
  24973. public function addRepository(RepositoryInterface $repository)
  24974. {
  24975. $this->repositories[] = $repository;
  24976. }
  24977. public function prependRepository(RepositoryInterface $repository)
  24978. {
  24979. array_unshift($this->repositories, $repository);
  24980. }
  24981. public function createRepository($type, $config, $name = null)
  24982. {
  24983. if (!isset($this->repositoryClasses[$type])) {
  24984. throw new \InvalidArgumentException('Repository type is not registered: '.$type);
  24985. }
  24986. if (isset($config['packagist']) && false === $config['packagist']) {
  24987. $this->io->writeError('<warning>Repository "'.$name.'" ('.json_encode($config).') has a packagist key which should be in its own repository definition</warning>');
  24988. }
  24989. $class = $this->repositoryClasses[$type];
  24990. if (isset($config['only']) || isset($config['exclude']) || isset($config['canonical'])) {
  24991. $filterConfig = $config;
  24992. unset($config['only'], $config['exclude'], $config['canonical']);
  24993. }
  24994. $repository = new $class($config, $this->io, $this->config, $this->httpDownloader, $this->eventDispatcher, $this->process);
  24995. if (isset($filterConfig)) {
  24996. $repository = new FilterRepository($repository, $filterConfig);
  24997. }
  24998. return $repository;
  24999. }
  25000. public function setRepositoryClass($type, $class)
  25001. {
  25002. $this->repositoryClasses[$type] = $class;
  25003. }
  25004. public function getRepositories()
  25005. {
  25006. return $this->repositories;
  25007. }
  25008. public function setLocalRepository(InstalledRepositoryInterface $repository)
  25009. {
  25010. $this->localRepository = $repository;
  25011. }
  25012. public function getLocalRepository()
  25013. {
  25014. return $this->localRepository;
  25015. }
  25016. }
  25017. <?php
  25018. namespace Composer\Repository;
  25019. class RepositorySecurityException extends \Exception
  25020. {
  25021. }
  25022. <?php
  25023. namespace Composer\Repository;
  25024. use Composer\DependencyResolver\Pool;
  25025. use Composer\DependencyResolver\PoolBuilder;
  25026. use Composer\DependencyResolver\Request;
  25027. use Composer\EventDispatcher\EventDispatcher;
  25028. use Composer\IO\IOInterface;
  25029. use Composer\IO\NullIO;
  25030. use Composer\Package\BasePackage;
  25031. use Composer\Package\AliasPackage;
  25032. use Composer\Package\Version\VersionParser;
  25033. use Composer\Repository\CompositeRepository;
  25034. use Composer\Repository\PlatformRepository;
  25035. use Composer\Repository\LockArrayRepository;
  25036. use Composer\Repository\InstalledRepositoryInterface;
  25037. use Composer\Repository\InstalledRepository;
  25038. use Composer\Semver\Constraint\ConstraintInterface;
  25039. use Composer\Package\Version\StabilityFilter;
  25040. class RepositorySet
  25041. {
  25042. const ALLOW_UNACCEPTABLE_STABILITIES = 1;
  25043. const ALLOW_SHADOWED_REPOSITORIES = 2;
  25044. private $rootAliases;
  25045. private $rootReferences;
  25046. private $repositories = array();
  25047. private $acceptableStabilities;
  25048. private $stabilityFlags;
  25049. private $rootRequires;
  25050. private $locked = false;
  25051. private $allowInstalledRepositories = false;
  25052. public function __construct($minimumStability = 'stable', array $stabilityFlags = array(), array $rootAliases = array(), array $rootReferences = array(), array $rootRequires = array())
  25053. {
  25054. $this->rootAliases = self::getRootAliasesPerPackage($rootAliases);
  25055. $this->rootReferences = $rootReferences;
  25056. $this->acceptableStabilities = array();
  25057. foreach (BasePackage::$stabilities as $stability => $value) {
  25058. if ($value <= BasePackage::$stabilities[$minimumStability]) {
  25059. $this->acceptableStabilities[$stability] = $value;
  25060. }
  25061. }
  25062. $this->stabilityFlags = $stabilityFlags;
  25063. $this->rootRequires = $rootRequires;
  25064. foreach ($rootRequires as $name => $constraint) {
  25065. if (PlatformRepository::isPlatformPackage($name)) {
  25066. unset($this->rootRequires[$name]);
  25067. }
  25068. }
  25069. }
  25070. public function allowInstalledRepositories($allow = true)
  25071. {
  25072. $this->allowInstalledRepositories = $allow;
  25073. }
  25074. public function getRootRequires()
  25075. {
  25076. return $this->rootRequires;
  25077. }
  25078. public function addRepository(RepositoryInterface $repo)
  25079. {
  25080. if ($this->locked) {
  25081. throw new \RuntimeException("Pool has already been created from this repository set, it cannot be modified anymore.");
  25082. }
  25083. if ($repo instanceof CompositeRepository) {
  25084. $repos = $repo->getRepositories();
  25085. } else {
  25086. $repos = array($repo);
  25087. }
  25088. foreach ($repos as $repo) {
  25089. $this->repositories[] = $repo;
  25090. }
  25091. }
  25092. public function findPackages($name, ConstraintInterface $constraint = null, $flags = 0)
  25093. {
  25094. $ignoreStability = ($flags & self::ALLOW_UNACCEPTABLE_STABILITIES) !== 0;
  25095. $loadFromAllRepos = ($flags & self::ALLOW_SHADOWED_REPOSITORIES) !== 0;
  25096. $packages = array();
  25097. if ($loadFromAllRepos) {
  25098. foreach ($this->repositories as $repository) {
  25099. $packages[] = $repository->findPackages($name, $constraint) ?: array();
  25100. }
  25101. } else {
  25102. foreach ($this->repositories as $repository) {
  25103. $result = $repository->loadPackages(array($name => $constraint), $ignoreStability ? BasePackage::$stabilities : $this->acceptableStabilities, $ignoreStability ? array() : $this->stabilityFlags);
  25104. $packages[] = $result['packages'];
  25105. foreach ($result['namesFound'] as $nameFound) {
  25106. if ($name === $nameFound) {
  25107. break 2;
  25108. }
  25109. }
  25110. }
  25111. }
  25112. $candidates = $packages ? call_user_func_array('array_merge', $packages) : array();
  25113. if ($ignoreStability || !$loadFromAllRepos) {
  25114. return $candidates;
  25115. }
  25116. $result = array();
  25117. foreach ($candidates as $candidate) {
  25118. if ($this->isPackageAcceptable($candidate->getNames(), $candidate->getStability())) {
  25119. $result[] = $candidate;
  25120. }
  25121. }
  25122. return $result;
  25123. }
  25124. public function getProviders($packageName)
  25125. {
  25126. $providers = array();
  25127. foreach ($this->repositories as $repository) {
  25128. if ($repoProviders = $repository->getProviders($packageName)) {
  25129. $providers = array_merge($providers, $repoProviders);
  25130. }
  25131. }
  25132. return $providers;
  25133. }
  25134. public function isPackageAcceptable($names, $stability)
  25135. {
  25136. return StabilityFilter::isPackageAcceptable($this->acceptableStabilities, $this->stabilityFlags, $names, $stability);
  25137. }
  25138. public function createPool(Request $request, IOInterface $io, EventDispatcher $eventDispatcher = null)
  25139. {
  25140. $poolBuilder = new PoolBuilder($this->acceptableStabilities, $this->stabilityFlags, $this->rootAliases, $this->rootReferences, $io, $eventDispatcher);
  25141. foreach ($this->repositories as $repo) {
  25142. if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) {
  25143. throw new \LogicException('The pool can not accept packages from an installed repository');
  25144. }
  25145. }
  25146. $this->locked = true;
  25147. return $poolBuilder->buildPool($this->repositories, $request);
  25148. }
  25149. public function createPoolWithAllPackages()
  25150. {
  25151. foreach ($this->repositories as $repo) {
  25152. if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) {
  25153. throw new \LogicException('The pool can not accept packages from an installed repository');
  25154. }
  25155. }
  25156. $this->locked = true;
  25157. $packages = array();
  25158. foreach ($this->repositories as $repository) {
  25159. foreach ($repository->getPackages() as $package) {
  25160. $packages[] = $package;
  25161. if (isset($this->rootAliases[$package->getName()][$package->getVersion()])) {
  25162. $alias = $this->rootAliases[$package->getName()][$package->getVersion()];
  25163. while ($package instanceof AliasPackage) {
  25164. $package = $package->getAliasOf();
  25165. }
  25166. $aliasPackage = new AliasPackage($package, $alias['alias_normalized'], $alias['alias']);
  25167. $aliasPackage->setRootPackageAlias(true);
  25168. $packages[] = $aliasPackage;
  25169. }
  25170. }
  25171. }
  25172. return new Pool($packages);
  25173. }
  25174. public function createPoolForPackage($packageName, LockArrayRepository $lockedRepo = null)
  25175. {
  25176. return $this->createPoolForPackages(array($packageName), $lockedRepo);
  25177. }
  25178. public function createPoolForPackages($packageNames, LockArrayRepository $lockedRepo = null)
  25179. {
  25180. $request = new Request($lockedRepo);
  25181. foreach ($packageNames as $packageName) {
  25182. if (PlatformRepository::isPlatformPackage($packageName)) {
  25183. 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.');
  25184. }
  25185. $request->requireName($packageName);
  25186. }
  25187. return $this->createPool($request, new NullIO());
  25188. }
  25189. private static function getRootAliasesPerPackage(array $aliases)
  25190. {
  25191. $normalizedAliases = array();
  25192. foreach ($aliases as $alias) {
  25193. $normalizedAliases[$alias['package']][$alias['version']] = array(
  25194. 'alias' => $alias['alias'],
  25195. 'alias_normalized' => $alias['alias_normalized'],
  25196. );
  25197. }
  25198. return $normalizedAliases;
  25199. }
  25200. }
  25201. <?php
  25202. namespace Composer\Repository;
  25203. use Composer\Package\RootPackageInterface;
  25204. class RootPackageRepository extends ArrayRepository
  25205. {
  25206. public function __construct(RootPackageInterface $package)
  25207. {
  25208. parent::__construct(array($package));
  25209. }
  25210. public function getRepoName()
  25211. {
  25212. return 'root package repo';
  25213. }
  25214. }
  25215. <?php
  25216. namespace Composer\Repository\Vcs;
  25217. use Composer\Cache;
  25218. use Composer\Downloader\TransportException;
  25219. use Composer\Json\JsonFile;
  25220. use Composer\Util\Bitbucket;
  25221. use Composer\Util\Http\Response;
  25222. abstract class BitbucketDriver extends VcsDriver
  25223. {
  25224. protected $owner;
  25225. protected $repository;
  25226. protected $hasIssues;
  25227. protected $rootIdentifier;
  25228. protected $tags;
  25229. protected $branches;
  25230. protected $branchesUrl = '';
  25231. protected $tagsUrl = '';
  25232. protected $homeUrl = '';
  25233. protected $website = '';
  25234. protected $cloneHttpsUrl = '';
  25235. protected $fallbackDriver;
  25236. protected $vcsType;
  25237. public function initialize()
  25238. {
  25239. preg_match('#^https?://bitbucket\.org/([^/]+)/([^/]+?)(\.git|/?)$#i', $this->url, $match);
  25240. $this->owner = $match[1];
  25241. $this->repository = $match[2];
  25242. $this->originUrl = 'bitbucket.org';
  25243. $this->cache = new Cache(
  25244. $this->io,
  25245. implode('/', array(
  25246. $this->config->get('cache-repo-dir'),
  25247. $this->originUrl,
  25248. $this->owner,
  25249. $this->repository,
  25250. ))
  25251. );
  25252. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  25253. }
  25254. public function getUrl()
  25255. {
  25256. if ($this->fallbackDriver) {
  25257. return $this->fallbackDriver->getUrl();
  25258. }
  25259. return $this->cloneHttpsUrl;
  25260. }
  25261. protected function getRepoData()
  25262. {
  25263. $resource = sprintf(
  25264. 'https://api.bitbucket.org/2.0/repositories/%s/%s?%s',
  25265. $this->owner,
  25266. $this->repository,
  25267. http_build_query(
  25268. array('fields' => '-project,-owner'),
  25269. null,
  25270. '&'
  25271. )
  25272. );
  25273. $repoData = $this->fetchWithOAuthCredentials($resource, true)->decodeJson();
  25274. if ($this->fallbackDriver) {
  25275. return false;
  25276. }
  25277. $this->parseCloneUrls($repoData['links']['clone']);
  25278. $this->hasIssues = !empty($repoData['has_issues']);
  25279. $this->branchesUrl = $repoData['links']['branches']['href'];
  25280. $this->tagsUrl = $repoData['links']['tags']['href'];
  25281. $this->homeUrl = $repoData['links']['html']['href'];
  25282. $this->website = $repoData['website'];
  25283. $this->vcsType = $repoData['scm'];
  25284. return true;
  25285. }
  25286. public function getComposerInformation($identifier)
  25287. {
  25288. if ($this->fallbackDriver) {
  25289. return $this->fallbackDriver->getComposerInformation($identifier);
  25290. }
  25291. if (!isset($this->infoCache[$identifier])) {
  25292. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  25293. $composer = JsonFile::parseJson($res);
  25294. } else {
  25295. $composer = $this->getBaseComposerInformation($identifier);
  25296. if ($this->shouldCache($identifier)) {
  25297. $this->cache->write($identifier, json_encode($composer));
  25298. }
  25299. }
  25300. if ($composer) {
  25301. if (!isset($composer['support']['source'])) {
  25302. $label = array_search(
  25303. $identifier,
  25304. $this->getTags()
  25305. ) ?: array_search(
  25306. $identifier,
  25307. $this->getBranches()
  25308. ) ?: $identifier;
  25309. if (array_key_exists($label, $tags = $this->getTags())) {
  25310. $hash = $tags[$label];
  25311. } elseif (array_key_exists($label, $branches = $this->getBranches())) {
  25312. $hash = $branches[$label];
  25313. }
  25314. if (! isset($hash)) {
  25315. $composer['support']['source'] = sprintf(
  25316. 'https://%s/%s/%s/src',
  25317. $this->originUrl,
  25318. $this->owner,
  25319. $this->repository
  25320. );
  25321. } else {
  25322. $composer['support']['source'] = sprintf(
  25323. 'https://%s/%s/%s/src/%s/?at=%s',
  25324. $this->originUrl,
  25325. $this->owner,
  25326. $this->repository,
  25327. $hash,
  25328. $label
  25329. );
  25330. }
  25331. }
  25332. if (!isset($composer['support']['issues']) && $this->hasIssues) {
  25333. $composer['support']['issues'] = sprintf(
  25334. 'https://%s/%s/%s/issues',
  25335. $this->originUrl,
  25336. $this->owner,
  25337. $this->repository
  25338. );
  25339. }
  25340. if (!isset($composer['homepage'])) {
  25341. $composer['homepage'] = empty($this->website) ? $this->homeUrl : $this->website;
  25342. }
  25343. }
  25344. $this->infoCache[$identifier] = $composer;
  25345. }
  25346. return $this->infoCache[$identifier];
  25347. }
  25348. public function getFileContent($file, $identifier)
  25349. {
  25350. if ($this->fallbackDriver) {
  25351. return $this->fallbackDriver->getFileContent($file, $identifier);
  25352. }
  25353. if (strpos($identifier, '/') !== false) {
  25354. $branches = $this->getBranches();
  25355. if (isset($branches[$identifier])) {
  25356. $identifier = $branches[$identifier];
  25357. }
  25358. }
  25359. $resource = sprintf(
  25360. 'https://api.bitbucket.org/2.0/repositories/%s/%s/src/%s/%s',
  25361. $this->owner,
  25362. $this->repository,
  25363. $identifier,
  25364. $file
  25365. );
  25366. return $this->fetchWithOAuthCredentials($resource)->getBody();
  25367. }
  25368. public function getChangeDate($identifier)
  25369. {
  25370. if ($this->fallbackDriver) {
  25371. return $this->fallbackDriver->getChangeDate($identifier);
  25372. }
  25373. if (strpos($identifier, '/') !== false) {
  25374. $branches = $this->getBranches();
  25375. if (isset($branches[$identifier])) {
  25376. $identifier = $branches[$identifier];
  25377. }
  25378. }
  25379. $resource = sprintf(
  25380. 'https://api.bitbucket.org/2.0/repositories/%s/%s/commit/%s?fields=date',
  25381. $this->owner,
  25382. $this->repository,
  25383. $identifier
  25384. );
  25385. $commit = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  25386. return new \DateTime($commit['date']);
  25387. }
  25388. public function getSource($identifier)
  25389. {
  25390. if ($this->fallbackDriver) {
  25391. return $this->fallbackDriver->getSource($identifier);
  25392. }
  25393. return array('type' => $this->vcsType, 'url' => $this->getUrl(), 'reference' => $identifier);
  25394. }
  25395. public function getDist($identifier)
  25396. {
  25397. if ($this->fallbackDriver) {
  25398. return $this->fallbackDriver->getDist($identifier);
  25399. }
  25400. $url = sprintf(
  25401. 'https://bitbucket.org/%s/%s/get/%s.zip',
  25402. $this->owner,
  25403. $this->repository,
  25404. $identifier
  25405. );
  25406. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  25407. }
  25408. public function getTags()
  25409. {
  25410. if ($this->fallbackDriver) {
  25411. return $this->fallbackDriver->getTags();
  25412. }
  25413. if (null === $this->tags) {
  25414. $this->tags = array();
  25415. $resource = sprintf(
  25416. '%s?%s',
  25417. $this->tagsUrl,
  25418. http_build_query(
  25419. array(
  25420. 'pagelen' => 100,
  25421. 'fields' => 'values.name,values.target.hash,next',
  25422. 'sort' => '-target.date',
  25423. ),
  25424. null,
  25425. '&'
  25426. )
  25427. );
  25428. $hasNext = true;
  25429. while ($hasNext) {
  25430. $tagsData = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  25431. foreach ($tagsData['values'] as $data) {
  25432. $this->tags[$data['name']] = $data['target']['hash'];
  25433. }
  25434. if (empty($tagsData['next'])) {
  25435. $hasNext = false;
  25436. } else {
  25437. $resource = $tagsData['next'];
  25438. }
  25439. }
  25440. if ($this->vcsType === 'hg') {
  25441. unset($this->tags['tip']);
  25442. }
  25443. }
  25444. return $this->tags;
  25445. }
  25446. public function getBranches()
  25447. {
  25448. if ($this->fallbackDriver) {
  25449. return $this->fallbackDriver->getBranches();
  25450. }
  25451. if (null === $this->branches) {
  25452. $this->branches = array();
  25453. $resource = sprintf(
  25454. '%s?%s',
  25455. $this->branchesUrl,
  25456. http_build_query(
  25457. array(
  25458. 'pagelen' => 100,
  25459. 'fields' => 'values.name,values.target.hash,values.heads,next',
  25460. 'sort' => '-target.date',
  25461. ),
  25462. null,
  25463. '&'
  25464. )
  25465. );
  25466. $hasNext = true;
  25467. while ($hasNext) {
  25468. $branchData = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  25469. foreach ($branchData['values'] as $data) {
  25470. if ($this->vcsType === 'hg' && empty($data['heads'])) {
  25471. continue;
  25472. }
  25473. $this->branches[$data['name']] = $data['target']['hash'];
  25474. }
  25475. if (empty($branchData['next'])) {
  25476. $hasNext = false;
  25477. } else {
  25478. $resource = $branchData['next'];
  25479. }
  25480. }
  25481. }
  25482. return $this->branches;
  25483. }
  25484. protected function fetchWithOAuthCredentials($url, $fetchingRepoData = false)
  25485. {
  25486. try {
  25487. return parent::getContents($url);
  25488. } catch (TransportException $e) {
  25489. $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process, $this->httpDownloader);
  25490. if (403 === $e->getCode() || (401 === $e->getCode() && strpos($e->getMessage(), 'Could not authenticate against') === 0)) {
  25491. if (!$this->io->hasAuthentication($this->originUrl)
  25492. && $bitbucketUtil->authorizeOAuth($this->originUrl)
  25493. ) {
  25494. return parent::getContents($url);
  25495. }
  25496. if (!$this->io->isInteractive() && $fetchingRepoData) {
  25497. if ($this->attemptCloneFallback()) {
  25498. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  25499. }
  25500. }
  25501. }
  25502. throw $e;
  25503. }
  25504. }
  25505. abstract protected function generateSshUrl();
  25506. protected function attemptCloneFallback()
  25507. {
  25508. try {
  25509. $this->setupFallbackDriver($this->generateSshUrl());
  25510. return true;
  25511. } catch (\RuntimeException $e) {
  25512. $this->fallbackDriver = null;
  25513. $this->io->writeError(
  25514. '<error>Failed to clone the ' . $this->generateSshUrl() . ' repository, try running in interactive mode'
  25515. . ' so that you can enter your Bitbucket OAuth consumer credentials</error>'
  25516. );
  25517. throw $e;
  25518. }
  25519. }
  25520. abstract protected function setupFallbackDriver($url);
  25521. protected function parseCloneUrls(array $cloneLinks)
  25522. {
  25523. foreach ($cloneLinks as $cloneLink) {
  25524. if ($cloneLink['name'] === 'https') {
  25525. $this->cloneHttpsUrl = preg_replace('/https:\/\/([^@]+@)?/', 'https://', $cloneLink['href']);
  25526. }
  25527. }
  25528. }
  25529. protected function getMainBranchData()
  25530. {
  25531. $resource = sprintf(
  25532. 'https://api.bitbucket.org/2.0/repositories/%s/%s?fields=mainbranch',
  25533. $this->owner,
  25534. $this->repository
  25535. );
  25536. $data = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  25537. if (isset($data['mainbranch'])) {
  25538. return $data['mainbranch'];
  25539. }
  25540. return null;
  25541. }
  25542. }
  25543. <?php
  25544. namespace Composer\Repository\Vcs;
  25545. use Composer\Cache;
  25546. use Composer\Config;
  25547. use Composer\Util\ProcessExecutor;
  25548. use Composer\Util\Filesystem;
  25549. use Composer\IO\IOInterface;
  25550. class FossilDriver extends VcsDriver
  25551. {
  25552. protected $tags;
  25553. protected $branches;
  25554. protected $rootIdentifier;
  25555. protected $repoFile;
  25556. protected $checkoutDir;
  25557. public function initialize()
  25558. {
  25559. $this->checkFossil();
  25560. $this->config->prohibitUrlByConfig($this->url, $this->io);
  25561. if (Filesystem::isLocalPath($this->url) && is_dir($this->url)) {
  25562. $this->checkoutDir = $this->url;
  25563. } else {
  25564. if (!Cache::isUsable($this->config->get('cache-repo-dir')) || !Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  25565. throw new \RuntimeException('FossilDriver requires a usable cache directory, and it looks like you set it to be disabled');
  25566. }
  25567. $localName = preg_replace('{[^a-z0-9]}i', '-', $this->url);
  25568. $this->repoFile = $this->config->get('cache-repo-dir') . '/' . $localName . '.fossil';
  25569. $this->checkoutDir = $this->config->get('cache-vcs-dir') . '/' . $localName . '/';
  25570. $this->updateLocalRepo();
  25571. }
  25572. $this->getTags();
  25573. $this->getBranches();
  25574. }
  25575. protected function checkFossil()
  25576. {
  25577. if (0 !== $this->process->execute('fossil version', $ignoredOutput)) {
  25578. throw new \RuntimeException("fossil was not found, check that it is installed and in your PATH env.\n\n" . $this->process->getErrorOutput());
  25579. }
  25580. }
  25581. protected function updateLocalRepo()
  25582. {
  25583. $fs = new Filesystem();
  25584. $fs->ensureDirectoryExists($this->checkoutDir);
  25585. if (!is_writable(dirname($this->checkoutDir))) {
  25586. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.$this->checkoutDir.'" directory is not writable by the current user.');
  25587. }
  25588. if (is_file($this->repoFile) && is_dir($this->checkoutDir) && 0 === $this->process->execute('fossil info', $output, $this->checkoutDir)) {
  25589. if (0 !== $this->process->execute('fossil pull', $output, $this->checkoutDir)) {
  25590. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
  25591. }
  25592. } else {
  25593. $fs->removeDirectory($this->checkoutDir);
  25594. $fs->remove($this->repoFile);
  25595. $fs->ensureDirectoryExists($this->checkoutDir);
  25596. if (0 !== $this->process->execute(sprintf('fossil clone %s %s', ProcessExecutor::escape($this->url), ProcessExecutor::escape($this->repoFile)), $output)) {
  25597. $output = $this->process->getErrorOutput();
  25598. throw new \RuntimeException('Failed to clone '.$this->url.' to repository ' . $this->repoFile . "\n\n" .$output);
  25599. }
  25600. if (0 !== $this->process->execute(sprintf('fossil open %s --nested', ProcessExecutor::escape($this->repoFile)), $output, $this->checkoutDir)) {
  25601. $output = $this->process->getErrorOutput();
  25602. throw new \RuntimeException('Failed to open repository '.$this->repoFile.' in ' . $this->checkoutDir . "\n\n" .$output);
  25603. }
  25604. }
  25605. }
  25606. public function getRootIdentifier()
  25607. {
  25608. if (null === $this->rootIdentifier) {
  25609. $this->rootIdentifier = 'trunk';
  25610. }
  25611. return $this->rootIdentifier;
  25612. }
  25613. public function getUrl()
  25614. {
  25615. return $this->url;
  25616. }
  25617. public function getSource($identifier)
  25618. {
  25619. return array('type' => 'fossil', 'url' => $this->getUrl(), 'reference' => $identifier);
  25620. }
  25621. public function getDist($identifier)
  25622. {
  25623. return null;
  25624. }
  25625. public function getFileContent($file, $identifier)
  25626. {
  25627. $command = sprintf('fossil cat -r %s %s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  25628. $this->process->execute($command, $content, $this->checkoutDir);
  25629. if (!trim($content)) {
  25630. return null;
  25631. }
  25632. return $content;
  25633. }
  25634. public function getChangeDate($identifier)
  25635. {
  25636. $this->process->execute('fossil finfo -b -n 1 composer.json', $output, $this->checkoutDir);
  25637. list(,$date) = explode(' ', trim($output), 3);
  25638. return new \DateTime($date, new \DateTimeZone('UTC'));
  25639. }
  25640. public function getTags()
  25641. {
  25642. if (null === $this->tags) {
  25643. $tags = array();
  25644. $this->process->execute('fossil tag list', $output, $this->checkoutDir);
  25645. foreach ($this->process->splitLines($output) as $tag) {
  25646. $tags[$tag] = $tag;
  25647. }
  25648. $this->tags = $tags;
  25649. }
  25650. return $this->tags;
  25651. }
  25652. public function getBranches()
  25653. {
  25654. if (null === $this->branches) {
  25655. $branches = array();
  25656. $this->process->execute('fossil branch list', $output, $this->checkoutDir);
  25657. foreach ($this->process->splitLines($output) as $branch) {
  25658. $branch = trim(preg_replace('/^\*/', '', trim($branch)));
  25659. $branches[$branch] = $branch;
  25660. }
  25661. $this->branches = $branches;
  25662. }
  25663. return $this->branches;
  25664. }
  25665. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  25666. {
  25667. if (preg_match('#(^(?:https?|ssh)://(?:[^@]@)?(?:chiselapp\.com|fossil\.))#i', $url)) {
  25668. return true;
  25669. }
  25670. if (preg_match('!/fossil/|\.fossil!', $url)) {
  25671. return true;
  25672. }
  25673. if (Filesystem::isLocalPath($url)) {
  25674. $url = Filesystem::getPlatformPath($url);
  25675. if (!is_dir($url)) {
  25676. return false;
  25677. }
  25678. $process = new ProcessExecutor($io);
  25679. if ($process->execute('fossil info', $output, $url) === 0) {
  25680. return true;
  25681. }
  25682. }
  25683. return false;
  25684. }
  25685. }
  25686. <?php
  25687. namespace Composer\Repository\Vcs;
  25688. use Composer\Config;
  25689. use Composer\IO\IOInterface;
  25690. class GitBitbucketDriver extends BitbucketDriver
  25691. {
  25692. public function getRootIdentifier()
  25693. {
  25694. if ($this->fallbackDriver) {
  25695. return $this->fallbackDriver->getRootIdentifier();
  25696. }
  25697. if (null === $this->rootIdentifier) {
  25698. if (! $this->getRepoData()) {
  25699. return $this->fallbackDriver->getRootIdentifier();
  25700. }
  25701. if ($this->vcsType !== 'git') {
  25702. throw new \RuntimeException(
  25703. $this->url.' does not appear to be a git repository, use '.
  25704. $this->cloneHttpsUrl.' if this is a mercurial bitbucket repository'
  25705. );
  25706. }
  25707. $mainBranchData = $this->getMainBranchData();
  25708. $this->rootIdentifier = !empty($mainBranchData['name']) ? $mainBranchData['name'] : 'master';
  25709. }
  25710. return $this->rootIdentifier;
  25711. }
  25712. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  25713. {
  25714. if (!preg_match('#^https?://bitbucket\.org/([^/]+)/(.+?)\.git$#i', $url)) {
  25715. return false;
  25716. }
  25717. if (!extension_loaded('openssl')) {
  25718. $io->writeError('Skipping Bitbucket git driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  25719. return false;
  25720. }
  25721. return true;
  25722. }
  25723. protected function setupFallbackDriver($url)
  25724. {
  25725. $this->fallbackDriver = new GitDriver(
  25726. array('url' => $url),
  25727. $this->io,
  25728. $this->config,
  25729. $this->httpDownloader,
  25730. $this->process
  25731. );
  25732. $this->fallbackDriver->initialize();
  25733. }
  25734. protected function generateSshUrl()
  25735. {
  25736. return 'git@' . $this->originUrl . ':' . $this->owner.'/'.$this->repository.'.git';
  25737. }
  25738. }
  25739. <?php
  25740. namespace Composer\Repository\Vcs;
  25741. use Composer\Util\ProcessExecutor;
  25742. use Composer\Util\Filesystem;
  25743. use Composer\Util\Url;
  25744. use Composer\Util\Git as GitUtil;
  25745. use Composer\IO\IOInterface;
  25746. use Composer\Cache;
  25747. use Composer\Config;
  25748. class GitDriver extends VcsDriver
  25749. {
  25750. protected $tags;
  25751. protected $branches;
  25752. protected $rootIdentifier;
  25753. protected $repoDir;
  25754. public function initialize()
  25755. {
  25756. if (Filesystem::isLocalPath($this->url)) {
  25757. $this->url = preg_replace('{[\\/]\.git/?$}', '', $this->url);
  25758. $this->repoDir = $this->url;
  25759. $cacheUrl = realpath($this->url);
  25760. } else {
  25761. if (!Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  25762. throw new \RuntimeException('GitDriver requires a usable cache directory, and it looks like you set it to be disabled');
  25763. }
  25764. $this->repoDir = $this->config->get('cache-vcs-dir') . '/' . preg_replace('{[^a-z0-9.]}i', '-', $this->url) . '/';
  25765. GitUtil::cleanEnv();
  25766. $fs = new Filesystem();
  25767. $fs->ensureDirectoryExists(dirname($this->repoDir));
  25768. if (!is_writable(dirname($this->repoDir))) {
  25769. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.dirname($this->repoDir).'" directory is not writable by the current user.');
  25770. }
  25771. if (preg_match('{^ssh://[^@]+@[^:]+:[^0-9]+}', $this->url)) {
  25772. 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.');
  25773. }
  25774. $gitUtil = new GitUtil($this->io, $this->config, $this->process, $fs);
  25775. if (!$gitUtil->syncMirror($this->url, $this->repoDir)) {
  25776. if (!is_dir($this->repoDir)) {
  25777. throw new \RuntimeException('Failed to clone '.$this->url.' to read package information from it');
  25778. }
  25779. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated</error>');
  25780. }
  25781. $cacheUrl = $this->url;
  25782. }
  25783. $this->getTags();
  25784. $this->getBranches();
  25785. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', Url::sanitize($cacheUrl)));
  25786. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  25787. }
  25788. public function getRootIdentifier()
  25789. {
  25790. if (null === $this->rootIdentifier) {
  25791. $this->rootIdentifier = 'master';
  25792. $this->process->execute('git branch --no-color', $output, $this->repoDir);
  25793. $branches = $this->process->splitLines($output);
  25794. if (!in_array('* master', $branches)) {
  25795. foreach ($branches as $branch) {
  25796. if ($branch && preg_match('{^\* +(\S+)}', $branch, $match)) {
  25797. $this->rootIdentifier = $match[1];
  25798. break;
  25799. }
  25800. }
  25801. }
  25802. }
  25803. return $this->rootIdentifier;
  25804. }
  25805. public function getUrl()
  25806. {
  25807. return $this->url;
  25808. }
  25809. public function getSource($identifier)
  25810. {
  25811. return array('type' => 'git', 'url' => $this->getUrl(), 'reference' => $identifier);
  25812. }
  25813. public function getDist($identifier)
  25814. {
  25815. return null;
  25816. }
  25817. public function getFileContent($file, $identifier)
  25818. {
  25819. $resource = sprintf('%s:%s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  25820. $this->process->execute(sprintf('git show %s', $resource), $content, $this->repoDir);
  25821. if (!trim($content)) {
  25822. return null;
  25823. }
  25824. return $content;
  25825. }
  25826. public function getChangeDate($identifier)
  25827. {
  25828. $this->process->execute(sprintf(
  25829. 'git -c log.showSignature=false log -1 --format=%%at %s',
  25830. ProcessExecutor::escape($identifier)
  25831. ), $output, $this->repoDir);
  25832. return new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
  25833. }
  25834. public function getTags()
  25835. {
  25836. if (null === $this->tags) {
  25837. $this->tags = array();
  25838. $this->process->execute('git show-ref --tags --dereference', $output, $this->repoDir);
  25839. foreach ($output = $this->process->splitLines($output) as $tag) {
  25840. if ($tag && preg_match('{^([a-f0-9]{40}) refs/tags/(\S+?)(\^\{\})?$}', $tag, $match)) {
  25841. $this->tags[$match[2]] = $match[1];
  25842. }
  25843. }
  25844. }
  25845. return $this->tags;
  25846. }
  25847. public function getBranches()
  25848. {
  25849. if (null === $this->branches) {
  25850. $branches = array();
  25851. $this->process->execute('git branch --no-color --no-abbrev -v', $output, $this->repoDir);
  25852. foreach ($this->process->splitLines($output) as $branch) {
  25853. if ($branch && !preg_match('{^ *[^/]+/HEAD }', $branch)) {
  25854. if (preg_match('{^(?:\* )? *(\S+) *([a-f0-9]+)(?: .*)?$}', $branch, $match)) {
  25855. $branches[$match[1]] = $match[2];
  25856. }
  25857. }
  25858. }
  25859. $this->branches = $branches;
  25860. }
  25861. return $this->branches;
  25862. }
  25863. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  25864. {
  25865. if (preg_match('#(^git://|\.git/?$|git(?:olite)?@|//git\.|//github.com/)#i', $url)) {
  25866. return true;
  25867. }
  25868. if (Filesystem::isLocalPath($url)) {
  25869. $url = Filesystem::getPlatformPath($url);
  25870. if (!is_dir($url)) {
  25871. return false;
  25872. }
  25873. $process = new ProcessExecutor($io);
  25874. if ($process->execute('git tag', $output, $url) === 0) {
  25875. return true;
  25876. }
  25877. }
  25878. if (!$deep) {
  25879. return false;
  25880. }
  25881. $gitUtil = new GitUtil($io, $config, new ProcessExecutor($io), new Filesystem());
  25882. GitUtil::cleanEnv();
  25883. try {
  25884. $gitUtil->runCommand(function ($url) {
  25885. return 'git ls-remote --heads ' . ProcessExecutor::escape($url);
  25886. }, $url, sys_get_temp_dir());
  25887. } catch (\RuntimeException $e) {
  25888. return false;
  25889. }
  25890. return true;
  25891. }
  25892. }
  25893. <?php
  25894. namespace Composer\Repository\Vcs;
  25895. use Composer\Config;
  25896. use Composer\Downloader\TransportException;
  25897. use Composer\Json\JsonFile;
  25898. use Composer\Cache;
  25899. use Composer\IO\IOInterface;
  25900. use Composer\Util\GitHub;
  25901. use Composer\Util\Http\Response;
  25902. class GitHubDriver extends VcsDriver
  25903. {
  25904. protected $owner;
  25905. protected $repository;
  25906. protected $tags;
  25907. protected $branches;
  25908. protected $rootIdentifier;
  25909. protected $repoData;
  25910. protected $hasIssues;
  25911. protected $isPrivate = false;
  25912. private $isArchived = false;
  25913. private $fundingInfo;
  25914. protected $gitDriver;
  25915. public function initialize()
  25916. {
  25917. preg_match('#^(?:(?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/(.+?)(?:\.git|/)?$#', $this->url, $match);
  25918. $this->owner = $match[3];
  25919. $this->repository = $match[4];
  25920. $this->originUrl = strtolower(!empty($match[1]) ? $match[1] : $match[2]);
  25921. if ($this->originUrl === 'www.github.com') {
  25922. $this->originUrl = 'github.com';
  25923. }
  25924. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->owner.'/'.$this->repository);
  25925. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  25926. if ( $this->config->get('use-github-api') === false || (isset($this->repoConfig['no-api']) && $this->repoConfig['no-api'] ) ){
  25927. $this->setupGitDriver($this->url);
  25928. return;
  25929. }
  25930. $this->fetchRootIdentifier();
  25931. }
  25932. public function getRepositoryUrl()
  25933. {
  25934. return 'https://'.$this->originUrl.'/'.$this->owner.'/'.$this->repository;
  25935. }
  25936. public function getRootIdentifier()
  25937. {
  25938. if ($this->gitDriver) {
  25939. return $this->gitDriver->getRootIdentifier();
  25940. }
  25941. return $this->rootIdentifier;
  25942. }
  25943. public function getUrl()
  25944. {
  25945. if ($this->gitDriver) {
  25946. return $this->gitDriver->getUrl();
  25947. }
  25948. return 'https://' . $this->originUrl . '/'.$this->owner.'/'.$this->repository.'.git';
  25949. }
  25950. protected function getApiUrl()
  25951. {
  25952. if ('github.com' === $this->originUrl) {
  25953. $apiUrl = 'api.github.com';
  25954. } else {
  25955. $apiUrl = $this->originUrl . '/api/v3';
  25956. }
  25957. return 'https://' . $apiUrl;
  25958. }
  25959. public function getSource($identifier)
  25960. {
  25961. if ($this->gitDriver) {
  25962. return $this->gitDriver->getSource($identifier);
  25963. }
  25964. if ($this->isPrivate) {
  25965. $url = $this->generateSshUrl();
  25966. } else {
  25967. $url = $this->getUrl();
  25968. }
  25969. return array('type' => 'git', 'url' => $url, 'reference' => $identifier);
  25970. }
  25971. public function getDist($identifier)
  25972. {
  25973. $url = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/zipball/'.$identifier;
  25974. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  25975. }
  25976. public function getComposerInformation($identifier)
  25977. {
  25978. if ($this->gitDriver) {
  25979. return $this->gitDriver->getComposerInformation($identifier);
  25980. }
  25981. if (!isset($this->infoCache[$identifier])) {
  25982. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  25983. $composer = JsonFile::parseJson($res);
  25984. } else {
  25985. $composer = $this->getBaseComposerInformation($identifier);
  25986. if ($this->shouldCache($identifier)) {
  25987. $this->cache->write($identifier, json_encode($composer));
  25988. }
  25989. }
  25990. if ($composer) {
  25991. if (!isset($composer['support']['source'])) {
  25992. $label = array_search($identifier, $this->getTags()) ?: array_search($identifier, $this->getBranches()) ?: $identifier;
  25993. $composer['support']['source'] = sprintf('https://%s/%s/%s/tree/%s', $this->originUrl, $this->owner, $this->repository, $label);
  25994. }
  25995. if (!isset($composer['support']['issues']) && $this->hasIssues) {
  25996. $composer['support']['issues'] = sprintf('https://%s/%s/%s/issues', $this->originUrl, $this->owner, $this->repository);
  25997. }
  25998. if (!isset($composer['abandoned']) && $this->isArchived) {
  25999. $composer['abandoned'] = true;
  26000. }
  26001. if (!isset($composer['funding']) && $funding = $this->getFundingInfo()) {
  26002. $composer['funding'] = $funding;
  26003. }
  26004. }
  26005. $this->infoCache[$identifier] = $composer;
  26006. }
  26007. return $this->infoCache[$identifier];
  26008. }
  26009. private function getFundingInfo()
  26010. {
  26011. if (null !== $this->fundingInfo) {
  26012. return $this->fundingInfo;
  26013. }
  26014. if ($this->originUrl !== 'github.com') {
  26015. return $this->fundingInfo = false;
  26016. }
  26017. foreach (array($this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/.github/FUNDING.yml', $this->getApiUrl() . '/repos/'.$this->owner.'/.github/contents/FUNDING.yml') as $file) {
  26018. try {
  26019. $response = $this->httpDownloader->get($file, array(
  26020. 'retry-auth-failure' => false,
  26021. ))->decodeJson();
  26022. } catch (TransportException $e) {
  26023. continue;
  26024. }
  26025. if (empty($response['content']) || $response['encoding'] !== 'base64' || !($funding = base64_decode($response['content']))) {
  26026. continue;
  26027. }
  26028. break;
  26029. }
  26030. if (empty($funding)) {
  26031. return $this->fundingInfo = false;
  26032. }
  26033. $result = array();
  26034. $key = null;
  26035. foreach (preg_split('{\r?\n}', $funding) as $line) {
  26036. $line = trim($line);
  26037. if (preg_match('{^(\w+)\s*:\s*(.+)$}', $line, $match)) {
  26038. if (preg_match('{^\[(.*)\](?:\s*#.*)?$}', $match[2], $match2)) {
  26039. foreach (array_map('trim', preg_split('{[\'"]?\s*,\s*[\'"]?}', $match2[1])) as $item) {
  26040. $result[] = array('type' => $match[1], 'url' => trim($item, '"\' '));
  26041. }
  26042. } elseif (preg_match('{^([^#].*?)(\s+#.*)?$}', $match[2], $match2)) {
  26043. $result[] = array('type' => $match[1], 'url' => trim($match2[1], '"\' '));
  26044. }
  26045. $key = null;
  26046. } elseif (preg_match('{^(\w+)\s*:\s*#\s*$}', $line, $match)) {
  26047. $key = $match[1];
  26048. } elseif ($key && preg_match('{^-\s*(.+)(\s+#.*)?$}', $line, $match)) {
  26049. $result[] = array('type' => $key, 'url' => trim($match[1], '"\' '));
  26050. }
  26051. }
  26052. foreach ($result as $key => $item) {
  26053. switch ($item['type']) {
  26054. case 'tidelift':
  26055. $result[$key]['url'] = 'https://tidelift.com/funding/github/' . $item['url'];
  26056. break;
  26057. case 'github':
  26058. $result[$key]['url'] = 'https://github.com/' . basename($item['url']);
  26059. break;
  26060. case 'patreon':
  26061. $result[$key]['url'] = 'https://www.patreon.com/' . basename($item['url']);
  26062. break;
  26063. case 'otechie':
  26064. $result[$key]['url'] = 'https://otechie.com/' . basename($item['url']);
  26065. break;
  26066. case 'open_collective':
  26067. $result[$key]['url'] = 'https://opencollective.com/' . basename($item['url']);
  26068. break;
  26069. case 'liberapay':
  26070. $result[$key]['url'] = 'https://liberapay.com/' . basename($item['url']);
  26071. break;
  26072. case 'ko_fi':
  26073. $result[$key]['url'] = 'https://ko-fi.com/' . basename($item['url']);
  26074. break;
  26075. case 'issuehunt':
  26076. $result[$key]['url'] = 'https://issuehunt.io/r/' . $item['url'];
  26077. break;
  26078. case 'community_bridge':
  26079. $result[$key]['url'] = 'https://funding.communitybridge.org/projects/' . basename($item['url']);
  26080. break;
  26081. }
  26082. }
  26083. return $this->fundingInfo = $result;
  26084. }
  26085. public function getFileContent($file, $identifier)
  26086. {
  26087. if ($this->gitDriver) {
  26088. return $this->gitDriver->getFileContent($file, $identifier);
  26089. }
  26090. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/' . $file . '?ref='.urlencode($identifier);
  26091. $resource = $this->getContents($resource)->decodeJson();
  26092. if (empty($resource['content']) || $resource['encoding'] !== 'base64' || !($content = base64_decode($resource['content']))) {
  26093. throw new \RuntimeException('Could not retrieve ' . $file . ' for '.$identifier);
  26094. }
  26095. return $content;
  26096. }
  26097. public function getChangeDate($identifier)
  26098. {
  26099. if ($this->gitDriver) {
  26100. return $this->gitDriver->getChangeDate($identifier);
  26101. }
  26102. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/commits/'.urlencode($identifier);
  26103. $commit = $this->getContents($resource)->decodeJson();
  26104. return new \DateTime($commit['commit']['committer']['date']);
  26105. }
  26106. public function getTags()
  26107. {
  26108. if ($this->gitDriver) {
  26109. return $this->gitDriver->getTags();
  26110. }
  26111. if (null === $this->tags) {
  26112. $this->tags = array();
  26113. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/tags?per_page=100';
  26114. do {
  26115. $response = $this->getContents($resource);
  26116. $tagsData = $response->decodeJson();
  26117. foreach ($tagsData as $tag) {
  26118. $this->tags[$tag['name']] = $tag['commit']['sha'];
  26119. }
  26120. $resource = $this->getNextPage($response);
  26121. } while ($resource);
  26122. }
  26123. return $this->tags;
  26124. }
  26125. public function getBranches()
  26126. {
  26127. if ($this->gitDriver) {
  26128. return $this->gitDriver->getBranches();
  26129. }
  26130. if (null === $this->branches) {
  26131. $this->branches = array();
  26132. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/git/refs/heads?per_page=100';
  26133. do {
  26134. $response = $this->getContents($resource);
  26135. $branchData = $response->decodeJson();
  26136. foreach ($branchData as $branch) {
  26137. $name = substr($branch['ref'], 11);
  26138. if ($name !== 'gh-pages') {
  26139. $this->branches[$name] = $branch['object']['sha'];
  26140. }
  26141. }
  26142. $resource = $this->getNextPage($response);
  26143. } while ($resource);
  26144. }
  26145. return $this->branches;
  26146. }
  26147. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  26148. {
  26149. if (!preg_match('#^((?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/(.+?)(?:\.git|/)?$#', $url, $matches)) {
  26150. return false;
  26151. }
  26152. $originUrl = !empty($matches[2]) ? $matches[2] : $matches[3];
  26153. if (!in_array(strtolower(preg_replace('{^www\.}i', '', $originUrl)), $config->get('github-domains'))) {
  26154. return false;
  26155. }
  26156. if (!extension_loaded('openssl')) {
  26157. $io->writeError('Skipping GitHub driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  26158. return false;
  26159. }
  26160. return true;
  26161. }
  26162. public function getRepoData()
  26163. {
  26164. $this->fetchRootIdentifier();
  26165. return $this->repoData;
  26166. }
  26167. protected function generateSshUrl()
  26168. {
  26169. if (false !== strpos($this->originUrl, ':')) {
  26170. return 'ssh://git@' . $this->originUrl . '/'.$this->owner.'/'.$this->repository.'.git';
  26171. }
  26172. return 'git@' . $this->originUrl . ':'.$this->owner.'/'.$this->repository.'.git';
  26173. }
  26174. protected function getContents($url, $fetchingRepoData = false)
  26175. {
  26176. try {
  26177. return parent::getContents($url);
  26178. } catch (TransportException $e) {
  26179. $gitHubUtil = new GitHub($this->io, $this->config, $this->process, $this->httpDownloader);
  26180. switch ($e->getCode()) {
  26181. case 401:
  26182. case 404:
  26183. if (!$fetchingRepoData) {
  26184. throw $e;
  26185. }
  26186. if ($gitHubUtil->authorizeOAuth($this->originUrl)) {
  26187. return parent::getContents($url);
  26188. }
  26189. if (!$this->io->isInteractive()) {
  26190. if ($this->attemptCloneFallback()) {
  26191. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  26192. }
  26193. }
  26194. $scopesIssued = array();
  26195. $scopesNeeded = array();
  26196. if ($headers = $e->getHeaders()) {
  26197. if ($scopes = Response::findHeaderValue($headers, 'X-OAuth-Scopes')) {
  26198. $scopesIssued = explode(' ', $scopes);
  26199. }
  26200. if ($scopes = Response::findHeaderValue($headers, 'X-Accepted-OAuth-Scopes')) {
  26201. $scopesNeeded = explode(' ', $scopes);
  26202. }
  26203. }
  26204. $scopesFailed = array_diff($scopesNeeded, $scopesIssued);
  26205. if (!$headers || !count($scopesNeeded) || count($scopesFailed)) {
  26206. $gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'Your GitHub credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
  26207. }
  26208. return parent::getContents($url);
  26209. case 403:
  26210. if (!$this->io->hasAuthentication($this->originUrl) && $gitHubUtil->authorizeOAuth($this->originUrl)) {
  26211. return parent::getContents($url);
  26212. }
  26213. if (!$this->io->isInteractive() && $fetchingRepoData) {
  26214. if ($this->attemptCloneFallback()) {
  26215. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  26216. }
  26217. }
  26218. $rateLimited = $gitHubUtil->isRateLimited($e->getHeaders());
  26219. if (!$this->io->hasAuthentication($this->originUrl)) {
  26220. if (!$this->io->isInteractive()) {
  26221. $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>');
  26222. throw $e;
  26223. }
  26224. $gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'API limit exhausted. Enter your GitHub credentials to get a larger API limit (<info>'.$this->url.'</info>)');
  26225. return parent::getContents($url);
  26226. }
  26227. if ($rateLimited) {
  26228. $rateLimit = $gitHubUtil->getRateLimit($e->getHeaders());
  26229. $this->io->writeError(sprintf(
  26230. '<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>',
  26231. $rateLimit['limit'],
  26232. $rateLimit['reset']
  26233. ));
  26234. }
  26235. throw $e;
  26236. default:
  26237. throw $e;
  26238. }
  26239. }
  26240. }
  26241. protected function fetchRootIdentifier()
  26242. {
  26243. if ($this->repoData) {
  26244. return;
  26245. }
  26246. $repoDataUrl = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository;
  26247. try {
  26248. $this->repoData = $this->getContents($repoDataUrl, true)->decodeJson();
  26249. } catch (TransportException $e) {
  26250. if ($e->getCode() === 499) {
  26251. $this->attemptCloneFallback();
  26252. } else {
  26253. throw $e;
  26254. }
  26255. }
  26256. if (null === $this->repoData && null !== $this->gitDriver) {
  26257. return;
  26258. }
  26259. $this->owner = $this->repoData['owner']['login'];
  26260. $this->repository = $this->repoData['name'];
  26261. $this->isPrivate = !empty($this->repoData['private']);
  26262. if (isset($this->repoData['default_branch'])) {
  26263. $this->rootIdentifier = $this->repoData['default_branch'];
  26264. } elseif (isset($this->repoData['master_branch'])) {
  26265. $this->rootIdentifier = $this->repoData['master_branch'];
  26266. } else {
  26267. $this->rootIdentifier = 'master';
  26268. }
  26269. $this->hasIssues = !empty($this->repoData['has_issues']);
  26270. $this->isArchived = !empty($this->repoData['archived']);
  26271. }
  26272. protected function attemptCloneFallback()
  26273. {
  26274. $this->isPrivate = true;
  26275. try {
  26276. $this->setupGitDriver($this->generateSshUrl());
  26277. return true;
  26278. } catch (\RuntimeException $e) {
  26279. $this->gitDriver = null;
  26280. $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>');
  26281. throw $e;
  26282. }
  26283. }
  26284. protected function setupGitDriver($url)
  26285. {
  26286. $this->gitDriver = new GitDriver(
  26287. array('url' => $url),
  26288. $this->io,
  26289. $this->config,
  26290. $this->httpDownloader,
  26291. $this->process
  26292. );
  26293. $this->gitDriver->initialize();
  26294. }
  26295. protected function getNextPage(Response $response)
  26296. {
  26297. $header = $response->getHeader('link');
  26298. $links = explode(',', $header);
  26299. foreach ($links as $link) {
  26300. if (preg_match('{<(.+?)>; *rel="next"}', $link, $match)) {
  26301. return $match[1];
  26302. }
  26303. }
  26304. }
  26305. }
  26306. <?php
  26307. namespace Composer\Repository\Vcs;
  26308. use Composer\Config;
  26309. use Composer\Cache;
  26310. use Composer\IO\IOInterface;
  26311. use Composer\Json\JsonFile;
  26312. use Composer\Downloader\TransportException;
  26313. use Composer\Util\HttpDownloader;
  26314. use Composer\Util\GitLab;
  26315. use Composer\Util\Http\Response;
  26316. class GitLabDriver extends VcsDriver
  26317. {
  26318. private $scheme;
  26319. private $namespace;
  26320. private $repository;
  26321. private $project;
  26322. private $commits = array();
  26323. private $tags;
  26324. private $branches;
  26325. protected $gitDriver;
  26326. private $isPrivate = true;
  26327. private $hasNonstandardOrigin = false;
  26328. const URL_REGEX = '#^(?:(?P<scheme>https?)://(?P<domain>.+?)(?::(?P<port>[0-9]+))?/|git@(?P<domain2>[^:]+):)(?P<parts>.+)/(?P<repo>[^/]+?)(?:\.git|/)?$#';
  26329. public function initialize()
  26330. {
  26331. if (!preg_match(self::URL_REGEX, $this->url, $match)) {
  26332. throw new \InvalidArgumentException('The URL provided is invalid. It must be the HTTP URL of a GitLab project.');
  26333. }
  26334. $guessedDomain = !empty($match['domain']) ? $match['domain'] : $match['domain2'];
  26335. $configuredDomains = $this->config->get('gitlab-domains');
  26336. $urlParts = explode('/', $match['parts']);
  26337. $this->scheme = !empty($match['scheme'])
  26338. ? $match['scheme']
  26339. : (isset($this->repoConfig['secure-http']) && $this->repoConfig['secure-http'] === false ? 'http' : 'https')
  26340. ;
  26341. $this->originUrl = self::determineOrigin($configuredDomains, $guessedDomain, $urlParts, $match['port']);
  26342. if (false !== strpos($this->originUrl, ':') || false !== strpos($this->originUrl, '/')) {
  26343. $this->hasNonstandardOrigin = true;
  26344. }
  26345. $this->namespace = implode('/', $urlParts);
  26346. $this->repository = preg_replace('#(\.git)$#', '', $match['repo']);
  26347. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->namespace.'/'.$this->repository);
  26348. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  26349. $this->fetchProject();
  26350. }
  26351. public function setHttpDownloader(HttpDownloader $httpDownloader)
  26352. {
  26353. $this->httpDownloader = $httpDownloader;
  26354. }
  26355. public function getComposerInformation($identifier)
  26356. {
  26357. if ($this->gitDriver) {
  26358. return $this->gitDriver->getComposerInformation($identifier);
  26359. }
  26360. if (!isset($this->infoCache[$identifier])) {
  26361. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  26362. $composer = JsonFile::parseJson($res);
  26363. } else {
  26364. $composer = $this->getBaseComposerInformation($identifier);
  26365. if ($this->shouldCache($identifier)) {
  26366. $this->cache->write($identifier, json_encode($composer));
  26367. }
  26368. }
  26369. if ($composer) {
  26370. if (!isset($composer['support']['issues']) && isset($this->project['_links']['issues'])) {
  26371. $composer['support']['issues'] = $this->project['_links']['issues'];
  26372. }
  26373. if (!isset($composer['abandoned']) && !empty($this->project['archived'])) {
  26374. $composer['abandoned'] = true;
  26375. }
  26376. }
  26377. $this->infoCache[$identifier] = $composer;
  26378. }
  26379. return $this->infoCache[$identifier];
  26380. }
  26381. public function getFileContent($file, $identifier)
  26382. {
  26383. if ($this->gitDriver) {
  26384. return $this->gitDriver->getFileContent($file, $identifier);
  26385. }
  26386. if (!preg_match('{[a-f0-9]{40}}i', $identifier)) {
  26387. $branches = $this->getBranches();
  26388. if (isset($branches[$identifier])) {
  26389. $identifier = $branches[$identifier];
  26390. }
  26391. }
  26392. $resource = $this->getApiUrl().'/repository/files/'.$this->urlEncodeAll($file).'/raw?ref='.$identifier;
  26393. try {
  26394. $content = $this->getContents($resource)->getBody();
  26395. } catch (TransportException $e) {
  26396. if ($e->getCode() !== 404) {
  26397. throw $e;
  26398. }
  26399. return null;
  26400. }
  26401. return $content;
  26402. }
  26403. public function getChangeDate($identifier)
  26404. {
  26405. if ($this->gitDriver) {
  26406. return $this->gitDriver->getChangeDate($identifier);
  26407. }
  26408. if (isset($this->commits[$identifier])) {
  26409. return new \DateTime($this->commits[$identifier]['committed_date']);
  26410. }
  26411. return new \DateTime();
  26412. }
  26413. public function getRepositoryUrl()
  26414. {
  26415. return $this->isPrivate ? $this->project['ssh_url_to_repo'] : $this->project['http_url_to_repo'];
  26416. }
  26417. public function getUrl()
  26418. {
  26419. if ($this->gitDriver) {
  26420. return $this->gitDriver->getUrl();
  26421. }
  26422. return $this->project['web_url'];
  26423. }
  26424. public function getDist($identifier)
  26425. {
  26426. $url = $this->getApiUrl().'/repository/archive.zip?sha='.$identifier;
  26427. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  26428. }
  26429. public function getSource($identifier)
  26430. {
  26431. if ($this->gitDriver) {
  26432. return $this->gitDriver->getSource($identifier);
  26433. }
  26434. return array('type' => 'git', 'url' => $this->getRepositoryUrl(), 'reference' => $identifier);
  26435. }
  26436. public function getRootIdentifier()
  26437. {
  26438. if ($this->gitDriver) {
  26439. return $this->gitDriver->getRootIdentifier();
  26440. }
  26441. return $this->project['default_branch'];
  26442. }
  26443. public function getBranches()
  26444. {
  26445. if ($this->gitDriver) {
  26446. return $this->gitDriver->getBranches();
  26447. }
  26448. if (!$this->branches) {
  26449. $this->branches = $this->getReferences('branches');
  26450. }
  26451. return $this->branches;
  26452. }
  26453. public function getTags()
  26454. {
  26455. if ($this->gitDriver) {
  26456. return $this->gitDriver->getTags();
  26457. }
  26458. if (!$this->tags) {
  26459. $this->tags = $this->getReferences('tags');
  26460. }
  26461. return $this->tags;
  26462. }
  26463. public function getApiUrl()
  26464. {
  26465. return $this->scheme.'://'.$this->originUrl.'/api/v4/projects/'.$this->urlEncodeAll($this->namespace).'%2F'.$this->urlEncodeAll($this->repository);
  26466. }
  26467. private function urlEncodeAll($string)
  26468. {
  26469. $encoded = '';
  26470. for ($i = 0; isset($string[$i]); $i++) {
  26471. $character = $string[$i];
  26472. if (!ctype_alnum($character) && !in_array($character, array('-', '_'), true)) {
  26473. $character = '%' . sprintf('%02X', ord($character));
  26474. }
  26475. $encoded .= $character;
  26476. }
  26477. return $encoded;
  26478. }
  26479. protected function getReferences($type)
  26480. {
  26481. $perPage = 100;
  26482. $resource = $this->getApiUrl().'/repository/'.$type.'?per_page='.$perPage;
  26483. $references = array();
  26484. do {
  26485. $response = $this->getContents($resource);
  26486. $data = $response->decodeJson();
  26487. foreach ($data as $datum) {
  26488. $references[$datum['name']] = $datum['commit']['id'];
  26489. $this->commits[$datum['commit']['id']] = $datum['commit'];
  26490. }
  26491. if (count($data) >= $perPage) {
  26492. $resource = $this->getNextPage($response);
  26493. } else {
  26494. $resource = false;
  26495. }
  26496. } while ($resource);
  26497. return $references;
  26498. }
  26499. protected function fetchProject()
  26500. {
  26501. $resource = $this->getApiUrl();
  26502. $this->project = $this->getContents($resource, true)->decodeJson();
  26503. if (isset($this->project['visibility'])) {
  26504. $this->isPrivate = $this->project['visibility'] !== 'public';
  26505. } else {
  26506. $this->isPrivate = false;
  26507. }
  26508. }
  26509. protected function attemptCloneFallback()
  26510. {
  26511. if ($this->isPrivate === false) {
  26512. $url = $this->generatePublicUrl();
  26513. } else {
  26514. $url = $this->generateSshUrl();
  26515. }
  26516. try {
  26517. $this->setupGitDriver($url);
  26518. return true;
  26519. } catch (\RuntimeException $e) {
  26520. $this->gitDriver = null;
  26521. $this->io->writeError('<error>Failed to clone the '.$url.' repository, try running in interactive mode so that you can enter your credentials</error>');
  26522. throw $e;
  26523. }
  26524. }
  26525. protected function generateSshUrl()
  26526. {
  26527. if ($this->hasNonstandardOrigin) {
  26528. return 'ssh://git@'.$this->originUrl.'/'.$this->namespace.'/'.$this->repository.'.git';
  26529. }
  26530. return 'git@' . $this->originUrl . ':'.$this->namespace.'/'.$this->repository.'.git';
  26531. }
  26532. protected function generatePublicUrl()
  26533. {
  26534. return $this->scheme . '://' . $this->originUrl . '/'.$this->namespace.'/'.$this->repository.'.git';
  26535. }
  26536. protected function setupGitDriver($url)
  26537. {
  26538. $this->gitDriver = new GitDriver(
  26539. array('url' => $url),
  26540. $this->io,
  26541. $this->config,
  26542. $this->httpDownloader,
  26543. $this->process
  26544. );
  26545. $this->gitDriver->initialize();
  26546. }
  26547. protected function getContents($url, $fetchingRepoData = false)
  26548. {
  26549. try {
  26550. $response = parent::getContents($url);
  26551. if ($fetchingRepoData) {
  26552. $json = $response->decodeJson();
  26553. if (!isset($json['default_branch']) && isset($json['permissions'])) {
  26554. $this->isPrivate = $json['visibility'] !== 'public';
  26555. $moreThanGuestAccess = false;
  26556. foreach ($json['permissions'] as $permission) {
  26557. if ($permission && $permission['access_level'] > 10) {
  26558. $moreThanGuestAccess = true;
  26559. }
  26560. }
  26561. if (!$moreThanGuestAccess) {
  26562. $this->io->writeError('<warning>GitLab token with Guest only access detected</warning>');
  26563. return $this->attemptCloneFallback();
  26564. }
  26565. }
  26566. if (!isset($json['default_branch'])) {
  26567. if (!empty($json['id'])) {
  26568. $this->isPrivate = false;
  26569. }
  26570. throw new TransportException('GitLab API seems to not be authenticated as it did not return a default_branch', 401);
  26571. }
  26572. }
  26573. return $response;
  26574. } catch (TransportException $e) {
  26575. $gitLabUtil = new GitLab($this->io, $this->config, $this->process, $this->httpDownloader);
  26576. switch ($e->getCode()) {
  26577. case 401:
  26578. case 404:
  26579. if (!$fetchingRepoData) {
  26580. throw $e;
  26581. }
  26582. if ($gitLabUtil->authorizeOAuth($this->originUrl)) {
  26583. return parent::getContents($url);
  26584. }
  26585. if (!$this->io->isInteractive()) {
  26586. if ($this->attemptCloneFallback()) {
  26587. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  26588. }
  26589. }
  26590. $this->io->writeError('<warning>Failed to download ' . $this->namespace . '/' . $this->repository . ':' . $e->getMessage() . '</warning>');
  26591. $gitLabUtil->authorizeOAuthInteractively($this->scheme, $this->originUrl, 'Your credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
  26592. return parent::getContents($url);
  26593. case 403:
  26594. if (!$this->io->hasAuthentication($this->originUrl) && $gitLabUtil->authorizeOAuth($this->originUrl)) {
  26595. return parent::getContents($url);
  26596. }
  26597. if (!$this->io->isInteractive() && $fetchingRepoData) {
  26598. if ($this->attemptCloneFallback()) {
  26599. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  26600. }
  26601. }
  26602. throw $e;
  26603. default:
  26604. throw $e;
  26605. }
  26606. }
  26607. }
  26608. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  26609. {
  26610. if (!preg_match(self::URL_REGEX, $url, $match)) {
  26611. return false;
  26612. }
  26613. $scheme = !empty($match['scheme']) ? $match['scheme'] : null;
  26614. $guessedDomain = !empty($match['domain']) ? $match['domain'] : $match['domain2'];
  26615. $urlParts = explode('/', $match['parts']);
  26616. if (false === self::determineOrigin((array) $config->get('gitlab-domains'), $guessedDomain, $urlParts, $match['port'])) {
  26617. return false;
  26618. }
  26619. if ('https' === $scheme && !extension_loaded('openssl')) {
  26620. $io->writeError('Skipping GitLab driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  26621. return false;
  26622. }
  26623. return true;
  26624. }
  26625. protected function getNextPage(Response $response)
  26626. {
  26627. $header = $response->getHeader('link');
  26628. $links = explode(',', $header);
  26629. foreach ($links as $link) {
  26630. if (preg_match('{<(.+?)>; *rel="next"}', $link, $match)) {
  26631. return $match[1];
  26632. }
  26633. }
  26634. }
  26635. private static function determineOrigin(array $configuredDomains, $guessedDomain, array &$urlParts, $portNumber)
  26636. {
  26637. $guessedDomain = strtolower($guessedDomain);
  26638. if (in_array($guessedDomain, $configuredDomains) || ($portNumber && in_array($guessedDomain.':'.$portNumber, $configuredDomains))) {
  26639. if ($portNumber) {
  26640. return $guessedDomain.':'.$portNumber;
  26641. }
  26642. return $guessedDomain;
  26643. }
  26644. if ($portNumber) {
  26645. $guessedDomain .= ':'.$portNumber;
  26646. }
  26647. while (null !== ($part = array_shift($urlParts))) {
  26648. $guessedDomain .= '/' . $part;
  26649. if (in_array($guessedDomain, $configuredDomains) || ($portNumber && in_array(preg_replace('{:\d+}', '', $guessedDomain), $configuredDomains))) {
  26650. return $guessedDomain;
  26651. }
  26652. }
  26653. return false;
  26654. }
  26655. }
  26656. <?php
  26657. namespace Composer\Repository\Vcs;
  26658. use Composer\Config;
  26659. use Composer\IO\IOInterface;
  26660. class HgBitbucketDriver extends BitbucketDriver
  26661. {
  26662. public function getRootIdentifier()
  26663. {
  26664. if ($this->fallbackDriver) {
  26665. return $this->fallbackDriver->getRootIdentifier();
  26666. }
  26667. if (null === $this->rootIdentifier) {
  26668. if (! $this->getRepoData()) {
  26669. return $this->fallbackDriver->getRootIdentifier();
  26670. }
  26671. if ($this->vcsType !== 'hg') {
  26672. throw new \RuntimeException(
  26673. $this->url.' does not appear to be a mercurial repository, use '.
  26674. $this->cloneHttpsUrl.' if this is a git bitbucket repository'
  26675. );
  26676. }
  26677. $mainBranchData = $this->getMainBranchData();
  26678. $this->rootIdentifier = !empty($mainBranchData['name']) ? $mainBranchData['name'] : 'default';
  26679. }
  26680. return $this->rootIdentifier;
  26681. }
  26682. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  26683. {
  26684. if (!preg_match('#^https?://bitbucket\.org/([^/]+)/([^/]+)/?$#i', $url)) {
  26685. return false;
  26686. }
  26687. if (!extension_loaded('openssl')) {
  26688. $io->writeError('Skipping Bitbucket hg driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  26689. return false;
  26690. }
  26691. return true;
  26692. }
  26693. protected function setupFallbackDriver($url)
  26694. {
  26695. $this->fallbackDriver = new HgDriver(
  26696. array('url' => $url),
  26697. $this->io,
  26698. $this->config,
  26699. $this->httpDownloader,
  26700. $this->process
  26701. );
  26702. $this->fallbackDriver->initialize();
  26703. }
  26704. protected function generateSshUrl()
  26705. {
  26706. return 'ssh://hg@' . $this->originUrl . '/' . $this->owner.'/'.$this->repository;
  26707. }
  26708. }
  26709. <?php
  26710. namespace Composer\Repository\Vcs;
  26711. use Composer\Config;
  26712. use Composer\Cache;
  26713. use Composer\Util\Hg as HgUtils;
  26714. use Composer\Util\ProcessExecutor;
  26715. use Composer\Util\Filesystem;
  26716. use Composer\IO\IOInterface;
  26717. class HgDriver extends VcsDriver
  26718. {
  26719. protected $tags;
  26720. protected $branches;
  26721. protected $rootIdentifier;
  26722. protected $repoDir;
  26723. public function initialize()
  26724. {
  26725. if (Filesystem::isLocalPath($this->url)) {
  26726. $this->repoDir = $this->url;
  26727. } else {
  26728. if (!Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  26729. throw new \RuntimeException('HgDriver requires a usable cache directory, and it looks like you set it to be disabled');
  26730. }
  26731. $cacheDir = $this->config->get('cache-vcs-dir');
  26732. $this->repoDir = $cacheDir . '/' . preg_replace('{[^a-z0-9]}i', '-', $this->url) . '/';
  26733. $fs = new Filesystem();
  26734. $fs->ensureDirectoryExists($cacheDir);
  26735. if (!is_writable(dirname($this->repoDir))) {
  26736. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.$cacheDir.'" directory is not writable by the current user.');
  26737. }
  26738. $this->config->prohibitUrlByConfig($this->url, $this->io);
  26739. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  26740. if (is_dir($this->repoDir) && 0 === $this->process->execute('hg summary', $output, $this->repoDir)) {
  26741. if (0 !== $this->process->execute('hg pull', $output, $this->repoDir)) {
  26742. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
  26743. }
  26744. } else {
  26745. $fs->removeDirectory($this->repoDir);
  26746. $repoDir = $this->repoDir;
  26747. $command = function ($url) use ($repoDir) {
  26748. return sprintf('hg clone --noupdate %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($repoDir));
  26749. };
  26750. $hgUtils->runCommand($command, $this->url, null);
  26751. }
  26752. }
  26753. $this->getTags();
  26754. $this->getBranches();
  26755. }
  26756. public function getRootIdentifier()
  26757. {
  26758. if (null === $this->rootIdentifier) {
  26759. $this->process->execute(sprintf('hg tip --template "{node}"'), $output, $this->repoDir);
  26760. $output = $this->process->splitLines($output);
  26761. $this->rootIdentifier = $output[0];
  26762. }
  26763. return $this->rootIdentifier;
  26764. }
  26765. public function getUrl()
  26766. {
  26767. return $this->url;
  26768. }
  26769. public function getSource($identifier)
  26770. {
  26771. return array('type' => 'hg', 'url' => $this->getUrl(), 'reference' => $identifier);
  26772. }
  26773. public function getDist($identifier)
  26774. {
  26775. return null;
  26776. }
  26777. public function getFileContent($file, $identifier)
  26778. {
  26779. $resource = sprintf('hg cat -r %s %s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  26780. $this->process->execute($resource, $content, $this->repoDir);
  26781. if (!trim($content)) {
  26782. return;
  26783. }
  26784. return $content;
  26785. }
  26786. public function getChangeDate($identifier)
  26787. {
  26788. $this->process->execute(
  26789. sprintf(
  26790. 'hg log --template "{date|rfc3339date}" -r %s',
  26791. ProcessExecutor::escape($identifier)
  26792. ),
  26793. $output,
  26794. $this->repoDir
  26795. );
  26796. return new \DateTime(trim($output), new \DateTimeZone('UTC'));
  26797. }
  26798. public function getTags()
  26799. {
  26800. if (null === $this->tags) {
  26801. $tags = array();
  26802. $this->process->execute('hg tags', $output, $this->repoDir);
  26803. foreach ($this->process->splitLines($output) as $tag) {
  26804. if ($tag && preg_match('(^([^\s]+)\s+\d+:(.*)$)', $tag, $match)) {
  26805. $tags[$match[1]] = $match[2];
  26806. }
  26807. }
  26808. unset($tags['tip']);
  26809. $this->tags = $tags;
  26810. }
  26811. return $this->tags;
  26812. }
  26813. public function getBranches()
  26814. {
  26815. if (null === $this->branches) {
  26816. $branches = array();
  26817. $bookmarks = array();
  26818. $this->process->execute('hg branches', $output, $this->repoDir);
  26819. foreach ($this->process->splitLines($output) as $branch) {
  26820. if ($branch && preg_match('(^([^\s]+)\s+\d+:([a-f0-9]+))', $branch, $match)) {
  26821. $branches[$match[1]] = $match[2];
  26822. }
  26823. }
  26824. $this->process->execute('hg bookmarks', $output, $this->repoDir);
  26825. foreach ($this->process->splitLines($output) as $branch) {
  26826. if ($branch && preg_match('(^(?:[\s*]*)([^\s]+)\s+\d+:(.*)$)', $branch, $match)) {
  26827. $bookmarks[$match[1]] = $match[2];
  26828. }
  26829. }
  26830. $this->branches = array_merge($bookmarks, $branches);
  26831. }
  26832. return $this->branches;
  26833. }
  26834. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  26835. {
  26836. if (preg_match('#(^(?:https?|ssh)://(?:[^@]+@)?bitbucket.org|https://(?:.*?)\.kilnhg.com)#i', $url)) {
  26837. return true;
  26838. }
  26839. if (Filesystem::isLocalPath($url)) {
  26840. $url = Filesystem::getPlatformPath($url);
  26841. if (!is_dir($url)) {
  26842. return false;
  26843. }
  26844. $process = new ProcessExecutor($io);
  26845. if ($process->execute('hg summary', $output, $url) === 0) {
  26846. return true;
  26847. }
  26848. }
  26849. if (!$deep) {
  26850. return false;
  26851. }
  26852. $process = new ProcessExecutor($io);
  26853. $exit = $process->execute(sprintf('hg identify %s', ProcessExecutor::escape($url)), $ignored);
  26854. return $exit === 0;
  26855. }
  26856. }
  26857. <?php
  26858. namespace Composer\Repository\Vcs;
  26859. use Composer\Config;
  26860. use Composer\Cache;
  26861. use Composer\IO\IOInterface;
  26862. use Composer\Util\ProcessExecutor;
  26863. use Composer\Util\Perforce;
  26864. class PerforceDriver extends VcsDriver
  26865. {
  26866. protected $depot;
  26867. protected $branch;
  26868. protected $perforce;
  26869. public function initialize()
  26870. {
  26871. $this->depot = $this->repoConfig['depot'];
  26872. $this->branch = '';
  26873. if (!empty($this->repoConfig['branch'])) {
  26874. $this->branch = $this->repoConfig['branch'];
  26875. }
  26876. $this->initPerforce($this->repoConfig);
  26877. $this->perforce->p4Login();
  26878. $this->perforce->checkStream();
  26879. $this->perforce->writeP4ClientSpec();
  26880. $this->perforce->connectClient();
  26881. return true;
  26882. }
  26883. private function initPerforce($repoConfig)
  26884. {
  26885. if (!empty($this->perforce)) {
  26886. return;
  26887. }
  26888. if (!Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  26889. throw new \RuntimeException('PerforceDriver requires a usable cache directory, and it looks like you set it to be disabled');
  26890. }
  26891. $repoDir = $this->config->get('cache-vcs-dir') . '/' . $this->depot;
  26892. $this->perforce = Perforce::create($repoConfig, $this->getUrl(), $repoDir, $this->process, $this->io);
  26893. }
  26894. public function getFileContent($file, $identifier)
  26895. {
  26896. return $this->perforce->getFileContent($file, $identifier);
  26897. }
  26898. public function getChangeDate($identifier)
  26899. {
  26900. return null;
  26901. }
  26902. public function getRootIdentifier()
  26903. {
  26904. return $this->branch;
  26905. }
  26906. public function getBranches()
  26907. {
  26908. return $this->perforce->getBranches();
  26909. }
  26910. public function getTags()
  26911. {
  26912. return $this->perforce->getTags();
  26913. }
  26914. public function getDist($identifier)
  26915. {
  26916. return null;
  26917. }
  26918. public function getSource($identifier)
  26919. {
  26920. return array(
  26921. 'type' => 'perforce',
  26922. 'url' => $this->repoConfig['url'],
  26923. 'reference' => $identifier,
  26924. 'p4user' => $this->perforce->getUser(),
  26925. );
  26926. }
  26927. public function getUrl()
  26928. {
  26929. return $this->url;
  26930. }
  26931. public function hasComposerFile($identifier)
  26932. {
  26933. $composerInfo = $this->perforce->getComposerInformation('//' . $this->depot . '/' . $identifier);
  26934. return !empty($composerInfo);
  26935. }
  26936. public function getContents($url)
  26937. {
  26938. return false;
  26939. }
  26940. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  26941. {
  26942. if ($deep || preg_match('#\b(perforce|p4)\b#i', $url)) {
  26943. return Perforce::checkServerExists($url, new ProcessExecutor($io));
  26944. }
  26945. return false;
  26946. }
  26947. public function cleanup()
  26948. {
  26949. $this->perforce->cleanupClientSpec();
  26950. $this->perforce = null;
  26951. }
  26952. public function getDepot()
  26953. {
  26954. return $this->depot;
  26955. }
  26956. public function getBranch()
  26957. {
  26958. return $this->branch;
  26959. }
  26960. }
  26961. <?php
  26962. namespace Composer\Repository\Vcs;
  26963. use Composer\Cache;
  26964. use Composer\Config;
  26965. use Composer\Json\JsonFile;
  26966. use Composer\Util\ProcessExecutor;
  26967. use Composer\Util\Filesystem;
  26968. use Composer\Util\Url;
  26969. use Composer\Util\Svn as SvnUtil;
  26970. use Composer\IO\IOInterface;
  26971. use Composer\Downloader\TransportException;
  26972. class SvnDriver extends VcsDriver
  26973. {
  26974. protected $baseUrl;
  26975. protected $tags;
  26976. protected $branches;
  26977. protected $rootIdentifier;
  26978. protected $trunkPath = 'trunk';
  26979. protected $branchesPath = 'branches';
  26980. protected $tagsPath = 'tags';
  26981. protected $packagePath = '';
  26982. protected $cacheCredentials = true;
  26983. private $util;
  26984. public function initialize()
  26985. {
  26986. $this->url = $this->baseUrl = rtrim(self::normalizeUrl($this->url), '/');
  26987. SvnUtil::cleanEnv();
  26988. if (isset($this->repoConfig['trunk-path'])) {
  26989. $this->trunkPath = $this->repoConfig['trunk-path'];
  26990. }
  26991. if (isset($this->repoConfig['branches-path'])) {
  26992. $this->branchesPath = $this->repoConfig['branches-path'];
  26993. }
  26994. if (isset($this->repoConfig['tags-path'])) {
  26995. $this->tagsPath = $this->repoConfig['tags-path'];
  26996. }
  26997. if (array_key_exists('svn-cache-credentials', $this->repoConfig)) {
  26998. $this->cacheCredentials = (bool) $this->repoConfig['svn-cache-credentials'];
  26999. }
  27000. if (isset($this->repoConfig['package-path'])) {
  27001. $this->packagePath = '/' . trim($this->repoConfig['package-path'], '/');
  27002. }
  27003. if (false !== ($pos = strrpos($this->url, '/' . $this->trunkPath))) {
  27004. $this->baseUrl = substr($this->url, 0, $pos);
  27005. }
  27006. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', Url::sanitize($this->baseUrl)));
  27007. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  27008. $this->getBranches();
  27009. $this->getTags();
  27010. }
  27011. public function getRootIdentifier()
  27012. {
  27013. return $this->rootIdentifier ?: $this->trunkPath;
  27014. }
  27015. public function getUrl()
  27016. {
  27017. return $this->url;
  27018. }
  27019. public function getSource($identifier)
  27020. {
  27021. return array('type' => 'svn', 'url' => $this->baseUrl, 'reference' => $identifier);
  27022. }
  27023. public function getDist($identifier)
  27024. {
  27025. return null;
  27026. }
  27027. protected function shouldCache($identifier)
  27028. {
  27029. return $this->cache && preg_match('{@\d+$}', $identifier);
  27030. }
  27031. public function getComposerInformation($identifier)
  27032. {
  27033. if (!isset($this->infoCache[$identifier])) {
  27034. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier.'.json')) {
  27035. return $this->infoCache[$identifier] = JsonFile::parseJson($res);
  27036. }
  27037. try {
  27038. $composer = $this->getBaseComposerInformation($identifier);
  27039. } catch (TransportException $e) {
  27040. $message = $e->getMessage();
  27041. if (stripos($message, 'path not found') === false && stripos($message, 'svn: warning: W160013') === false) {
  27042. throw $e;
  27043. }
  27044. $composer = '';
  27045. }
  27046. if ($this->shouldCache($identifier)) {
  27047. $this->cache->write($identifier.'.json', json_encode($composer));
  27048. }
  27049. $this->infoCache[$identifier] = $composer;
  27050. }
  27051. return $this->infoCache[$identifier];
  27052. }
  27053. public function getFileContent($file, $identifier)
  27054. {
  27055. $identifier = '/' . trim($identifier, '/') . '/';
  27056. preg_match('{^(.+?)(@\d+)?/$}', $identifier, $match);
  27057. if (!empty($match[2])) {
  27058. $path = $match[1];
  27059. $rev = $match[2];
  27060. } else {
  27061. $path = $identifier;
  27062. $rev = '';
  27063. }
  27064. try {
  27065. $resource = $path.$file;
  27066. $output = $this->execute('svn cat', $this->baseUrl . $resource . $rev);
  27067. if (!trim($output)) {
  27068. return null;
  27069. }
  27070. } catch (\RuntimeException $e) {
  27071. throw new TransportException($e->getMessage());
  27072. }
  27073. return $output;
  27074. }
  27075. public function getChangeDate($identifier)
  27076. {
  27077. $identifier = '/' . trim($identifier, '/') . '/';
  27078. preg_match('{^(.+?)(@\d+)?/$}', $identifier, $match);
  27079. if (!empty($match[2])) {
  27080. $path = $match[1];
  27081. $rev = $match[2];
  27082. } else {
  27083. $path = $identifier;
  27084. $rev = '';
  27085. }
  27086. $output = $this->execute('svn info', $this->baseUrl . $path . $rev);
  27087. foreach ($this->process->splitLines($output) as $line) {
  27088. if ($line && preg_match('{^Last Changed Date: ([^(]+)}', $line, $match)) {
  27089. return new \DateTime($match[1], new \DateTimeZone('UTC'));
  27090. }
  27091. }
  27092. return null;
  27093. }
  27094. public function getTags()
  27095. {
  27096. if (null === $this->tags) {
  27097. $this->tags = array();
  27098. if ($this->tagsPath !== false) {
  27099. $output = $this->execute('svn ls --verbose', $this->baseUrl . '/' . $this->tagsPath);
  27100. if ($output) {
  27101. foreach ($this->process->splitLines($output) as $line) {
  27102. $line = trim($line);
  27103. if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  27104. if (isset($match[1], $match[2]) && $match[2] !== './') {
  27105. $this->tags[rtrim($match[2], '/')] = $this->buildIdentifier(
  27106. '/' . $this->tagsPath . '/' . $match[2],
  27107. $match[1]
  27108. );
  27109. }
  27110. }
  27111. }
  27112. }
  27113. }
  27114. }
  27115. return $this->tags;
  27116. }
  27117. public function getBranches()
  27118. {
  27119. if (null === $this->branches) {
  27120. $this->branches = array();
  27121. if (false === $this->trunkPath) {
  27122. $trunkParent = $this->baseUrl . '/';
  27123. } else {
  27124. $trunkParent = $this->baseUrl . '/' . $this->trunkPath;
  27125. }
  27126. $output = $this->execute('svn ls --verbose', $trunkParent);
  27127. if ($output) {
  27128. foreach ($this->process->splitLines($output) as $line) {
  27129. $line = trim($line);
  27130. if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  27131. if (isset($match[1], $match[2]) && $match[2] === './') {
  27132. $this->branches['trunk'] = $this->buildIdentifier(
  27133. '/' . $this->trunkPath,
  27134. $match[1]
  27135. );
  27136. $this->rootIdentifier = $this->branches['trunk'];
  27137. break;
  27138. }
  27139. }
  27140. }
  27141. }
  27142. unset($output);
  27143. if ($this->branchesPath !== false) {
  27144. $output = $this->execute('svn ls --verbose', $this->baseUrl . '/' . $this->branchesPath);
  27145. if ($output) {
  27146. foreach ($this->process->splitLines(trim($output)) as $line) {
  27147. $line = trim($line);
  27148. if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  27149. if (isset($match[1], $match[2]) && $match[2] !== './') {
  27150. $this->branches[rtrim($match[2], '/')] = $this->buildIdentifier(
  27151. '/' . $this->branchesPath . '/' . $match[2],
  27152. $match[1]
  27153. );
  27154. }
  27155. }
  27156. }
  27157. }
  27158. }
  27159. }
  27160. return $this->branches;
  27161. }
  27162. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  27163. {
  27164. $url = self::normalizeUrl($url);
  27165. if (preg_match('#(^svn://|^svn\+ssh://|svn\.)#i', $url)) {
  27166. return true;
  27167. }
  27168. if (!$deep && !Filesystem::isLocalPath($url)) {
  27169. return false;
  27170. }
  27171. $process = new ProcessExecutor($io);
  27172. $exit = $process->execute(
  27173. "svn info --non-interactive ".ProcessExecutor::escape($url),
  27174. $ignoredOutput
  27175. );
  27176. if ($exit === 0) {
  27177. return true;
  27178. }
  27179. if (false !== stripos($process->getErrorOutput(), 'authorization failed:')) {
  27180. return true;
  27181. }
  27182. if (false !== stripos($process->getErrorOutput(), 'Authentication failed')) {
  27183. return true;
  27184. }
  27185. return false;
  27186. }
  27187. protected static function normalizeUrl($url)
  27188. {
  27189. $fs = new Filesystem();
  27190. if ($fs->isAbsolutePath($url)) {
  27191. return 'file://' . strtr($url, '\\', '/');
  27192. }
  27193. return $url;
  27194. }
  27195. protected function execute($command, $url)
  27196. {
  27197. if (null === $this->util) {
  27198. $this->util = new SvnUtil($this->baseUrl, $this->io, $this->config, $this->process);
  27199. $this->util->setCacheCredentials($this->cacheCredentials);
  27200. }
  27201. try {
  27202. return $this->util->execute($command, $url);
  27203. } catch (\RuntimeException $e) {
  27204. if (null === $this->util->binaryVersion()) {
  27205. 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());
  27206. }
  27207. throw new \RuntimeException(
  27208. 'Repository '.$this->url.' could not be processed, '.$e->getMessage()
  27209. );
  27210. }
  27211. }
  27212. protected function buildIdentifier($baseDir, $revision)
  27213. {
  27214. return rtrim($baseDir, '/') . $this->packagePath . '/@' . $revision;
  27215. }
  27216. }
  27217. <?php
  27218. namespace Composer\Repository\Vcs;
  27219. use Composer\Cache;
  27220. use Composer\Downloader\TransportException;
  27221. use Composer\Config;
  27222. use Composer\Factory;
  27223. use Composer\IO\IOInterface;
  27224. use Composer\Json\JsonFile;
  27225. use Composer\Util\ProcessExecutor;
  27226. use Composer\Util\HttpDownloader;
  27227. use Composer\Util\Filesystem;
  27228. use Composer\Util\Http\Response;
  27229. abstract class VcsDriver implements VcsDriverInterface
  27230. {
  27231. protected $url;
  27232. protected $originUrl;
  27233. protected $repoConfig;
  27234. protected $io;
  27235. protected $config;
  27236. protected $process;
  27237. protected $httpDownloader;
  27238. protected $infoCache = array();
  27239. protected $cache;
  27240. final public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, ProcessExecutor $process)
  27241. {
  27242. if (Filesystem::isLocalPath($repoConfig['url'])) {
  27243. $repoConfig['url'] = Filesystem::getPlatformPath($repoConfig['url']);
  27244. }
  27245. $this->url = $repoConfig['url'];
  27246. $this->originUrl = $repoConfig['url'];
  27247. $this->repoConfig = $repoConfig;
  27248. $this->io = $io;
  27249. $this->config = $config;
  27250. $this->httpDownloader = $httpDownloader;
  27251. $this->process = $process;
  27252. }
  27253. protected function shouldCache($identifier)
  27254. {
  27255. return $this->cache && preg_match('{^[a-f0-9]{40}$}iD', $identifier);
  27256. }
  27257. public function getComposerInformation($identifier)
  27258. {
  27259. if (!isset($this->infoCache[$identifier])) {
  27260. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  27261. return $this->infoCache[$identifier] = JsonFile::parseJson($res);
  27262. }
  27263. $composer = $this->getBaseComposerInformation($identifier);
  27264. if ($this->shouldCache($identifier)) {
  27265. $this->cache->write($identifier, json_encode($composer));
  27266. }
  27267. $this->infoCache[$identifier] = $composer;
  27268. }
  27269. return $this->infoCache[$identifier];
  27270. }
  27271. protected function getBaseComposerInformation($identifier)
  27272. {
  27273. $composerFileContent = $this->getFileContent('composer.json', $identifier);
  27274. if (!$composerFileContent) {
  27275. return null;
  27276. }
  27277. $composer = JsonFile::parseJson($composerFileContent, $identifier . ':composer.json');
  27278. if (empty($composer['time']) && $changeDate = $this->getChangeDate($identifier)) {
  27279. $composer['time'] = $changeDate->format(DATE_RFC3339);
  27280. }
  27281. return $composer;
  27282. }
  27283. public function hasComposerFile($identifier)
  27284. {
  27285. try {
  27286. return (bool) $this->getComposerInformation($identifier);
  27287. } catch (TransportException $e) {
  27288. }
  27289. return false;
  27290. }
  27291. protected function getScheme()
  27292. {
  27293. if (extension_loaded('openssl')) {
  27294. return 'https';
  27295. }
  27296. return 'http';
  27297. }
  27298. protected function getContents($url)
  27299. {
  27300. $options = isset($this->repoConfig['options']) ? $this->repoConfig['options'] : array();
  27301. return $this->httpDownloader->get($url, $options);
  27302. }
  27303. public function cleanup()
  27304. {
  27305. return;
  27306. }
  27307. }
  27308. <?php
  27309. namespace Composer\Repository\Vcs;
  27310. use Composer\Config;
  27311. use Composer\IO\IOInterface;
  27312. interface VcsDriverInterface
  27313. {
  27314. public function initialize();
  27315. public function getComposerInformation($identifier);
  27316. public function getFileContent($file, $identifier);
  27317. public function getChangeDate($identifier);
  27318. public function getRootIdentifier();
  27319. public function getBranches();
  27320. public function getTags();
  27321. public function getDist($identifier);
  27322. public function getSource($identifier);
  27323. public function getUrl();
  27324. public function hasComposerFile($identifier);
  27325. public function cleanup();
  27326. public static function supports(IOInterface $io, Config $config, $url, $deep = false);
  27327. }
  27328. <?php
  27329. namespace Composer\Repository;
  27330. use Composer\Downloader\TransportException;
  27331. use Composer\Repository\Vcs\VcsDriverInterface;
  27332. use Composer\Package\Version\VersionParser;
  27333. use Composer\Package\Loader\ArrayLoader;
  27334. use Composer\Package\Loader\ValidatingArrayLoader;
  27335. use Composer\Package\Loader\InvalidPackageException;
  27336. use Composer\Package\Loader\LoaderInterface;
  27337. use Composer\EventDispatcher\EventDispatcher;
  27338. use Composer\Util\ProcessExecutor;
  27339. use Composer\Util\HttpDownloader;
  27340. use Composer\Util\Url;
  27341. use Composer\Semver\Constraint\Constraint;
  27342. use Composer\IO\IOInterface;
  27343. use Composer\Config;
  27344. class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  27345. {
  27346. protected $url;
  27347. protected $packageName;
  27348. protected $isVerbose;
  27349. protected $isVeryVerbose;
  27350. protected $io;
  27351. protected $config;
  27352. protected $versionParser;
  27353. protected $type;
  27354. protected $loader;
  27355. protected $repoConfig;
  27356. protected $httpDownloader;
  27357. protected $processExecutor;
  27358. protected $branchErrorOccurred = false;
  27359. private $drivers;
  27360. private $driver;
  27361. private $versionCache;
  27362. private $emptyReferences = array();
  27363. private $versionTransportExceptions = array();
  27364. public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $dispatcher = null, ProcessExecutor $process = null, array $drivers = null, VersionCacheInterface $versionCache = null)
  27365. {
  27366. parent::__construct();
  27367. $this->drivers = $drivers ?: array(
  27368. 'github' => 'Composer\Repository\Vcs\GitHubDriver',
  27369. 'gitlab' => 'Composer\Repository\Vcs\GitLabDriver',
  27370. 'git-bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver',
  27371. 'git' => 'Composer\Repository\Vcs\GitDriver',
  27372. 'hg-bitbucket' => 'Composer\Repository\Vcs\HgBitbucketDriver',
  27373. 'hg' => 'Composer\Repository\Vcs\HgDriver',
  27374. 'perforce' => 'Composer\Repository\Vcs\PerforceDriver',
  27375. 'fossil' => 'Composer\Repository\Vcs\FossilDriver',
  27376. 'svn' => 'Composer\Repository\Vcs\SvnDriver',
  27377. );
  27378. $this->url = $repoConfig['url'];
  27379. $this->io = $io;
  27380. $this->type = isset($repoConfig['type']) ? $repoConfig['type'] : 'vcs';
  27381. $this->isVerbose = $io->isVerbose();
  27382. $this->isVeryVerbose = $io->isVeryVerbose();
  27383. $this->config = $config;
  27384. $this->repoConfig = $repoConfig;
  27385. $this->versionCache = $versionCache;
  27386. $this->httpDownloader = $httpDownloader;
  27387. $this->processExecutor = $process ?: new ProcessExecutor($io);
  27388. }
  27389. public function getRepoName()
  27390. {
  27391. $driverClass = get_class($this->getDriver());
  27392. $driverType = array_search($driverClass, $this->drivers);
  27393. if (!$driverType) {
  27394. $driverType = $driverClass;
  27395. }
  27396. return 'vcs repo ('.$driverType.' '.Url::sanitize($this->url).')';
  27397. }
  27398. public function getRepoConfig()
  27399. {
  27400. return $this->repoConfig;
  27401. }
  27402. public function setLoader(LoaderInterface $loader)
  27403. {
  27404. $this->loader = $loader;
  27405. }
  27406. public function getDriver()
  27407. {
  27408. if ($this->driver) {
  27409. return $this->driver;
  27410. }
  27411. if (isset($this->drivers[$this->type])) {
  27412. $class = $this->drivers[$this->type];
  27413. $this->driver = new $class($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  27414. $this->driver->initialize();
  27415. return $this->driver;
  27416. }
  27417. foreach ($this->drivers as $driver) {
  27418. if ($driver::supports($this->io, $this->config, $this->url)) {
  27419. $this->driver = new $driver($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  27420. $this->driver->initialize();
  27421. return $this->driver;
  27422. }
  27423. }
  27424. foreach ($this->drivers as $driver) {
  27425. if ($driver::supports($this->io, $this->config, $this->url, true)) {
  27426. $this->driver = new $driver($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  27427. $this->driver->initialize();
  27428. return $this->driver;
  27429. }
  27430. }
  27431. }
  27432. public function hadInvalidBranches()
  27433. {
  27434. return $this->branchErrorOccurred;
  27435. }
  27436. public function getEmptyReferences()
  27437. {
  27438. return $this->emptyReferences;
  27439. }
  27440. public function getVersionTransportExceptions()
  27441. {
  27442. return $this->versionTransportExceptions;
  27443. }
  27444. protected function initialize()
  27445. {
  27446. parent::initialize();
  27447. $isVerbose = $this->isVerbose;
  27448. $isVeryVerbose = $this->isVeryVerbose;
  27449. $driver = $this->getDriver();
  27450. if (!$driver) {
  27451. throw new \InvalidArgumentException('No driver found to handle VCS repository '.$this->url);
  27452. }
  27453. $this->versionParser = new VersionParser;
  27454. if (!$this->loader) {
  27455. $this->loader = new ArrayLoader($this->versionParser);
  27456. }
  27457. $hasRootIdentifierComposerJson = false;
  27458. try {
  27459. $hasRootIdentifierComposerJson = $driver->hasComposerFile($driver->getRootIdentifier());
  27460. if ($hasRootIdentifierComposerJson) {
  27461. $data = $driver->getComposerInformation($driver->getRootIdentifier());
  27462. $this->packageName = !empty($data['name']) ? $data['name'] : null;
  27463. }
  27464. } catch (\Exception $e) {
  27465. if ($isVeryVerbose) {
  27466. $this->io->writeError('<error>Skipped parsing '.$driver->getRootIdentifier().', '.$e->getMessage().'</error>');
  27467. }
  27468. }
  27469. foreach ($driver->getTags() as $tag => $identifier) {
  27470. $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $tag . '</comment>)';
  27471. if ($isVeryVerbose) {
  27472. $this->io->writeError($msg);
  27473. } elseif ($isVerbose) {
  27474. $this->io->overwriteError($msg, false);
  27475. }
  27476. $tag = str_replace('release-', '', $tag);
  27477. $cachedPackage = $this->getCachedPackageVersion($tag, $identifier, $isVerbose, $isVeryVerbose);
  27478. if ($cachedPackage) {
  27479. $this->addPackage($cachedPackage);
  27480. continue;
  27481. }
  27482. if ($cachedPackage === false) {
  27483. $this->emptyReferences[] = $identifier;
  27484. continue;
  27485. }
  27486. if (!$parsedTag = $this->validateTag($tag)) {
  27487. if ($isVeryVerbose) {
  27488. $this->io->writeError('<warning>Skipped tag '.$tag.', invalid tag name</warning>');
  27489. }
  27490. continue;
  27491. }
  27492. try {
  27493. if (!$data = $driver->getComposerInformation($identifier)) {
  27494. if ($isVeryVerbose) {
  27495. $this->io->writeError('<warning>Skipped tag '.$tag.', no composer file</warning>');
  27496. }
  27497. $this->emptyReferences[] = $identifier;
  27498. continue;
  27499. }
  27500. if (isset($data['version'])) {
  27501. $data['version_normalized'] = $this->versionParser->normalize($data['version']);
  27502. } else {
  27503. $data['version'] = $tag;
  27504. $data['version_normalized'] = $parsedTag;
  27505. }
  27506. $data['version'] = preg_replace('{[.-]?dev$}i', '', $data['version']);
  27507. $data['version_normalized'] = preg_replace('{(^dev-|[.-]?dev$)}i', '', $data['version_normalized']);
  27508. unset($data['default-branch']);
  27509. if ($data['version_normalized'] !== $parsedTag) {
  27510. if ($isVeryVerbose) {
  27511. if (preg_match('{(^dev-|[.-]?dev$)}i', $parsedTag)) {
  27512. $this->io->writeError('<warning>Skipped tag '.$tag.', invalid tag name, tags can not use dev prefixes or suffixes</warning>');
  27513. } else {
  27514. $this->io->writeError('<warning>Skipped tag '.$tag.', tag ('.$parsedTag.') does not match version ('.$data['version_normalized'].') in composer.json</warning>');
  27515. }
  27516. }
  27517. continue;
  27518. }
  27519. $tagPackageName = isset($data['name']) ? $data['name'] : $this->packageName;
  27520. if ($existingPackage = $this->findPackage($tagPackageName, $data['version_normalized'])) {
  27521. if ($isVeryVerbose) {
  27522. $this->io->writeError('<warning>Skipped tag '.$tag.', it conflicts with an another tag ('.$existingPackage->getPrettyVersion().') as both resolve to '.$data['version_normalized'].' internally</warning>');
  27523. }
  27524. continue;
  27525. }
  27526. if ($isVeryVerbose) {
  27527. $this->io->writeError('Importing tag '.$tag.' ('.$data['version_normalized'].')');
  27528. }
  27529. $this->addPackage($this->loader->load($this->preProcess($driver, $data, $identifier)));
  27530. } catch (\Exception $e) {
  27531. if ($e instanceof TransportException) {
  27532. $this->versionTransportExceptions['tags'][$tag] = $e;
  27533. if ($e->getCode() === 404) {
  27534. $this->emptyReferences[] = $identifier;
  27535. }
  27536. if ($e->getCode() === 401 || $e->getCode() === 403) {
  27537. throw $e;
  27538. }
  27539. }
  27540. if ($isVeryVerbose) {
  27541. $this->io->writeError('<warning>Skipped tag '.$tag.', '.($e instanceof TransportException ? 'no composer file was found (' . $e->getCode() . ' HTTP status code)' : $e->getMessage()).'</warning>');
  27542. }
  27543. continue;
  27544. }
  27545. }
  27546. if (!$isVeryVerbose) {
  27547. $this->io->overwriteError('', false);
  27548. }
  27549. $branches = $driver->getBranches();
  27550. if ($hasRootIdentifierComposerJson && isset($branches[$driver->getRootIdentifier()])) {
  27551. $branches = array($driver->getRootIdentifier() => $branches[$driver->getRootIdentifier()]) + $branches;
  27552. }
  27553. foreach ($branches as $branch => $identifier) {
  27554. $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $branch . '</comment>)';
  27555. if ($isVeryVerbose) {
  27556. $this->io->writeError($msg);
  27557. } elseif ($isVerbose) {
  27558. $this->io->overwriteError($msg, false);
  27559. }
  27560. if (!$parsedBranch = $this->validateBranch($branch)) {
  27561. if ($isVeryVerbose) {
  27562. $this->io->writeError('<warning>Skipped branch '.$branch.', invalid name</warning>');
  27563. }
  27564. continue;
  27565. }
  27566. if (strpos($parsedBranch, 'dev-') === 0 || VersionParser::DEFAULT_BRANCH_ALIAS === $parsedBranch) {
  27567. $version = 'dev-' . $branch;
  27568. } else {
  27569. $prefix = strpos($branch, 'v') === 0 ? 'v' : '';
  27570. $version = $prefix . preg_replace('{(\.9{7})+}', '.x', $parsedBranch);
  27571. }
  27572. $cachedPackage = $this->getCachedPackageVersion($version, $identifier, $isVerbose, $isVeryVerbose, $driver->getRootIdentifier() === $branch);
  27573. if ($cachedPackage) {
  27574. $this->addPackage($cachedPackage);
  27575. continue;
  27576. }
  27577. if ($cachedPackage === false) {
  27578. $this->emptyReferences[] = $identifier;
  27579. continue;
  27580. }
  27581. try {
  27582. if (!$data = $driver->getComposerInformation($identifier)) {
  27583. if ($isVeryVerbose) {
  27584. $this->io->writeError('<warning>Skipped branch '.$branch.', no composer file</warning>');
  27585. }
  27586. $this->emptyReferences[] = $identifier;
  27587. continue;
  27588. }
  27589. $data['version'] = $version;
  27590. $data['version_normalized'] = $parsedBranch;
  27591. unset($data['default-branch']);
  27592. if ($driver->getRootIdentifier() === $branch) {
  27593. $data['default-branch'] = true;
  27594. }
  27595. if ($isVeryVerbose) {
  27596. $this->io->writeError('Importing branch '.$branch.' ('.$data['version'].')');
  27597. }
  27598. $packageData = $this->preProcess($driver, $data, $identifier);
  27599. $package = $this->loader->load($packageData);
  27600. if ($this->loader instanceof ValidatingArrayLoader && $this->loader->getWarnings()) {
  27601. throw new InvalidPackageException($this->loader->getErrors(), $this->loader->getWarnings(), $packageData);
  27602. }
  27603. $this->addPackage($package);
  27604. } catch (TransportException $e) {
  27605. $this->versionTransportExceptions['branches'][$branch] = $e;
  27606. if ($e->getCode() === 404) {
  27607. $this->emptyReferences[] = $identifier;
  27608. }
  27609. if ($e->getCode() === 401 || $e->getCode() === 403) {
  27610. throw $e;
  27611. }
  27612. if ($isVeryVerbose) {
  27613. $this->io->writeError('<warning>Skipped branch '.$branch.', no composer file was found (' . $e->getCode() . ' HTTP status code)</warning>');
  27614. }
  27615. continue;
  27616. } catch (\Exception $e) {
  27617. if (!$isVeryVerbose) {
  27618. $this->io->writeError('');
  27619. }
  27620. $this->branchErrorOccurred = true;
  27621. $this->io->writeError('<error>Skipped branch '.$branch.', '.$e->getMessage().'</error>');
  27622. $this->io->writeError('');
  27623. continue;
  27624. }
  27625. }
  27626. $driver->cleanup();
  27627. if (!$isVeryVerbose) {
  27628. $this->io->overwriteError('', false);
  27629. }
  27630. if (!$this->getPackages()) {
  27631. throw new InvalidRepositoryException('No valid composer.json was found in any branch or tag of '.$this->url.', could not load a package from it.');
  27632. }
  27633. }
  27634. protected function preProcess(VcsDriverInterface $driver, array $data, $identifier)
  27635. {
  27636. $dataPackageName = isset($data['name']) ? $data['name'] : null;
  27637. $data['name'] = $this->packageName ?: $dataPackageName;
  27638. if (!isset($data['dist'])) {
  27639. $data['dist'] = $driver->getDist($identifier);
  27640. }
  27641. if (!isset($data['source'])) {
  27642. $data['source'] = $driver->getSource($identifier);
  27643. }
  27644. return $data;
  27645. }
  27646. private function validateBranch($branch)
  27647. {
  27648. try {
  27649. $normalizedBranch = $this->versionParser->normalizeBranch($branch);
  27650. $this->versionParser->parseConstraints($normalizedBranch);
  27651. return $normalizedBranch;
  27652. } catch (\Exception $e) {
  27653. }
  27654. return false;
  27655. }
  27656. private function validateTag($version)
  27657. {
  27658. try {
  27659. return $this->versionParser->normalize($version);
  27660. } catch (\Exception $e) {
  27661. }
  27662. return false;
  27663. }
  27664. private function getCachedPackageVersion($version, $identifier, $isVerbose, $isVeryVerbose, $isDefaultBranch = false)
  27665. {
  27666. if (!$this->versionCache) {
  27667. return;
  27668. }
  27669. $cachedPackage = $this->versionCache->getVersionPackage($version, $identifier);
  27670. if ($cachedPackage === false) {
  27671. if ($isVeryVerbose) {
  27672. $this->io->writeError('<warning>Skipped '.$version.', no composer file (cached from ref '.$identifier.')</warning>');
  27673. }
  27674. return false;
  27675. }
  27676. if ($cachedPackage) {
  27677. $msg = 'Found cached composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $version . '</comment>)';
  27678. if ($isVeryVerbose) {
  27679. $this->io->writeError($msg);
  27680. } elseif ($isVerbose) {
  27681. $this->io->overwriteError($msg, false);
  27682. }
  27683. unset($cachedPackage['default-branch']);
  27684. if ($isDefaultBranch) {
  27685. $cachedPackage['default-branch'] = true;
  27686. }
  27687. if ($existingPackage = $this->findPackage($cachedPackage['name'], new Constraint('=', $cachedPackage['version_normalized']))) {
  27688. if ($isVeryVerbose) {
  27689. $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>');
  27690. }
  27691. $cachedPackage = null;
  27692. }
  27693. }
  27694. if ($cachedPackage) {
  27695. return $this->loader->load($cachedPackage);
  27696. }
  27697. return null;
  27698. }
  27699. }
  27700. <?php
  27701. namespace Composer\Repository;
  27702. interface VersionCacheInterface
  27703. {
  27704. public function getVersionPackage($version, $identifier);
  27705. }
  27706. <?php
  27707. namespace Composer\Repository;
  27708. use Composer\Package\AliasPackage;
  27709. use Composer\Installer\InstallationManager;
  27710. class WritableArrayRepository extends ArrayRepository implements WritableRepositoryInterface
  27711. {
  27712. public function write($devMode, InstallationManager $installationManager)
  27713. {
  27714. }
  27715. public function reload()
  27716. {
  27717. }
  27718. public function getCanonicalPackages()
  27719. {
  27720. $packages = $this->getPackages();
  27721. $packagesByName = array();
  27722. foreach ($packages as $package) {
  27723. if (!isset($packagesByName[$package->getName()]) || $packagesByName[$package->getName()] instanceof AliasPackage) {
  27724. $packagesByName[$package->getName()] = $package;
  27725. }
  27726. }
  27727. $canonicalPackages = array();
  27728. foreach ($packagesByName as $package) {
  27729. while ($package instanceof AliasPackage) {
  27730. $package = $package->getAliasOf();
  27731. }
  27732. $canonicalPackages[] = $package;
  27733. }
  27734. return $canonicalPackages;
  27735. }
  27736. }
  27737. <?php
  27738. namespace Composer\Repository;
  27739. use Composer\Package\PackageInterface;
  27740. use Composer\Installer\InstallationManager;
  27741. interface WritableRepositoryInterface extends RepositoryInterface
  27742. {
  27743. public function write($devMode, InstallationManager $installationManager);
  27744. public function addPackage(PackageInterface $package);
  27745. public function removePackage(PackageInterface $package);
  27746. public function getCanonicalPackages();
  27747. public function reload();
  27748. }
  27749. <?php
  27750. namespace Composer\Script;
  27751. use Composer\Composer;
  27752. use Composer\IO\IOInterface;
  27753. use Composer\EventDispatcher\Event as BaseEvent;
  27754. class Event extends BaseEvent
  27755. {
  27756. private $composer;
  27757. private $io;
  27758. private $devMode;
  27759. private $originatingEvent;
  27760. public function __construct($name, Composer $composer, IOInterface $io, $devMode = false, array $args = array(), array $flags = array())
  27761. {
  27762. parent::__construct($name, $args, $flags);
  27763. $this->composer = $composer;
  27764. $this->io = $io;
  27765. $this->devMode = $devMode;
  27766. }
  27767. public function getComposer()
  27768. {
  27769. return $this->composer;
  27770. }
  27771. public function getIO()
  27772. {
  27773. return $this->io;
  27774. }
  27775. public function isDevMode()
  27776. {
  27777. return $this->devMode;
  27778. }
  27779. public function getOriginatingEvent()
  27780. {
  27781. return $this->originatingEvent;
  27782. }
  27783. public function setOriginatingEvent(BaseEvent $event)
  27784. {
  27785. $this->originatingEvent = $this->calculateOriginatingEvent($event);
  27786. return $this;
  27787. }
  27788. private function calculateOriginatingEvent(BaseEvent $event)
  27789. {
  27790. if ($event instanceof Event && $event->getOriginatingEvent()) {
  27791. return $this->calculateOriginatingEvent($event->getOriginatingEvent());
  27792. }
  27793. return $event;
  27794. }
  27795. }
  27796. <?php
  27797. namespace Composer\Script;
  27798. class ScriptEvents
  27799. {
  27800. const PRE_INSTALL_CMD = 'pre-install-cmd';
  27801. const POST_INSTALL_CMD = 'post-install-cmd';
  27802. const PRE_UPDATE_CMD = 'pre-update-cmd';
  27803. const POST_UPDATE_CMD = 'post-update-cmd';
  27804. const PRE_STATUS_CMD = 'pre-status-cmd';
  27805. const POST_STATUS_CMD = 'post-status-cmd';
  27806. const PRE_AUTOLOAD_DUMP = 'pre-autoload-dump';
  27807. const POST_AUTOLOAD_DUMP = 'post-autoload-dump';
  27808. const POST_ROOT_PACKAGE_INSTALL = 'post-root-package-install';
  27809. const POST_CREATE_PROJECT_CMD = 'post-create-project-cmd';
  27810. const PRE_ARCHIVE_CMD = 'pre-archive-cmd';
  27811. const POST_ARCHIVE_CMD = 'post-archive-cmd';
  27812. }
  27813. <?php
  27814. namespace Composer\SelfUpdate;
  27815. class Keys
  27816. {
  27817. public static function fingerprint($path)
  27818. {
  27819. $hash = strtoupper(hash('sha256', preg_replace('{\s}', '', file_get_contents($path))));
  27820. return implode(' ', array(
  27821. substr($hash, 0, 8),
  27822. substr($hash, 8, 8),
  27823. substr($hash, 16, 8),
  27824. substr($hash, 24, 8),
  27825. '',
  27826. substr($hash, 32, 8),
  27827. substr($hash, 40, 8),
  27828. substr($hash, 48, 8),
  27829. substr($hash, 56, 8),
  27830. ));
  27831. }
  27832. }
  27833. <?php
  27834. namespace Composer\SelfUpdate;
  27835. use Composer\Util\HttpDownloader;
  27836. use Composer\Config;
  27837. use Composer\Json\JsonFile;
  27838. class Versions
  27839. {
  27840. public static $channels = array('stable', 'preview', 'snapshot', '1', '2');
  27841. private $httpDownloader;
  27842. private $config;
  27843. private $channel;
  27844. private $versionsData;
  27845. public function __construct(Config $config, HttpDownloader $httpDownloader)
  27846. {
  27847. $this->httpDownloader = $httpDownloader;
  27848. $this->config = $config;
  27849. }
  27850. public function getChannel()
  27851. {
  27852. if ($this->channel) {
  27853. return $this->channel;
  27854. }
  27855. $channelFile = $this->config->get('home').'/update-channel';
  27856. if (file_exists($channelFile)) {
  27857. $channel = trim(file_get_contents($channelFile));
  27858. if (in_array($channel, array('stable', 'preview', 'snapshot'), true)) {
  27859. return $this->channel = $channel;
  27860. }
  27861. }
  27862. return $this->channel = 'stable';
  27863. }
  27864. public function setChannel($channel)
  27865. {
  27866. if (!in_array($channel, self::$channels, true)) {
  27867. throw new \InvalidArgumentException('Invalid channel '.$channel.', must be one of: ' . implode(', ', self::$channels));
  27868. }
  27869. $channelFile = $this->config->get('home').'/update-channel';
  27870. $this->channel = $channel;
  27871. file_put_contents($channelFile, (is_numeric($channel) ? 'stable' : $channel).PHP_EOL);
  27872. }
  27873. public function getLatest($channel = null)
  27874. {
  27875. $versions = $this->getVersionsData();
  27876. foreach ($versions[$channel ?: $this->getChannel()] as $version) {
  27877. if ($version['min-php'] <= PHP_VERSION_ID) {
  27878. return $version;
  27879. }
  27880. }
  27881. throw new \UnexpectedValueException('There is no version of Composer available for your PHP version ('.PHP_VERSION.')');
  27882. }
  27883. private function getVersionsData()
  27884. {
  27885. if (!$this->versionsData) {
  27886. if ($this->config->get('disable-tls') === true) {
  27887. $protocol = 'http';
  27888. } else {
  27889. $protocol = 'https';
  27890. }
  27891. $this->versionsData = $this->httpDownloader->get($protocol . '://getcomposer.org/versions')->decodeJson();
  27892. }
  27893. return $this->versionsData;
  27894. }
  27895. }
  27896. <?php
  27897. namespace Composer\Util;
  27898. use Composer\Config;
  27899. use Composer\IO\IOInterface;
  27900. use Composer\Downloader\TransportException;
  27901. class AuthHelper
  27902. {
  27903. protected $io;
  27904. protected $config;
  27905. private $displayedOriginAuthentications = array();
  27906. public function __construct(IOInterface $io, Config $config)
  27907. {
  27908. $this->io = $io;
  27909. $this->config = $config;
  27910. }
  27911. public function storeAuth($origin, $storeAuth)
  27912. {
  27913. $store = false;
  27914. $configSource = $this->config->getAuthConfigSource();
  27915. if ($storeAuth === true) {
  27916. $store = $configSource;
  27917. } elseif ($storeAuth === 'prompt') {
  27918. $answer = $this->io->askAndValidate(
  27919. 'Do you want to store credentials for '.$origin.' in '.$configSource->getName().' ? [Yn] ',
  27920. function ($value) {
  27921. $input = strtolower(substr(trim($value), 0, 1));
  27922. if (in_array($input, array('y','n'))) {
  27923. return $input;
  27924. }
  27925. throw new \RuntimeException('Please answer (y)es or (n)o');
  27926. },
  27927. null,
  27928. 'y'
  27929. );
  27930. if ($answer === 'y') {
  27931. $store = $configSource;
  27932. }
  27933. }
  27934. if ($store) {
  27935. $store->addConfigSetting(
  27936. 'http-basic.'.$origin,
  27937. $this->io->getAuthentication($origin)
  27938. );
  27939. }
  27940. }
  27941. public function promptAuthIfNeeded($url, $origin, $statusCode, $reason = null, $headers = array())
  27942. {
  27943. $storeAuth = false;
  27944. if (in_array($origin, $this->config->get('github-domains'), true)) {
  27945. $gitHubUtil = new GitHub($this->io, $this->config, null);
  27946. $message = "\n";
  27947. $rateLimited = $gitHubUtil->isRateLimited($headers);
  27948. if ($rateLimited) {
  27949. $rateLimit = $gitHubUtil->getRateLimit($headers);
  27950. if ($this->io->hasAuthentication($origin)) {
  27951. $message = 'Review your configured GitHub OAuth token or enter a new one to go over the API rate limit.';
  27952. } else {
  27953. $message = 'Create a GitHub OAuth token to go over the API rate limit.';
  27954. }
  27955. $message = sprintf(
  27956. '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.',
  27957. $rateLimit['limit'],
  27958. $rateLimit['reset']
  27959. )."\n";
  27960. } else {
  27961. $message .= 'Could not fetch '.$url.', please ';
  27962. if ($this->io->hasAuthentication($origin)) {
  27963. $message .= 'review your configured GitHub OAuth token or enter a new one to access private repos';
  27964. } else {
  27965. $message .= 'create a GitHub OAuth token to access private repos';
  27966. }
  27967. }
  27968. if (!$gitHubUtil->authorizeOAuth($origin)
  27969. && (!$this->io->isInteractive() || !$gitHubUtil->authorizeOAuthInteractively($origin, $message))
  27970. ) {
  27971. throw new TransportException('Could not authenticate against '.$origin, 401);
  27972. }
  27973. } elseif (in_array($origin, $this->config->get('gitlab-domains'), true)) {
  27974. $message = "\n".'Could not fetch '.$url.', enter your ' . $origin . ' credentials ' .($statusCode === 401 ? 'to access private repos' : 'to go over the API rate limit');
  27975. $gitLabUtil = new GitLab($this->io, $this->config, null);
  27976. if ($this->io->hasAuthentication($origin) && ($auth = $this->io->getAuthentication($origin)) && in_array($auth['password'], array('gitlab-ci-token', 'private-token', 'oauth2'), true)) {
  27977. throw new TransportException("Invalid credentials for '" . $url . "', aborting.", $statusCode);
  27978. }
  27979. if (!$gitLabUtil->authorizeOAuth($origin)
  27980. && (!$this->io->isInteractive() || !$gitLabUtil->authorizeOAuthInteractively(parse_url($url, PHP_URL_SCHEME), $origin, $message))
  27981. ) {
  27982. throw new TransportException('Could not authenticate against '.$origin, 401);
  27983. }
  27984. } elseif ($origin === 'bitbucket.org') {
  27985. $askForOAuthToken = true;
  27986. if ($this->io->hasAuthentication($origin)) {
  27987. $auth = $this->io->getAuthentication($origin);
  27988. if ($auth['username'] !== 'x-token-auth') {
  27989. $bitbucketUtil = new Bitbucket($this->io, $this->config);
  27990. $accessToken = $bitbucketUtil->requestToken($origin, $auth['username'], $auth['password']);
  27991. if (!empty($accessToken)) {
  27992. $this->io->setAuthentication($origin, 'x-token-auth', $accessToken);
  27993. $askForOAuthToken = false;
  27994. }
  27995. } else {
  27996. throw new TransportException('Could not authenticate against ' . $origin, 401);
  27997. }
  27998. }
  27999. if ($askForOAuthToken) {
  28000. $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');
  28001. $bitBucketUtil = new Bitbucket($this->io, $this->config);
  28002. if (! $bitBucketUtil->authorizeOAuth($origin)
  28003. && (! $this->io->isInteractive() || !$bitBucketUtil->authorizeOAuthInteractively($origin, $message))
  28004. ) {
  28005. throw new TransportException('Could not authenticate against ' . $origin, 401);
  28006. }
  28007. }
  28008. } else {
  28009. if ($statusCode === 404) {
  28010. return;
  28011. }
  28012. if (!$this->io->isInteractive()) {
  28013. if ($statusCode === 401) {
  28014. $message = "The '" . $url . "' URL required authentication.\nYou must be using the interactive console to authenticate";
  28015. } elseif ($statusCode === 403) {
  28016. $message = "The '" . $url . "' URL could not be accessed: " . $reason;
  28017. } else {
  28018. $message = "Unknown error code '" . $statusCode . "', reason: " . $reason;
  28019. }
  28020. throw new TransportException($message, $statusCode);
  28021. }
  28022. if ($this->io->hasAuthentication($origin)) {
  28023. throw new TransportException("Invalid credentials for '" . $url . "', aborting.", $statusCode);
  28024. }
  28025. $this->io->writeError(' Authentication required (<info>'.$origin.'</info>):');
  28026. $username = $this->io->ask(' Username: ');
  28027. $password = $this->io->askAndHideAnswer(' Password: ');
  28028. $this->io->setAuthentication($origin, $username, $password);
  28029. $storeAuth = $this->config->get('store-auths');
  28030. }
  28031. return array('retry' => true, 'storeAuth' => $storeAuth);
  28032. }
  28033. public function addAuthenticationHeader(array $headers, $origin, $url)
  28034. {
  28035. if ($this->io->hasAuthentication($origin)) {
  28036. $authenticationDisplayMessage = null;
  28037. $auth = $this->io->getAuthentication($origin);
  28038. if ($auth['password'] === 'bearer') {
  28039. $headers[] = 'Authorization: Bearer '.$auth['username'];
  28040. } elseif ('github.com' === $origin && 'x-oauth-basic' === $auth['password']) {
  28041. if (preg_match('{^https?://api\.github\.com/}', $url)) {
  28042. $headers[] = 'Authorization: token '.$auth['username'];
  28043. $authenticationDisplayMessage = 'Using GitHub token authentication';
  28044. }
  28045. } elseif (
  28046. in_array($origin, $this->config->get('gitlab-domains'), true)
  28047. && in_array($auth['password'], array('oauth2', 'private-token', 'gitlab-ci-token'), true)
  28048. ) {
  28049. if ($auth['password'] === 'oauth2') {
  28050. $headers[] = 'Authorization: Bearer '.$auth['username'];
  28051. $authenticationDisplayMessage = 'Using GitLab OAuth token authentication';
  28052. } elseif ($auth['password'] === 'private-token' || $auth['password'] === 'gitlab-ci-token') {
  28053. $headers[] = 'PRIVATE-TOKEN: '.$auth['username'];
  28054. $authenticationDisplayMessage = 'Using GitLab private token authentication';
  28055. }
  28056. } elseif (
  28057. 'bitbucket.org' === $origin
  28058. && $url !== Bitbucket::OAUTH2_ACCESS_TOKEN_URL
  28059. && 'x-token-auth' === $auth['username']
  28060. ) {
  28061. if (!$this->isPublicBitBucketDownload($url)) {
  28062. $headers[] = 'Authorization: Bearer ' . $auth['password'];
  28063. $authenticationDisplayMessage = 'Using Bitbucket OAuth token authentication';
  28064. }
  28065. } else {
  28066. $authStr = base64_encode($auth['username'] . ':' . $auth['password']);
  28067. $headers[] = 'Authorization: Basic '.$authStr;
  28068. $authenticationDisplayMessage = 'Using HTTP basic authentication with username "' . $auth['username'] . '"';
  28069. }
  28070. if ($authenticationDisplayMessage && !in_array($origin, $this->displayedOriginAuthentications, true)) {
  28071. $this->io->writeError($authenticationDisplayMessage, true, IOInterface::DEBUG);
  28072. $this->displayedOriginAuthentications[] = $origin;
  28073. }
  28074. } elseif (in_array($origin, array('api.bitbucket.org', 'api.github.com'), true)) {
  28075. return $this->addAuthenticationHeader($headers, str_replace('api.', '', $origin), $url);
  28076. }
  28077. return $headers;
  28078. }
  28079. public function isPublicBitBucketDownload($urlToBitBucketFile)
  28080. {
  28081. $domain = parse_url($urlToBitBucketFile, PHP_URL_HOST);
  28082. if (strpos($domain, 'bitbucket.org') === false) {
  28083. return true;
  28084. }
  28085. $path = parse_url($urlToBitBucketFile, PHP_URL_PATH);
  28086. $pathParts = explode('/', $path);
  28087. return count($pathParts) >= 4 && $pathParts[3] == 'downloads';
  28088. }
  28089. }
  28090. <?php
  28091. namespace Composer\Util;
  28092. use Composer\Factory;
  28093. use Composer\IO\IOInterface;
  28094. use Composer\Config;
  28095. use Composer\Downloader\TransportException;
  28096. class Bitbucket
  28097. {
  28098. private $io;
  28099. private $config;
  28100. private $process;
  28101. private $httpDownloader;
  28102. private $token = array();
  28103. private $time;
  28104. const OAUTH2_ACCESS_TOKEN_URL = 'https://bitbucket.org/site/oauth2/access_token';
  28105. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null, $time = null)
  28106. {
  28107. $this->io = $io;
  28108. $this->config = $config;
  28109. $this->process = $process ?: new ProcessExecutor($io);
  28110. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  28111. $this->time = $time;
  28112. }
  28113. public function getToken()
  28114. {
  28115. if (!isset($this->token['access_token'])) {
  28116. return '';
  28117. }
  28118. return $this->token['access_token'];
  28119. }
  28120. public function authorizeOAuth($originUrl)
  28121. {
  28122. if ($originUrl !== 'bitbucket.org') {
  28123. return false;
  28124. }
  28125. if (0 === $this->process->execute('git config bitbucket.accesstoken', $output)) {
  28126. $this->io->setAuthentication($originUrl, 'x-token-auth', trim($output));
  28127. return true;
  28128. }
  28129. return false;
  28130. }
  28131. private function requestAccessToken()
  28132. {
  28133. try {
  28134. $response = $this->httpDownloader->get(self::OAUTH2_ACCESS_TOKEN_URL, array(
  28135. 'retry-auth-failure' => false,
  28136. 'http' => array(
  28137. 'method' => 'POST',
  28138. 'content' => 'grant_type=client_credentials',
  28139. ),
  28140. ));
  28141. $this->token = $response->decodeJson();
  28142. } catch (TransportException $e) {
  28143. if ($e->getCode() === 400) {
  28144. $this->io->writeError('<error>Invalid OAuth consumer provided.</error>');
  28145. $this->io->writeError('This can have two reasons:');
  28146. $this->io->writeError('1. You are authenticating with a bitbucket username/password combination');
  28147. $this->io->writeError('2. You are using an OAuth consumer, but didn\'t configure a (dummy) callback url');
  28148. return false;
  28149. }
  28150. if (in_array($e->getCode(), array(403, 401))) {
  28151. $this->io->writeError('<error>Invalid OAuth consumer provided.</error>');
  28152. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  28153. return false;
  28154. }
  28155. throw $e;
  28156. }
  28157. return true;
  28158. }
  28159. public function authorizeOAuthInteractively($originUrl, $message = null)
  28160. {
  28161. if ($message) {
  28162. $this->io->writeError($message);
  28163. }
  28164. $url = 'https://confluence.atlassian.com/bitbucket/oauth-on-bitbucket-cloud-238027431.html';
  28165. $this->io->writeError(sprintf('Follow the instructions on %s', $url));
  28166. $this->io->writeError(sprintf('to create a consumer. It will be stored in "%s" for future use by Composer.', $this->config->getAuthConfigSource()->getName()));
  28167. $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)');
  28168. $consumerKey = trim($this->io->askAndHideAnswer('Consumer Key (hidden): '));
  28169. if (!$consumerKey) {
  28170. $this->io->writeError('<warning>No consumer key given, aborting.</warning>');
  28171. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  28172. return false;
  28173. }
  28174. $consumerSecret = trim($this->io->askAndHideAnswer('Consumer Secret (hidden): '));
  28175. if (!$consumerSecret) {
  28176. $this->io->writeError('<warning>No consumer secret given, aborting.</warning>');
  28177. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  28178. return false;
  28179. }
  28180. $this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret);
  28181. if (!$this->requestAccessToken()) {
  28182. return false;
  28183. }
  28184. $this->storeInAuthConfig($originUrl, $consumerKey, $consumerSecret);
  28185. $this->config->getAuthConfigSource()->removeConfigSetting('http-basic.' . $originUrl);
  28186. $this->io->writeError('<info>Consumer stored successfully.</info>');
  28187. return true;
  28188. }
  28189. public function requestToken($originUrl, $consumerKey, $consumerSecret)
  28190. {
  28191. if (!empty($this->token) || $this->getTokenFromConfig($originUrl)) {
  28192. return $this->token['access_token'];
  28193. }
  28194. $this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret);
  28195. if (!$this->requestAccessToken()) {
  28196. return '';
  28197. }
  28198. $this->storeInAuthConfig($originUrl, $consumerKey, $consumerSecret);
  28199. return $this->token['access_token'];
  28200. }
  28201. private function storeInAuthConfig($originUrl, $consumerKey, $consumerSecret)
  28202. {
  28203. $this->config->getConfigSource()->removeConfigSetting('bitbucket-oauth.'.$originUrl);
  28204. $time = null === $this->time ? time() : $this->time;
  28205. $consumer = array(
  28206. "consumer-key" => $consumerKey,
  28207. "consumer-secret" => $consumerSecret,
  28208. "access-token" => $this->token['access_token'],
  28209. "access-token-expiration" => $time + $this->token['expires_in'],
  28210. );
  28211. $this->config->getAuthConfigSource()->addConfigSetting('bitbucket-oauth.'.$originUrl, $consumer);
  28212. }
  28213. private function getTokenFromConfig($originUrl)
  28214. {
  28215. $authConfig = $this->config->get('bitbucket-oauth');
  28216. if (
  28217. !isset($authConfig[$originUrl]['access-token'], $authConfig[$originUrl]['access-token-expiration'])
  28218. || time() > $authConfig[$originUrl]['access-token-expiration']
  28219. ) {
  28220. return false;
  28221. }
  28222. $this->token = array(
  28223. 'access_token' => $authConfig[$originUrl]['access-token'],
  28224. );
  28225. return true;
  28226. }
  28227. }
  28228. <?php
  28229. namespace Composer\Util;
  28230. class ComposerMirror
  28231. {
  28232. public static function processUrl($mirrorUrl, $packageName, $version, $reference, $type)
  28233. {
  28234. if ($reference) {
  28235. $reference = preg_match('{^([a-f0-9]*|%reference%)$}', $reference) ? $reference : md5($reference);
  28236. }
  28237. $version = strpos($version, '/') === false ? $version : md5($version);
  28238. return str_replace(
  28239. array('%package%', '%version%', '%reference%', '%type%'),
  28240. array($packageName, $version, $reference, $type),
  28241. $mirrorUrl
  28242. );
  28243. }
  28244. public static function processGitUrl($mirrorUrl, $packageName, $url, $type)
  28245. {
  28246. if (preg_match('#^(?:(?:https?|git)://github\.com/|git@github\.com:)([^/]+)/(.+?)(?:\.git)?$#', $url, $match)) {
  28247. $url = 'gh-'.$match[1].'/'.$match[2];
  28248. } elseif (preg_match('#^https://bitbucket\.org/([^/]+)/(.+?)(?:\.git)?/?$#', $url, $match)) {
  28249. $url = 'bb-'.$match[1].'/'.$match[2];
  28250. } else {
  28251. $url = preg_replace('{[^a-z0-9_.-]}i', '-', trim($url, '/'));
  28252. }
  28253. return str_replace(
  28254. array('%package%', '%normalizedUrl%', '%type%'),
  28255. array($packageName, $url, $type),
  28256. $mirrorUrl
  28257. );
  28258. }
  28259. public static function processHgUrl($mirrorUrl, $packageName, $url, $type)
  28260. {
  28261. return self::processGitUrl($mirrorUrl, $packageName, $url, $type);
  28262. }
  28263. }
  28264. <?php
  28265. namespace Composer\Util;
  28266. use Composer\Package\Loader\ArrayLoader;
  28267. use Composer\Package\Loader\ValidatingArrayLoader;
  28268. use Composer\Package\Loader\InvalidPackageException;
  28269. use Composer\Json\JsonValidationException;
  28270. use Composer\IO\IOInterface;
  28271. use Composer\Json\JsonFile;
  28272. use Composer\Spdx\SpdxLicenses;
  28273. class ConfigValidator
  28274. {
  28275. const CHECK_VERSION = 1;
  28276. private $io;
  28277. public function __construct(IOInterface $io)
  28278. {
  28279. $this->io = $io;
  28280. }
  28281. public function validate($file, $arrayLoaderValidationFlags = ValidatingArrayLoader::CHECK_ALL, $flags = self::CHECK_VERSION)
  28282. {
  28283. $errors = array();
  28284. $publishErrors = array();
  28285. $warnings = array();
  28286. $laxValid = false;
  28287. try {
  28288. $json = new JsonFile($file, null, $this->io);
  28289. $manifest = $json->read();
  28290. $json->validateSchema(JsonFile::LAX_SCHEMA);
  28291. $laxValid = true;
  28292. $json->validateSchema();
  28293. } catch (JsonValidationException $e) {
  28294. foreach ($e->getErrors() as $message) {
  28295. if ($laxValid) {
  28296. $publishErrors[] = $message;
  28297. } else {
  28298. $errors[] = $message;
  28299. }
  28300. }
  28301. } catch (\Exception $e) {
  28302. $errors[] = $e->getMessage();
  28303. return array($errors, $publishErrors, $warnings);
  28304. }
  28305. if (empty($manifest['license'])) {
  28306. $warnings[] = 'No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.';
  28307. } else {
  28308. $licenses = (array) $manifest['license'];
  28309. foreach ($licenses as $key => $license) {
  28310. if ('proprietary' === $license) {
  28311. unset($licenses[$key]);
  28312. }
  28313. }
  28314. $licenseValidator = new SpdxLicenses();
  28315. foreach ($licenses as $license) {
  28316. $spdxLicense = $licenseValidator->getLicenseByIdentifier($license);
  28317. if ($spdxLicense && $spdxLicense[3]) {
  28318. if (preg_match('{^[AL]?GPL-[123](\.[01])?\+$}i', $license)) {
  28319. $warnings[] = sprintf(
  28320. 'License "%s" is a deprecated SPDX license identifier, use "'.str_replace('+', '', $license).'-or-later" instead',
  28321. $license
  28322. );
  28323. } elseif (preg_match('{^[AL]?GPL-[123](\.[01])?$}i', $license)) {
  28324. $warnings[] = sprintf(
  28325. 'License "%s" is a deprecated SPDX license identifier, use "'.$license.'-only" or "'.$license.'-or-later" instead',
  28326. $license
  28327. );
  28328. } else {
  28329. $warnings[] = sprintf(
  28330. 'License "%s" is a deprecated SPDX license identifier, see https://spdx.org/licenses/',
  28331. $license
  28332. );
  28333. }
  28334. }
  28335. }
  28336. }
  28337. if (($flags & self::CHECK_VERSION) && isset($manifest['version'])) {
  28338. $warnings[] = 'The version field is present, it is recommended to leave it out if the package is published on Packagist.';
  28339. }
  28340. if (!empty($manifest['name']) && preg_match('{[A-Z]}', $manifest['name'])) {
  28341. $suggestName = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $manifest['name']);
  28342. $suggestName = strtolower($suggestName);
  28343. $publishErrors[] = sprintf(
  28344. '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.',
  28345. $manifest['name'],
  28346. $suggestName
  28347. );
  28348. }
  28349. if (!empty($manifest['type']) && $manifest['type'] == 'composer-installer') {
  28350. $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.";
  28351. }
  28352. if (isset($manifest['require'], $manifest['require-dev'])) {
  28353. $requireOverrides = array_intersect_key($manifest['require'], $manifest['require-dev']);
  28354. if (!empty($requireOverrides)) {
  28355. $plural = (count($requireOverrides) > 1) ? 'are' : 'is';
  28356. $warnings[] = implode(', ', array_keys($requireOverrides)). " {$plural} required both in require and require-dev, this can lead to unexpected behavior";
  28357. }
  28358. }
  28359. $require = isset($manifest['require']) ? $manifest['require'] : array();
  28360. $requireDev = isset($manifest['require-dev']) ? $manifest['require-dev'] : array();
  28361. $packages = array_merge($require, $requireDev);
  28362. foreach ($packages as $package => $version) {
  28363. if (preg_match('/#/', $version) === 1) {
  28364. $warnings[] = sprintf(
  28365. 'The package "%s" is pointing to a commit-ref, this is bad practice and can cause unforeseen issues.',
  28366. $package
  28367. );
  28368. }
  28369. }
  28370. $scriptsDescriptions = isset($manifest['scripts-descriptions']) ? $manifest['scripts-descriptions'] : array();
  28371. $scripts = isset($manifest['scripts']) ? $manifest['scripts'] : array();
  28372. foreach ($scriptsDescriptions as $scriptName => $scriptDescription) {
  28373. if (!array_key_exists($scriptName, $scripts)) {
  28374. $warnings[] = sprintf(
  28375. 'Description for non-existent script "%s" found in "scripts-descriptions"',
  28376. $scriptName
  28377. );
  28378. }
  28379. }
  28380. if (isset($manifest['autoload']['psr-0'][''])) {
  28381. $warnings[] = "Defining autoload.psr-0 with an empty namespace prefix is a bad idea for performance";
  28382. }
  28383. if (isset($manifest['autoload']['psr-4'][''])) {
  28384. $warnings[] = "Defining autoload.psr-4 with an empty namespace prefix is a bad idea for performance";
  28385. }
  28386. $loader = new ValidatingArrayLoader(new ArrayLoader(), true, null, $arrayLoaderValidationFlags);
  28387. try {
  28388. if (!isset($manifest['version'])) {
  28389. $manifest['version'] = '1.0.0';
  28390. }
  28391. if (!isset($manifest['name'])) {
  28392. $manifest['name'] = 'dummy/dummy';
  28393. }
  28394. $loader->load($manifest);
  28395. } catch (InvalidPackageException $e) {
  28396. $errors = array_merge($errors, $e->getErrors());
  28397. }
  28398. $warnings = array_merge($warnings, $loader->getWarnings());
  28399. return array($errors, $publishErrors, $warnings);
  28400. }
  28401. }
  28402. <?php
  28403. namespace Composer\Util;
  28404. use Composer\IO\IOInterface;
  28405. class ErrorHandler
  28406. {
  28407. private static $io;
  28408. public static function handle($level, $message, $file, $line)
  28409. {
  28410. if (!(error_reporting() & $level)) {
  28411. return;
  28412. }
  28413. if (filter_var(ini_get('xdebug.scream'), FILTER_VALIDATE_BOOLEAN)) {
  28414. $message .= "\n\nWarning: You have xdebug.scream enabled, the warning above may be".
  28415. "\na legitimately suppressed error that you were not supposed to see.";
  28416. }
  28417. if ($level !== E_DEPRECATED && $level !== E_USER_DEPRECATED) {
  28418. throw new \ErrorException($message, 0, $level, $file, $line);
  28419. }
  28420. if (self::$io) {
  28421. self::$io->writeError('<warning>Deprecation Notice: '.$message.' in '.$file.':'.$line.'</warning>');
  28422. if (self::$io->isVerbose()) {
  28423. self::$io->writeError('<warning>Stack trace:</warning>');
  28424. self::$io->writeError(array_filter(array_map(function ($a) {
  28425. if (isset($a['line'], $a['file'])) {
  28426. return '<warning> '.$a['file'].':'.$a['line'].'</warning>';
  28427. }
  28428. return null;
  28429. }, array_slice(debug_backtrace(), 2))));
  28430. }
  28431. }
  28432. return true;
  28433. }
  28434. public static function register(IOInterface $io = null)
  28435. {
  28436. set_error_handler(array(__CLASS__, 'handle'));
  28437. error_reporting(E_ALL | E_STRICT);
  28438. self::$io = $io;
  28439. }
  28440. }
  28441. <?php
  28442. namespace Composer\Util;
  28443. use RecursiveDirectoryIterator;
  28444. use RecursiveIteratorIterator;
  28445. use Symfony\Component\Filesystem\Exception\IOException;
  28446. use Symfony\Component\Finder\Finder;
  28447. class Filesystem
  28448. {
  28449. private $processExecutor;
  28450. public function __construct(ProcessExecutor $executor = null)
  28451. {
  28452. $this->processExecutor = $executor;
  28453. }
  28454. public function remove($file)
  28455. {
  28456. if (is_dir($file)) {
  28457. return $this->removeDirectory($file);
  28458. }
  28459. if (file_exists($file)) {
  28460. return $this->unlink($file);
  28461. }
  28462. return false;
  28463. }
  28464. public function isDirEmpty($dir)
  28465. {
  28466. $finder = Finder::create()
  28467. ->ignoreVCS(false)
  28468. ->ignoreDotFiles(false)
  28469. ->depth(0)
  28470. ->in($dir);
  28471. return \count($finder) === 0;
  28472. }
  28473. public function emptyDirectory($dir, $ensureDirectoryExists = true)
  28474. {
  28475. if (file_exists($dir) && is_link($dir)) {
  28476. $this->unlink($dir);
  28477. }
  28478. if ($ensureDirectoryExists) {
  28479. $this->ensureDirectoryExists($dir);
  28480. }
  28481. if (is_dir($dir)) {
  28482. $finder = Finder::create()
  28483. ->ignoreVCS(false)
  28484. ->ignoreDotFiles(false)
  28485. ->depth(0)
  28486. ->in($dir);
  28487. foreach ($finder as $path) {
  28488. $this->remove((string) $path);
  28489. }
  28490. }
  28491. }
  28492. public function removeDirectory($directory)
  28493. {
  28494. if ($this->isSymlinkedDirectory($directory)) {
  28495. return $this->unlinkSymlinkedDirectory($directory);
  28496. }
  28497. if ($this->isJunction($directory)) {
  28498. return $this->removeJunction($directory);
  28499. }
  28500. if (is_link($directory)) {
  28501. return unlink($directory);
  28502. }
  28503. if (!file_exists($directory) || !is_dir($directory)) {
  28504. return true;
  28505. }
  28506. if (preg_match('{^(?:[a-z]:)?[/\\\\]+$}i', $directory)) {
  28507. throw new \RuntimeException('Aborting an attempted deletion of '.$directory.', this was probably not intended, if it is a real use case please report it.');
  28508. }
  28509. if (!\function_exists('proc_open')) {
  28510. return $this->removeDirectoryPhp($directory);
  28511. }
  28512. if (Platform::isWindows()) {
  28513. $cmd = sprintf('rmdir /S /Q %s', ProcessExecutor::escape(realpath($directory)));
  28514. } else {
  28515. $cmd = sprintf('rm -rf %s', ProcessExecutor::escape($directory));
  28516. }
  28517. $result = $this->getProcess()->execute($cmd, $output) === 0;
  28518. clearstatcache();
  28519. if ($result && !file_exists($directory)) {
  28520. return true;
  28521. }
  28522. return $this->removeDirectoryPhp($directory);
  28523. }
  28524. public function removeDirectoryPhp($directory)
  28525. {
  28526. try {
  28527. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  28528. } catch (\UnexpectedValueException $e) {
  28529. clearstatcache();
  28530. usleep(100000);
  28531. if (!is_dir($directory)) {
  28532. return true;
  28533. }
  28534. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  28535. }
  28536. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
  28537. foreach ($ri as $file) {
  28538. if ($file->isDir()) {
  28539. $this->rmdir($file->getPathname());
  28540. } else {
  28541. $this->unlink($file->getPathname());
  28542. }
  28543. }
  28544. return $this->rmdir($directory);
  28545. }
  28546. public function ensureDirectoryExists($directory)
  28547. {
  28548. if (!is_dir($directory)) {
  28549. if (file_exists($directory)) {
  28550. throw new \RuntimeException(
  28551. $directory.' exists and is not a directory.'
  28552. );
  28553. }
  28554. if (!@mkdir($directory, 0777, true)) {
  28555. throw new \RuntimeException(
  28556. $directory.' does not exist and could not be created.'
  28557. );
  28558. }
  28559. }
  28560. }
  28561. public function unlink($path)
  28562. {
  28563. $unlinked = @$this->unlinkImplementation($path);
  28564. if (!$unlinked) {
  28565. if (Platform::isWindows()) {
  28566. usleep(350000);
  28567. $unlinked = @$this->unlinkImplementation($path);
  28568. }
  28569. if (!$unlinked) {
  28570. $error = error_get_last();
  28571. $message = 'Could not delete '.$path.': ' . @$error['message'];
  28572. if (Platform::isWindows()) {
  28573. $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed";
  28574. }
  28575. throw new \RuntimeException($message);
  28576. }
  28577. }
  28578. return true;
  28579. }
  28580. public function rmdir($path)
  28581. {
  28582. $deleted = @rmdir($path);
  28583. if (!$deleted) {
  28584. if (Platform::isWindows()) {
  28585. usleep(350000);
  28586. $deleted = @rmdir($path);
  28587. }
  28588. if (!$deleted) {
  28589. $error = error_get_last();
  28590. $message = 'Could not delete '.$path.': ' . @$error['message'];
  28591. if (Platform::isWindows()) {
  28592. $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed";
  28593. }
  28594. throw new \RuntimeException($message);
  28595. }
  28596. }
  28597. return true;
  28598. }
  28599. public function copyThenRemove($source, $target)
  28600. {
  28601. $this->copy($source, $target);
  28602. if (!is_dir($source)) {
  28603. $this->unlink($source);
  28604. return;
  28605. }
  28606. $this->removeDirectoryPhp($source);
  28607. }
  28608. public function copy($source, $target)
  28609. {
  28610. if (!is_dir($source)) {
  28611. return copy($source, $target);
  28612. }
  28613. $it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
  28614. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);
  28615. $this->ensureDirectoryExists($target);
  28616. $result = true;
  28617. foreach ($ri as $file) {
  28618. $targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathname();
  28619. if ($file->isDir()) {
  28620. $this->ensureDirectoryExists($targetPath);
  28621. } else {
  28622. $result = $result && copy($file->getPathname(), $targetPath);
  28623. }
  28624. }
  28625. return $result;
  28626. }
  28627. public function rename($source, $target)
  28628. {
  28629. if (true === @rename($source, $target)) {
  28630. return;
  28631. }
  28632. if (!\function_exists('proc_open')) {
  28633. $this->copyThenRemove($source, $target);
  28634. return;
  28635. }
  28636. if (Platform::isWindows()) {
  28637. $command = sprintf('xcopy %s %s /E /I /Q /Y', ProcessExecutor::escape($source), ProcessExecutor::escape($target));
  28638. $result = $this->getProcess()->execute($command, $output);
  28639. clearstatcache();
  28640. if (0 === $result) {
  28641. $this->remove($source);
  28642. return;
  28643. }
  28644. } else {
  28645. $command = sprintf('mv %s %s', ProcessExecutor::escape($source), ProcessExecutor::escape($target));
  28646. $result = $this->getProcess()->execute($command, $output);
  28647. clearstatcache();
  28648. if (0 === $result) {
  28649. return;
  28650. }
  28651. }
  28652. $this->copyThenRemove($source, $target);
  28653. }
  28654. public function findShortestPath($from, $to, $directories = false)
  28655. {
  28656. if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
  28657. throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
  28658. }
  28659. $from = lcfirst($this->normalizePath($from));
  28660. $to = lcfirst($this->normalizePath($to));
  28661. if ($directories) {
  28662. $from = rtrim($from, '/') . '/dummy_file';
  28663. }
  28664. if (\dirname($from) === \dirname($to)) {
  28665. return './'.basename($to);
  28666. }
  28667. $commonPath = $to;
  28668. while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath)) {
  28669. $commonPath = strtr(\dirname($commonPath), '\\', '/');
  28670. }
  28671. if (0 !== strpos($from, $commonPath) || '/' === $commonPath) {
  28672. return $to;
  28673. }
  28674. $commonPath = rtrim($commonPath, '/') . '/';
  28675. $sourcePathDepth = substr_count(substr($from, \strlen($commonPath)), '/');
  28676. $commonPathCode = str_repeat('../', $sourcePathDepth);
  28677. return ($commonPathCode . substr($to, \strlen($commonPath))) ?: './';
  28678. }
  28679. public function findShortestPathCode($from, $to, $directories = false, $staticCode = false)
  28680. {
  28681. if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
  28682. throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
  28683. }
  28684. $from = lcfirst($this->normalizePath($from));
  28685. $to = lcfirst($this->normalizePath($to));
  28686. if ($from === $to) {
  28687. return $directories ? '__DIR__' : '__FILE__';
  28688. }
  28689. $commonPath = $to;
  28690. while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath) && '.' !== $commonPath) {
  28691. $commonPath = strtr(\dirname($commonPath), '\\', '/');
  28692. }
  28693. if (0 !== strpos($from, $commonPath) || '/' === $commonPath || '.' === $commonPath) {
  28694. return var_export($to, true);
  28695. }
  28696. $commonPath = rtrim($commonPath, '/') . '/';
  28697. if (strpos($to, $from.'/') === 0) {
  28698. return '__DIR__ . '.var_export(substr($to, \strlen($from)), true);
  28699. }
  28700. $sourcePathDepth = substr_count(substr($from, \strlen($commonPath)), '/') + $directories;
  28701. if ($staticCode) {
  28702. $commonPathCode = "__DIR__ . '".str_repeat('/..', $sourcePathDepth)."'";
  28703. } else {
  28704. $commonPathCode = str_repeat('dirname(', $sourcePathDepth).'__DIR__'.str_repeat(')', $sourcePathDepth);
  28705. }
  28706. $relTarget = substr($to, \strlen($commonPath));
  28707. return $commonPathCode . (\strlen($relTarget) ? '.' . var_export('/' . $relTarget, true) : '');
  28708. }
  28709. public function isAbsolutePath($path)
  28710. {
  28711. return strpos($path, '/') === 0 || substr($path, 1, 1) === ':' || strpos($path, '\\\\') === 0;
  28712. }
  28713. public function size($path)
  28714. {
  28715. if (!file_exists($path)) {
  28716. throw new \RuntimeException("$path does not exist.");
  28717. }
  28718. if (is_dir($path)) {
  28719. return $this->directorySize($path);
  28720. }
  28721. return filesize($path);
  28722. }
  28723. public function normalizePath($path)
  28724. {
  28725. $parts = array();
  28726. $path = strtr($path, '\\', '/');
  28727. $prefix = '';
  28728. $absolute = false;
  28729. if (preg_match('{^( [0-9a-z]{2,}+: (?: // (?: [a-z]: )? )? | [a-z]: )}ix', $path, $match)) {
  28730. $prefix = $match[1];
  28731. $path = substr($path, \strlen($prefix));
  28732. }
  28733. if (strpos($path, '/') === 0) {
  28734. $absolute = true;
  28735. $path = substr($path, 1);
  28736. }
  28737. $up = false;
  28738. foreach (explode('/', $path) as $chunk) {
  28739. if ('..' === $chunk && ($absolute || $up)) {
  28740. array_pop($parts);
  28741. $up = !(empty($parts) || '..' === end($parts));
  28742. } elseif ('.' !== $chunk && '' !== $chunk) {
  28743. $parts[] = $chunk;
  28744. $up = '..' !== $chunk;
  28745. }
  28746. }
  28747. return $prefix.($absolute ? '/' : '').implode('/', $parts);
  28748. }
  28749. public static function isLocalPath($path)
  28750. {
  28751. return (bool) preg_match('{^(file://(?!//)|/(?!/)|/?[a-z]:[\\\\/]|\.\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i', $path);
  28752. }
  28753. public static function getPlatformPath($path)
  28754. {
  28755. if (Platform::isWindows()) {
  28756. $path = preg_replace('{^(?:file:///([a-z]):?/)}i', 'file://$1:/', $path);
  28757. }
  28758. return preg_replace('{^file://}i', '', $path);
  28759. }
  28760. protected function directorySize($directory)
  28761. {
  28762. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  28763. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
  28764. $size = 0;
  28765. foreach ($ri as $file) {
  28766. if ($file->isFile()) {
  28767. $size += $file->getSize();
  28768. }
  28769. }
  28770. return $size;
  28771. }
  28772. protected function getProcess()
  28773. {
  28774. if (!$this->processExecutor) {
  28775. $this->processExecutor = new ProcessExecutor();
  28776. }
  28777. return $this->processExecutor;
  28778. }
  28779. private function unlinkImplementation($path)
  28780. {
  28781. if (Platform::isWindows() && is_dir($path) && is_link($path)) {
  28782. return rmdir($path);
  28783. }
  28784. return unlink($path);
  28785. }
  28786. public function relativeSymlink($target, $link)
  28787. {
  28788. $cwd = getcwd();
  28789. $relativePath = $this->findShortestPath($link, $target);
  28790. chdir(\dirname($link));
  28791. $result = @symlink($relativePath, $link);
  28792. chdir($cwd);
  28793. return $result;
  28794. }
  28795. public function isSymlinkedDirectory($directory)
  28796. {
  28797. if (!is_dir($directory)) {
  28798. return false;
  28799. }
  28800. $resolved = $this->resolveSymlinkedDirectorySymlink($directory);
  28801. return is_link($resolved);
  28802. }
  28803. private function unlinkSymlinkedDirectory($directory)
  28804. {
  28805. $resolved = $this->resolveSymlinkedDirectorySymlink($directory);
  28806. return $this->unlink($resolved);
  28807. }
  28808. private function resolveSymlinkedDirectorySymlink($pathname)
  28809. {
  28810. if (!is_dir($pathname)) {
  28811. return $pathname;
  28812. }
  28813. $resolved = rtrim($pathname, '/');
  28814. if (!\strlen($resolved)) {
  28815. return $pathname;
  28816. }
  28817. return $resolved;
  28818. }
  28819. public function junction($target, $junction)
  28820. {
  28821. if (!Platform::isWindows()) {
  28822. throw new \LogicException(sprintf('Function %s is not available on non-Windows platform', __CLASS__));
  28823. }
  28824. if (!is_dir($target)) {
  28825. throw new IOException(sprintf('Cannot junction to "%s" as it is not a directory.', $target), 0, null, $target);
  28826. }
  28827. $cmd = sprintf(
  28828. 'mklink /J %s %s',
  28829. ProcessExecutor::escape(str_replace('/', DIRECTORY_SEPARATOR, $junction)),
  28830. ProcessExecutor::escape(realpath($target))
  28831. );
  28832. if ($this->getProcess()->execute($cmd, $output) !== 0) {
  28833. throw new IOException(sprintf('Failed to create junction to "%s" at "%s".', $target, $junction), 0, null, $target);
  28834. }
  28835. clearstatcache(true, $junction);
  28836. }
  28837. public function isJunction($junction)
  28838. {
  28839. if (!Platform::isWindows()) {
  28840. return false;
  28841. }
  28842. clearstatcache(true, $junction);
  28843. if (!is_dir($junction) || is_link($junction)) {
  28844. return false;
  28845. }
  28846. $stat = lstat($junction);
  28847. return $stat ? 0x4000 !== ($stat['mode'] & 0xF000) : false;
  28848. }
  28849. public function removeJunction($junction)
  28850. {
  28851. if (!Platform::isWindows()) {
  28852. return false;
  28853. }
  28854. $junction = rtrim(str_replace('/', DIRECTORY_SEPARATOR, $junction), DIRECTORY_SEPARATOR);
  28855. if (!$this->isJunction($junction)) {
  28856. throw new IOException(sprintf('%s is not a junction and thus cannot be removed as one', $junction));
  28857. }
  28858. return $this->rmdir($junction);
  28859. }
  28860. public function filePutContentsIfModified($path, $content)
  28861. {
  28862. $currentContent = @file_get_contents($path);
  28863. if (!$currentContent || ($currentContent != $content)) {
  28864. return file_put_contents($path, $content);
  28865. }
  28866. return 0;
  28867. }
  28868. public function safeCopy($source, $target)
  28869. {
  28870. if (!file_exists($target) || !file_exists($source) || !$this->filesAreEqual($source, $target)) {
  28871. $source = fopen($source, 'r');
  28872. $target = fopen($target, 'w+');
  28873. stream_copy_to_stream($source, $target);
  28874. fclose($source);
  28875. fclose($target);
  28876. }
  28877. }
  28878. private function filesAreEqual($a, $b)
  28879. {
  28880. if (filesize($a) !== filesize($b)) {
  28881. return false;
  28882. }
  28883. $ah = fopen($a, 'rb');
  28884. $bh = fopen($b, 'rb');
  28885. $result = true;
  28886. while (!feof($ah)) {
  28887. if (fread($ah, 8192) != fread($bh, 8192)) {
  28888. $result = false;
  28889. break;
  28890. }
  28891. }
  28892. fclose($ah);
  28893. fclose($bh);
  28894. return $result;
  28895. }
  28896. }
  28897. <?php
  28898. namespace Composer\Util;
  28899. use Composer\Config;
  28900. use Composer\IO\IOInterface;
  28901. class Git
  28902. {
  28903. private static $version = false;
  28904. protected $io;
  28905. protected $config;
  28906. protected $process;
  28907. protected $filesystem;
  28908. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process, Filesystem $fs)
  28909. {
  28910. $this->io = $io;
  28911. $this->config = $config;
  28912. $this->process = $process;
  28913. $this->filesystem = $fs;
  28914. }
  28915. public function runCommand($commandCallable, $url, $cwd, $initialClone = false)
  28916. {
  28917. $this->config->prohibitUrlByConfig($url, $this->io);
  28918. if ($initialClone) {
  28919. $origCwd = $cwd;
  28920. $cwd = null;
  28921. }
  28922. if (preg_match('{^ssh://[^@]+@[^:]+:[^0-9]+}', $url)) {
  28923. 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.');
  28924. }
  28925. if (!$initialClone) {
  28926. $this->process->execute('git remote -v', $output, $cwd);
  28927. if (preg_match('{^(?:composer|origin)\s+https?://(.+):(.+)@([^/]+)}im', $output, $match) && !$this->io->hasAuthentication($match[3])) {
  28928. $this->io->setAuthentication($match[3], rawurldecode($match[1]), rawurldecode($match[2]));
  28929. }
  28930. }
  28931. $protocols = $this->config->get('github-protocols');
  28932. if (!is_array($protocols)) {
  28933. throw new \RuntimeException('Config value "github-protocols" must be an array, got ' . gettype($protocols));
  28934. }
  28935. if (preg_match('{^(?:https?|git)://' . self::getGitHubDomainsRegex($this->config) . '/(.*)}', $url, $match)) {
  28936. $messages = array();
  28937. foreach ($protocols as $protocol) {
  28938. if ('ssh' === $protocol) {
  28939. $protoUrl = "git@" . $match[1] . ":" . $match[2];
  28940. } else {
  28941. $protoUrl = $protocol . "://" . $match[1] . "/" . $match[2];
  28942. }
  28943. if (0 === $this->process->execute(call_user_func($commandCallable, $protoUrl), $ignoredOutput, $cwd)) {
  28944. return;
  28945. }
  28946. $messages[] = '- ' . $protoUrl . "\n" . preg_replace('#^#m', ' ', $this->process->getErrorOutput());
  28947. if ($initialClone && isset($origCwd)) {
  28948. $this->filesystem->removeDirectory($origCwd);
  28949. }
  28950. }
  28951. if (!$this->io->hasAuthentication($match[1]) && !$this->io->isInteractive()) {
  28952. $this->throwException('Failed to clone ' . $url . ' via ' . implode(', ', $protocols) . ' protocols, aborting.' . "\n\n" . implode("\n", $messages), $url);
  28953. }
  28954. }
  28955. $bypassSshForGitHub = preg_match('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\.git$}i', $url) && !in_array('ssh', $protocols, true);
  28956. $command = call_user_func($commandCallable, $url);
  28957. $auth = null;
  28958. if ($bypassSshForGitHub || 0 !== $this->process->execute($command, $ignoredOutput, $cwd)) {
  28959. $errorMsg = $this->process->getErrorOutput();
  28960. if (preg_match('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\.git$}i', $url, $match)
  28961. || preg_match('{^https?://' . self::getGitHubDomainsRegex($this->config) . '/(.*)}', $url, $match)
  28962. ) {
  28963. if (!$this->io->hasAuthentication($match[1])) {
  28964. $gitHubUtil = new GitHub($this->io, $this->config, $this->process);
  28965. $message = 'Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos';
  28966. if (!$gitHubUtil->authorizeOAuth($match[1]) && $this->io->isInteractive()) {
  28967. $gitHubUtil->authorizeOAuthInteractively($match[1], $message);
  28968. }
  28969. }
  28970. if ($this->io->hasAuthentication($match[1])) {
  28971. $auth = $this->io->getAuthentication($match[1]);
  28972. $authUrl = 'https://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[1] . '/' . $match[2] . '.git';
  28973. $command = call_user_func($commandCallable, $authUrl);
  28974. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  28975. return;
  28976. }
  28977. $errorMsg = $this->process->getErrorOutput();
  28978. }
  28979. } elseif (preg_match('{^https://(bitbucket\.org)/(.*)(\.git)?$}U', $url, $match)) {
  28980. $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process);
  28981. if (!$this->io->hasAuthentication($match[1])) {
  28982. $message = 'Enter your Bitbucket credentials to access private repos';
  28983. if (!$bitbucketUtil->authorizeOAuth($match[1]) && $this->io->isInteractive()) {
  28984. $bitbucketUtil->authorizeOAuthInteractively($match[1], $message);
  28985. $accessToken = $bitbucketUtil->getToken();
  28986. $this->io->setAuthentication($match[1], 'x-token-auth', $accessToken);
  28987. }
  28988. } else {
  28989. $auth = $this->io->getAuthentication($match[1]);
  28990. if ($auth['username'] !== 'x-token-auth') {
  28991. $accessToken = $bitbucketUtil->requestToken($match[1], $auth['username'], $auth['password']);
  28992. if (! empty($accessToken)) {
  28993. $this->io->setAuthentication($match[1], 'x-token-auth', $accessToken);
  28994. }
  28995. }
  28996. }
  28997. if ($this->io->hasAuthentication($match[1])) {
  28998. $auth = $this->io->getAuthentication($match[1]);
  28999. $authUrl = 'https://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[1] . '/' . $match[2] . '.git';
  29000. $command = call_user_func($commandCallable, $authUrl);
  29001. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29002. return;
  29003. }
  29004. $errorMsg = $this->process->getErrorOutput();
  29005. } else {
  29006. $sshUrl = 'git@bitbucket.org:' . $match[2] . '.git';
  29007. $this->io->writeError(' No bitbucket authentication configured. Falling back to ssh.');
  29008. $command = call_user_func($commandCallable, $sshUrl);
  29009. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29010. return;
  29011. }
  29012. $errorMsg = $this->process->getErrorOutput();
  29013. }
  29014. } elseif (
  29015. preg_match('{^(git)@' . self::getGitLabDomainsRegex($this->config) . ':(.+?\.git)$}i', $url, $match)
  29016. || preg_match('{^(https?)://' . self::getGitLabDomainsRegex($this->config) . '/(.*)}', $url, $match)
  29017. ) {
  29018. if ($match[1] === 'git') {
  29019. $match[1] = 'https';
  29020. }
  29021. if (!$this->io->hasAuthentication($match[2])) {
  29022. $gitLabUtil = new GitLab($this->io, $this->config, $this->process);
  29023. $message = 'Cloning failed, enter your GitLab credentials to access private repos';
  29024. if (!$gitLabUtil->authorizeOAuth($match[2]) && $this->io->isInteractive()) {
  29025. $gitLabUtil->authorizeOAuthInteractively($match[1], $match[2], $message);
  29026. }
  29027. }
  29028. if ($this->io->hasAuthentication($match[2])) {
  29029. $auth = $this->io->getAuthentication($match[2]);
  29030. if ($auth['password'] === 'private-token' || $auth['password'] === 'oauth2' || $auth['password'] === 'gitlab-ci-token') {
  29031. $authUrl = $match[1] . '://' . rawurlencode($auth['password']) . ':' . rawurlencode($auth['username']) . '@' . $match[2] . '/' . $match[3];
  29032. } else {
  29033. $authUrl = $match[1] . '://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[2] . '/' . $match[3];
  29034. }
  29035. $command = call_user_func($commandCallable, $authUrl);
  29036. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29037. return;
  29038. }
  29039. $errorMsg = $this->process->getErrorOutput();
  29040. }
  29041. } elseif ($this->isAuthenticationFailure($url, $match)) {
  29042. if (strpos($match[2], '@')) {
  29043. list($authParts, $match[2]) = explode('@', $match[2], 2);
  29044. }
  29045. $storeAuth = false;
  29046. if ($this->io->hasAuthentication($match[2])) {
  29047. $auth = $this->io->getAuthentication($match[2]);
  29048. } elseif ($this->io->isInteractive()) {
  29049. $defaultUsername = null;
  29050. if (isset($authParts) && $authParts) {
  29051. if (false !== strpos($authParts, ':')) {
  29052. list($defaultUsername, ) = explode(':', $authParts, 2);
  29053. } else {
  29054. $defaultUsername = $authParts;
  29055. }
  29056. }
  29057. $this->io->writeError(' Authentication required (<info>' . $match[2] . '</info>):');
  29058. $auth = array(
  29059. 'username' => $this->io->ask(' Username: ', $defaultUsername),
  29060. 'password' => $this->io->askAndHideAnswer(' Password: '),
  29061. );
  29062. $storeAuth = $this->config->get('store-auths');
  29063. }
  29064. if ($auth) {
  29065. $authUrl = $match[1] . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[2] . $match[3];
  29066. $command = call_user_func($commandCallable, $authUrl);
  29067. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29068. $this->io->setAuthentication($match[2], $auth['username'], $auth['password']);
  29069. $authHelper = new AuthHelper($this->io, $this->config);
  29070. $authHelper->storeAuth($match[2], $storeAuth);
  29071. return;
  29072. }
  29073. $errorMsg = $this->process->getErrorOutput();
  29074. }
  29075. }
  29076. if ($initialClone && isset($origCwd)) {
  29077. $this->filesystem->removeDirectory($origCwd);
  29078. }
  29079. $this->throwException('Failed to execute ' . $command . "\n\n" . $errorMsg, $url);
  29080. }
  29081. }
  29082. public function syncMirror($url, $dir)
  29083. {
  29084. if (getenv('COMPOSER_DISABLE_NETWORK') && getenv('COMPOSER_DISABLE_NETWORK') !== 'prime') {
  29085. $this->io->writeError('<warning>Aborting git mirror sync of '.$url.' as network is disabled</warning>');
  29086. return false;
  29087. }
  29088. if (is_dir($dir) && 0 === $this->process->execute('git rev-parse --git-dir', $output, $dir) && trim($output) === '.') {
  29089. try {
  29090. $commandCallable = function ($url) {
  29091. $sanitizedUrl = preg_replace('{://([^@]+?):(.+?)@}', '://', $url);
  29092. return sprintf('git remote set-url origin %s && git remote update --prune origin && git remote set-url origin %s', ProcessExecutor::escape($url), ProcessExecutor::escape($sanitizedUrl));
  29093. };
  29094. $this->runCommand($commandCallable, $url, $dir);
  29095. } catch (\Exception $e) {
  29096. $this->io->writeError('<error>Sync mirror failed: ' . $e->getMessage() . '</error>', true, IOInterface::DEBUG);
  29097. return false;
  29098. }
  29099. return true;
  29100. }
  29101. $this->filesystem->removeDirectory($dir);
  29102. $commandCallable = function ($url) use ($dir) {
  29103. return sprintf('git clone --mirror %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($dir));
  29104. };
  29105. $this->runCommand($commandCallable, $url, $dir, true);
  29106. return true;
  29107. }
  29108. public function fetchRefOrSyncMirror($url, $dir, $ref)
  29109. {
  29110. if ($this->checkRefIsInMirror($dir, $ref)) {
  29111. return true;
  29112. }
  29113. if ($this->syncMirror($url, $dir)) {
  29114. return $this->checkRefIsInMirror($dir, $ref);
  29115. }
  29116. return false;
  29117. }
  29118. public static function getNoShowSignatureFlag(ProcessExecutor $process)
  29119. {
  29120. $gitVersion = self::getVersion($process);
  29121. if ($gitVersion && version_compare($gitVersion, '2.10.0-rc0', '>=')) {
  29122. return ' --no-show-signature';
  29123. }
  29124. return '';
  29125. }
  29126. private function checkRefIsInMirror($dir, $ref)
  29127. {
  29128. if (is_dir($dir) && 0 === $this->process->execute('git rev-parse --git-dir', $output, $dir) && trim($output) === '.') {
  29129. $escapedRef = ProcessExecutor::escape($ref.'^{commit}');
  29130. $exitCode = $this->process->execute(sprintf('git rev-parse --quiet --verify %s', $escapedRef), $ignoredOutput, $dir);
  29131. if ($exitCode === 0) {
  29132. return true;
  29133. }
  29134. }
  29135. return false;
  29136. }
  29137. private function isAuthenticationFailure($url, &$match)
  29138. {
  29139. if (!preg_match('{^(https?://)([^/]+)(.*)$}i', $url, $match)) {
  29140. return false;
  29141. }
  29142. $authFailures = array(
  29143. 'fatal: Authentication failed',
  29144. 'remote error: Invalid username or password.',
  29145. 'error: 401 Unauthorized',
  29146. 'fatal: unable to access',
  29147. 'fatal: could not read Username',
  29148. );
  29149. $errorOutput = $this->process->getErrorOutput();
  29150. foreach ($authFailures as $authFailure) {
  29151. if (strpos($errorOutput, $authFailure) !== false) {
  29152. return true;
  29153. }
  29154. }
  29155. return false;
  29156. }
  29157. public static function cleanEnv()
  29158. {
  29159. if (PHP_VERSION_ID < 50400 && ini_get('safe_mode') && false === strpos(ini_get('safe_mode_allowed_env_vars'), 'GIT_ASKPASS')) {
  29160. 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');
  29161. }
  29162. if (getenv('GIT_ASKPASS') !== 'echo') {
  29163. putenv('GIT_ASKPASS=echo');
  29164. unset($_SERVER['GIT_ASKPASS']);
  29165. }
  29166. if (getenv('GIT_DIR')) {
  29167. putenv('GIT_DIR');
  29168. unset($_SERVER['GIT_DIR']);
  29169. }
  29170. if (getenv('GIT_WORK_TREE')) {
  29171. putenv('GIT_WORK_TREE');
  29172. unset($_SERVER['GIT_WORK_TREE']);
  29173. }
  29174. if (getenv('LANGUAGE') !== 'C') {
  29175. putenv('LANGUAGE=C');
  29176. }
  29177. putenv("DYLD_LIBRARY_PATH");
  29178. unset($_SERVER['DYLD_LIBRARY_PATH']);
  29179. }
  29180. public static function getGitHubDomainsRegex(Config $config)
  29181. {
  29182. return '(' . implode('|', array_map('preg_quote', $config->get('github-domains'))) . ')';
  29183. }
  29184. public static function getGitLabDomainsRegex(Config $config)
  29185. {
  29186. return '(' . implode('|', array_map('preg_quote', $config->get('gitlab-domains'))) . ')';
  29187. }
  29188. private function throwException($message, $url)
  29189. {
  29190. clearstatcache();
  29191. if (0 !== $this->process->execute('git --version', $ignoredOutput)) {
  29192. 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()));
  29193. }
  29194. throw new \RuntimeException(Url::sanitize($message));
  29195. }
  29196. public static function getVersion(ProcessExecutor $process)
  29197. {
  29198. if (false === self::$version) {
  29199. self::$version = null;
  29200. if (!$process) {
  29201. $process = new ProcessExecutor;
  29202. }
  29203. if (0 === $process->execute('git --version', $output) && preg_match('/^git version (\d+(?:\.\d+)+)/m', $output, $matches)) {
  29204. self::$version = $matches[1];
  29205. }
  29206. }
  29207. return self::$version;
  29208. }
  29209. }
  29210. <?php
  29211. namespace Composer\Util;
  29212. use Composer\Factory;
  29213. use Composer\IO\IOInterface;
  29214. use Composer\Config;
  29215. use Composer\Downloader\TransportException;
  29216. class GitHub
  29217. {
  29218. protected $io;
  29219. protected $config;
  29220. protected $process;
  29221. protected $httpDownloader;
  29222. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null)
  29223. {
  29224. $this->io = $io;
  29225. $this->config = $config;
  29226. $this->process = $process ?: new ProcessExecutor($io);
  29227. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  29228. }
  29229. public function authorizeOAuth($originUrl)
  29230. {
  29231. if (!in_array($originUrl, $this->config->get('github-domains'))) {
  29232. return false;
  29233. }
  29234. if (0 === $this->process->execute('git config github.accesstoken', $output)) {
  29235. $this->io->setAuthentication($originUrl, trim($output), 'x-oauth-basic');
  29236. return true;
  29237. }
  29238. return false;
  29239. }
  29240. public function authorizeOAuthInteractively($originUrl, $message = null)
  29241. {
  29242. if ($message) {
  29243. $this->io->writeError($message);
  29244. }
  29245. $note = 'Composer';
  29246. if ($this->config->get('github-expose-hostname') === true && 0 === $this->process->execute('hostname', $output)) {
  29247. $note .= ' on ' . trim($output);
  29248. }
  29249. $note .= ' ' . date('Y-m-d Hi');
  29250. $url = 'https://'.$originUrl.'/settings/tokens/new?scopes=repo&description=' . str_replace('%20', '+', rawurlencode($note));
  29251. $this->io->writeError(sprintf('Head to %s', $url));
  29252. $this->io->writeError(sprintf('to retrieve a token. It will be stored in "%s" for future use by Composer.', $this->config->getAuthConfigSource()->getName()));
  29253. $token = trim($this->io->askAndHideAnswer('Token (hidden): '));
  29254. if (!$token) {
  29255. $this->io->writeError('<warning>No token given, aborting.</warning>');
  29256. $this->io->writeError('You can also add it manually later by using "composer config --global --auth github-oauth.github.com <token>"');
  29257. return false;
  29258. }
  29259. $this->io->setAuthentication($originUrl, $token, 'x-oauth-basic');
  29260. try {
  29261. $apiUrl = ('github.com' === $originUrl) ? 'api.github.com/' : $originUrl . '/api/v3/';
  29262. $this->httpDownloader->get('https://'. $apiUrl, array(
  29263. 'retry-auth-failure' => false,
  29264. ));
  29265. } catch (TransportException $e) {
  29266. if (in_array($e->getCode(), array(403, 401))) {
  29267. $this->io->writeError('<error>Invalid token provided.</error>');
  29268. $this->io->writeError('You can also add it manually later by using "composer config --global --auth github-oauth.github.com <token>"');
  29269. return false;
  29270. }
  29271. throw $e;
  29272. }
  29273. $this->config->getConfigSource()->removeConfigSetting('github-oauth.'.$originUrl);
  29274. $this->config->getAuthConfigSource()->addConfigSetting('github-oauth.'.$originUrl, $token);
  29275. $this->io->writeError('<info>Token stored successfully.</info>');
  29276. return true;
  29277. }
  29278. public function getRateLimit(array $headers)
  29279. {
  29280. $rateLimit = array(
  29281. 'limit' => '?',
  29282. 'reset' => '?',
  29283. );
  29284. foreach ($headers as $header) {
  29285. $header = trim($header);
  29286. if (false === strpos($header, 'X-RateLimit-')) {
  29287. continue;
  29288. }
  29289. list($type, $value) = explode(':', $header, 2);
  29290. switch ($type) {
  29291. case 'X-RateLimit-Limit':
  29292. $rateLimit['limit'] = (int) trim($value);
  29293. break;
  29294. case 'X-RateLimit-Reset':
  29295. $rateLimit['reset'] = date('Y-m-d H:i:s', (int) trim($value));
  29296. break;
  29297. }
  29298. }
  29299. return $rateLimit;
  29300. }
  29301. public function isRateLimited(array $headers)
  29302. {
  29303. foreach ($headers as $header) {
  29304. if (preg_match('{^X-RateLimit-Remaining: *0$}i', trim($header))) {
  29305. return true;
  29306. }
  29307. }
  29308. return false;
  29309. }
  29310. }
  29311. <?php
  29312. namespace Composer\Util;
  29313. use Composer\IO\IOInterface;
  29314. use Composer\Config;
  29315. use Composer\Factory;
  29316. use Composer\Downloader\TransportException;
  29317. use Composer\Json\JsonFile;
  29318. class GitLab
  29319. {
  29320. protected $io;
  29321. protected $config;
  29322. protected $process;
  29323. protected $httpDownloader;
  29324. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null)
  29325. {
  29326. $this->io = $io;
  29327. $this->config = $config;
  29328. $this->process = $process ?: new ProcessExecutor($io);
  29329. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  29330. }
  29331. public function authorizeOAuth($originUrl)
  29332. {
  29333. $bcOriginUrl = preg_replace('{:\d+}', '', $originUrl);
  29334. if (!in_array($originUrl, $this->config->get('gitlab-domains'), true) && !in_array($bcOriginUrl, $this->config->get('gitlab-domains'), true)) {
  29335. return false;
  29336. }
  29337. if (0 === $this->process->execute('git config gitlab.accesstoken', $output)) {
  29338. $this->io->setAuthentication($originUrl, trim($output), 'oauth2');
  29339. return true;
  29340. }
  29341. if (0 === $this->process->execute('git config gitlab.deploytoken.user', $tokenUser) && 0 === $this->process->execute('git config gitlab.deploytoken.token', $tokenPassword)) {
  29342. $this->io->setAuthentication($originUrl, trim($tokenUser), trim($tokenPassword));
  29343. return true;
  29344. }
  29345. $authTokens = $this->config->get('gitlab-token');
  29346. if (isset($authTokens[$originUrl])) {
  29347. $token = $authTokens[$originUrl];
  29348. }
  29349. if (isset($authTokens[$bcOriginUrl])) {
  29350. $token = $authTokens[$bcOriginUrl];
  29351. }
  29352. if(isset($token)){
  29353. $username = is_array($token) && array_key_exists("username", $token) ? $token["username"] : $token;
  29354. $password = is_array($token) && array_key_exists("token", $token) ? $token["token"] : 'private-token';
  29355. $this->io->setAuthentication($originUrl, $username, $password);
  29356. return true;
  29357. }
  29358. return false;
  29359. }
  29360. public function authorizeOAuthInteractively($scheme, $originUrl, $message = null)
  29361. {
  29362. if ($message) {
  29363. $this->io->writeError($message);
  29364. }
  29365. $this->io->writeError(sprintf('A token will be created and stored in "%s", your password will never be stored', $this->config->getAuthConfigSource()->getName()));
  29366. $this->io->writeError('To revoke access to this token you can visit '.$scheme.'://'.$originUrl.'/profile/applications');
  29367. $attemptCounter = 0;
  29368. while ($attemptCounter++ < 5) {
  29369. try {
  29370. $response = $this->createToken($scheme, $originUrl);
  29371. } catch (TransportException $e) {
  29372. if (in_array($e->getCode(), array(403, 401))) {
  29373. if (401 === $e->getCode()) {
  29374. $response = json_decode($e->getResponse(), true);
  29375. if (isset($response['error']) && $response['error'] === 'invalid_grant') {
  29376. $this->io->writeError('Bad credentials. If you have two factor authentication enabled you will have to manually create a personal access token');
  29377. } else {
  29378. $this->io->writeError('Bad credentials.');
  29379. }
  29380. } else {
  29381. $this->io->writeError('Maximum number of login attempts exceeded. Please try again later.');
  29382. }
  29383. $this->io->writeError('You can also manually create a personal access token enabling the "read_api" scope at '.$scheme.'://'.$originUrl.'/profile/personal_access_tokens');
  29384. $this->io->writeError('Add it using "composer config --global --auth gitlab-token.'.$originUrl.' <token>"');
  29385. continue;
  29386. }
  29387. throw $e;
  29388. }
  29389. $this->io->setAuthentication($originUrl, $response['access_token'], 'oauth2');
  29390. $this->config->getAuthConfigSource()->addConfigSetting('gitlab-oauth.'.$originUrl, $response['access_token']);
  29391. return true;
  29392. }
  29393. throw new \RuntimeException('Invalid GitLab credentials 5 times in a row, aborting.');
  29394. }
  29395. private function createToken($scheme, $originUrl)
  29396. {
  29397. $username = $this->io->ask('Username: ');
  29398. $password = $this->io->askAndHideAnswer('Password: ');
  29399. $headers = array('Content-Type: application/x-www-form-urlencoded');
  29400. $apiUrl = $originUrl;
  29401. $data = http_build_query(array(
  29402. 'username' => $username,
  29403. 'password' => $password,
  29404. 'grant_type' => 'password',
  29405. ), null, '&');
  29406. $options = array(
  29407. 'retry-auth-failure' => false,
  29408. 'http' => array(
  29409. 'method' => 'POST',
  29410. 'header' => $headers,
  29411. 'content' => $data,
  29412. ),
  29413. );
  29414. $token = $this->httpDownloader->get($scheme.'://'.$apiUrl.'/oauth/token', $options)->decodeJson();
  29415. $this->io->writeError('Token successfully created');
  29416. return $token;
  29417. }
  29418. }
  29419. <?php
  29420. namespace Composer\Util;
  29421. use Composer\Config;
  29422. use Composer\IO\IOInterface;
  29423. class Hg
  29424. {
  29425. private $io;
  29426. private $config;
  29427. private $process;
  29428. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process)
  29429. {
  29430. $this->io = $io;
  29431. $this->config = $config;
  29432. $this->process = $process;
  29433. }
  29434. public function runCommand($commandCallable, $url, $cwd)
  29435. {
  29436. $this->config->prohibitUrlByConfig($url, $this->io);
  29437. $command = call_user_func($commandCallable, $url);
  29438. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29439. return;
  29440. }
  29441. if (preg_match('{^(https?)://((.+)(?:\:(.+))?@)?([^/]+)(/.*)?}mi', $url, $match) && $this->io->hasAuthentication($match[5])) {
  29442. $auth = $this->io->getAuthentication($match[5]);
  29443. $authenticatedUrl = $match[1] . '://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[5] . (!empty($match[6]) ? $match[6] : null);
  29444. $command = call_user_func($commandCallable, $authenticatedUrl);
  29445. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29446. return;
  29447. }
  29448. $error = $this->process->getErrorOutput();
  29449. } else {
  29450. $error = 'The given URL (' . $url . ') does not match the required format (http(s)://(username:password@)example.com/path-to-repository)';
  29451. }
  29452. $this->throwException('Failed to clone ' . $url . ', ' . "\n\n" . $error, $url);
  29453. }
  29454. private function throwException($message, $url)
  29455. {
  29456. if (0 !== $this->process->execute('hg --version', $ignoredOutput)) {
  29457. 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()));
  29458. }
  29459. throw new \RuntimeException(Url::sanitize($message));
  29460. }
  29461. }
  29462. <?php
  29463. namespace Composer\Util\Http;
  29464. use Composer\Config;
  29465. use Composer\Downloader\MaxFileSizeExceededException;
  29466. use Composer\IO\IOInterface;
  29467. use Composer\Downloader\TransportException;
  29468. use Composer\CaBundle\CaBundle;
  29469. use Composer\Util\StreamContextFactory;
  29470. use Composer\Util\AuthHelper;
  29471. use Composer\Util\Url;
  29472. use Composer\Util\HttpDownloader;
  29473. use React\Promise\Promise;
  29474. class CurlDownloader
  29475. {
  29476. private $multiHandle;
  29477. private $shareHandle;
  29478. private $jobs = array();
  29479. private $io;
  29480. private $config;
  29481. private $authHelper;
  29482. private $selectTimeout = 5.0;
  29483. private $maxRedirects = 20;
  29484. protected $multiErrors = array(
  29485. CURLM_BAD_HANDLE => array('CURLM_BAD_HANDLE', 'The passed-in handle is not a valid CURLM handle.'),
  29486. 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."),
  29487. CURLM_OUT_OF_MEMORY => array('CURLM_OUT_OF_MEMORY', 'You are doomed.'),
  29488. CURLM_INTERNAL_ERROR => array('CURLM_INTERNAL_ERROR', 'This can only be returned if libcurl bugs. Please report it to us!')
  29489. );
  29490. private static $options = array(
  29491. 'http' => array(
  29492. 'method' => CURLOPT_CUSTOMREQUEST,
  29493. 'content' => CURLOPT_POSTFIELDS,
  29494. 'header' => CURLOPT_HTTPHEADER,
  29495. ),
  29496. 'ssl' => array(
  29497. 'cafile' => CURLOPT_CAINFO,
  29498. 'capath' => CURLOPT_CAPATH,
  29499. 'verify_peer' => CURLOPT_SSL_VERIFYPEER,
  29500. 'verify_peer_name' => CURLOPT_SSL_VERIFYHOST,
  29501. ),
  29502. );
  29503. private static $timeInfo = array(
  29504. 'total_time' => true,
  29505. 'namelookup_time' => true,
  29506. 'connect_time' => true,
  29507. 'pretransfer_time' => true,
  29508. 'starttransfer_time' => true,
  29509. 'redirect_time' => true,
  29510. );
  29511. public function __construct(IOInterface $io, Config $config, array $options = array(), $disableTls = false)
  29512. {
  29513. $this->io = $io;
  29514. $this->config = $config;
  29515. $this->multiHandle = $mh = curl_multi_init();
  29516. if (function_exists('curl_multi_setopt')) {
  29517. curl_multi_setopt($mh, CURLMOPT_PIPELINING, PHP_VERSION_ID >= 70400 ? 2 : 3);
  29518. if (defined('CURLMOPT_MAX_HOST_CONNECTIONS') && !defined('HHVM_VERSION')) {
  29519. curl_multi_setopt($mh, CURLMOPT_MAX_HOST_CONNECTIONS, 8);
  29520. }
  29521. }
  29522. if (function_exists('curl_share_init')) {
  29523. $this->shareHandle = $sh = curl_share_init();
  29524. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
  29525. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
  29526. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
  29527. }
  29528. $this->authHelper = new AuthHelper($io, $config);
  29529. }
  29530. public function download($resolve, $reject, $origin, $url, $options, $copyTo = null)
  29531. {
  29532. $attributes = array();
  29533. if (isset($options['retry-auth-failure'])) {
  29534. $attributes['retryAuthFailure'] = $options['retry-auth-failure'];
  29535. unset($options['retry-auth-failure']);
  29536. }
  29537. return $this->initDownload($resolve, $reject, $origin, $url, $options, $copyTo, $attributes);
  29538. }
  29539. private function initDownload($resolve, $reject, $origin, $url, $options, $copyTo = null, array $attributes = array())
  29540. {
  29541. $attributes = array_merge(array(
  29542. 'retryAuthFailure' => true,
  29543. 'redirects' => 0,
  29544. 'storeAuth' => false,
  29545. ), $attributes);
  29546. $originalOptions = $options;
  29547. if (!preg_match('{^http://(repo\.)?packagist\.org/p/}', $url) || (false === strpos($url, '$') && false === strpos($url, '%24'))) {
  29548. $this->config->prohibitUrlByConfig($url, $this->io);
  29549. }
  29550. $curlHandle = curl_init();
  29551. $headerHandle = fopen('php://temp/maxmemory:32768', 'w+b');
  29552. if ($copyTo) {
  29553. $errorMessage = '';
  29554. set_error_handler(function ($code, $msg) use (&$errorMessage) {
  29555. if ($errorMessage) {
  29556. $errorMessage .= "\n";
  29557. }
  29558. $errorMessage .= preg_replace('{^fopen\(.*?\): }', '', $msg);
  29559. });
  29560. $bodyHandle = fopen($copyTo.'~', 'w+b');
  29561. restore_error_handler();
  29562. if (!$bodyHandle) {
  29563. throw new TransportException('The "'.$url.'" file could not be written to '.$copyTo.': '.$errorMessage);
  29564. }
  29565. } else {
  29566. $bodyHandle = @fopen('php://temp/maxmemory:524288', 'w+b');
  29567. }
  29568. curl_setopt($curlHandle, CURLOPT_URL, $url);
  29569. curl_setopt($curlHandle, CURLOPT_FOLLOWLOCATION, false);
  29570. curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 10);
  29571. curl_setopt($curlHandle, CURLOPT_TIMEOUT, 300);
  29572. curl_setopt($curlHandle, CURLOPT_WRITEHEADER, $headerHandle);
  29573. curl_setopt($curlHandle, CURLOPT_FILE, $bodyHandle);
  29574. curl_setopt($curlHandle, CURLOPT_ENCODING, "gzip");
  29575. curl_setopt($curlHandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP|CURLPROTO_HTTPS);
  29576. if (defined('CURLOPT_SSL_FALSESTART')) {
  29577. curl_setopt($curlHandle, CURLOPT_SSL_FALSESTART, true);
  29578. }
  29579. if (function_exists('curl_share_init')) {
  29580. curl_setopt($curlHandle, CURLOPT_SHARE, $this->shareHandle);
  29581. }
  29582. if (!isset($options['http']['header'])) {
  29583. $options['http']['header'] = array();
  29584. }
  29585. $options['http']['header'] = array_diff($options['http']['header'], array('Connection: close'));
  29586. $options['http']['header'][] = 'Connection: keep-alive';
  29587. $version = curl_version();
  29588. $features = $version['features'];
  29589. if (0 === strpos($url, 'https://') && \defined('CURL_VERSION_HTTP2') && \defined('CURL_HTTP_VERSION_2_0') && (CURL_VERSION_HTTP2 & $features)) {
  29590. curl_setopt($curlHandle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
  29591. }
  29592. $options['http']['header'] = $this->authHelper->addAuthenticationHeader($options['http']['header'], $origin, $url);
  29593. $options = StreamContextFactory::initOptions($url, $options);
  29594. foreach (self::$options as $type => $curlOptions) {
  29595. foreach ($curlOptions as $name => $curlOption) {
  29596. if (isset($options[$type][$name])) {
  29597. if ($type === 'ssl' && $name === 'verify_peer_name') {
  29598. curl_setopt($curlHandle, $curlOption, $options[$type][$name] === true ? 2 : $options[$type][$name]);
  29599. } else {
  29600. curl_setopt($curlHandle, $curlOption, $options[$type][$name]);
  29601. }
  29602. }
  29603. }
  29604. }
  29605. $progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo);
  29606. $this->jobs[(int) $curlHandle] = array(
  29607. 'url' => $url,
  29608. 'origin' => $origin,
  29609. 'attributes' => $attributes,
  29610. 'options' => $originalOptions,
  29611. 'progress' => $progress,
  29612. 'curlHandle' => $curlHandle,
  29613. 'filename' => $copyTo,
  29614. 'headerHandle' => $headerHandle,
  29615. 'bodyHandle' => $bodyHandle,
  29616. 'resolve' => $resolve,
  29617. 'reject' => $reject,
  29618. );
  29619. $usingProxy = !empty($options['http']['proxy']) ? ' using proxy ' . $options['http']['proxy'] : '';
  29620. $ifModified = false !== stripos(implode(',', $options['http']['header']), 'if-modified-since:') ? ' if modified' : '';
  29621. if ($attributes['redirects'] === 0) {
  29622. $this->io->writeError('Downloading ' . Url::sanitize($url) . $usingProxy . $ifModified, true, IOInterface::DEBUG);
  29623. }
  29624. $this->checkCurlResult(curl_multi_add_handle($this->multiHandle, $curlHandle));
  29625. return (int) $curlHandle;
  29626. }
  29627. public function abortRequest($id)
  29628. {
  29629. if (isset($this->jobs[$id], $this->jobs[$id]['handle'])) {
  29630. $job = $this->jobs[$id];
  29631. curl_multi_remove_handle($this->multiHandle, $job['handle']);
  29632. curl_close($job['handle']);
  29633. if (is_resource($job['headerHandle'])) {
  29634. fclose($job['headerHandle']);
  29635. }
  29636. if (is_resource($job['bodyHandle'])) {
  29637. fclose($job['bodyHandle']);
  29638. }
  29639. if ($job['filename']) {
  29640. @unlink($job['filename'].'~');
  29641. }
  29642. unset($this->jobs[$id]);
  29643. }
  29644. }
  29645. public function tick()
  29646. {
  29647. if (!$this->jobs) {
  29648. return;
  29649. }
  29650. $active = true;
  29651. $this->checkCurlResult(curl_multi_exec($this->multiHandle, $active));
  29652. if (-1 === curl_multi_select($this->multiHandle, $this->selectTimeout)) {
  29653. usleep(150);
  29654. }
  29655. while ($progress = curl_multi_info_read($this->multiHandle)) {
  29656. $curlHandle = $progress['handle'];
  29657. $i = (int) $curlHandle;
  29658. if (!isset($this->jobs[$i])) {
  29659. continue;
  29660. }
  29661. $progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo);
  29662. $job = $this->jobs[$i];
  29663. unset($this->jobs[$i]);
  29664. curl_multi_remove_handle($this->multiHandle, $curlHandle);
  29665. $error = curl_error($curlHandle);
  29666. $errno = curl_errno($curlHandle);
  29667. curl_close($curlHandle);
  29668. $headers = null;
  29669. $statusCode = null;
  29670. $response = null;
  29671. try {
  29672. if (CURLE_OK !== $errno || $error) {
  29673. throw new TransportException($error);
  29674. }
  29675. $statusCode = $progress['http_code'];
  29676. rewind($job['headerHandle']);
  29677. $headers = explode("\r\n", rtrim(stream_get_contents($job['headerHandle'])));
  29678. fclose($job['headerHandle']);
  29679. if ($job['filename']) {
  29680. $contents = $job['filename'].'~';
  29681. if ($statusCode >= 300) {
  29682. rewind($job['bodyHandle']);
  29683. $contents = stream_get_contents($job['bodyHandle']);
  29684. }
  29685. $response = new Response(array('url' => $progress['url']), $statusCode, $headers, $contents);
  29686. $this->io->writeError('['.$statusCode.'] '.Url::sanitize($progress['url']), true, IOInterface::DEBUG);
  29687. } else {
  29688. rewind($job['bodyHandle']);
  29689. $contents = stream_get_contents($job['bodyHandle']);
  29690. $response = new Response(array('url' => $progress['url']), $statusCode, $headers, $contents);
  29691. $this->io->writeError('['.$statusCode.'] '.Url::sanitize($progress['url']), true, IOInterface::DEBUG);
  29692. }
  29693. fclose($job['bodyHandle']);
  29694. if ($response->getStatusCode() >= 400 && $response->getHeader('content-type') === 'application/json') {
  29695. HttpDownloader::outputWarnings($this->io, $job['origin'], json_decode($response->getBody(), true));
  29696. }
  29697. $result = $this->isAuthenticatedRetryNeeded($job, $response);
  29698. if ($result['retry']) {
  29699. $this->restartJob($job, $job['url'], array('storeAuth' => $result['storeAuth']));
  29700. continue;
  29701. }
  29702. if ($statusCode >= 300 && $statusCode <= 399 && $statusCode !== 304 && $job['attributes']['redirects'] < $this->maxRedirects) {
  29703. $location = $this->handleRedirect($job, $response);
  29704. if ($location) {
  29705. $this->restartJob($job, $location, array('redirects' => $job['attributes']['redirects'] + 1));
  29706. continue;
  29707. }
  29708. }
  29709. if ($statusCode >= 400 && $statusCode <= 599) {
  29710. throw $this->failResponse($job, $response, $response->getStatusMessage());
  29711. }
  29712. if ($job['attributes']['storeAuth']) {
  29713. $this->authHelper->storeAuth($job['origin'], $job['attributes']['storeAuth']);
  29714. }
  29715. if ($job['filename']) {
  29716. rename($job['filename'].'~', $job['filename']);
  29717. call_user_func($job['resolve'], $response);
  29718. } else {
  29719. call_user_func($job['resolve'], $response);
  29720. }
  29721. } catch (\Exception $e) {
  29722. if ($e instanceof TransportException && $headers) {
  29723. $e->setHeaders($headers);
  29724. $e->setStatusCode($statusCode);
  29725. }
  29726. if ($e instanceof TransportException && $response) {
  29727. $e->setResponse($response->getBody());
  29728. }
  29729. if (is_resource($job['headerHandle'])) {
  29730. fclose($job['headerHandle']);
  29731. }
  29732. if (is_resource($job['bodyHandle'])) {
  29733. fclose($job['bodyHandle']);
  29734. }
  29735. if ($job['filename']) {
  29736. @unlink($job['filename'].'~');
  29737. }
  29738. call_user_func($job['reject'], $e);
  29739. }
  29740. }
  29741. foreach ($this->jobs as $i => $curlHandle) {
  29742. if (!isset($this->jobs[$i])) {
  29743. continue;
  29744. }
  29745. $curlHandle = $this->jobs[$i]['curlHandle'];
  29746. $progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo);
  29747. if ($this->jobs[$i]['progress'] !== $progress) {
  29748. $this->jobs[$i]['progress'] = $progress;
  29749. if (isset($this->jobs[$i]['options']['max_file_size'])) {
  29750. if ($this->jobs[$i]['options']['max_file_size'] < $progress['download_content_length']) {
  29751. throw new MaxFileSizeExceededException('Maximum allowed download size reached. Content-length header indicates ' . $progress['download_content_length'] . ' bytes. Allowed ' . $this->jobs[$i]['options']['max_file_size'] . ' bytes');
  29752. }
  29753. if ($this->jobs[$i]['options']['max_file_size'] < $progress['size_download']) {
  29754. throw new MaxFileSizeExceededException('Maximum allowed download size reached. Downloaded ' . $progress['size_download'] . ' of allowed ' . $this->jobs[$i]['options']['max_file_size'] . ' bytes');
  29755. }
  29756. }
  29757. }
  29758. }
  29759. }
  29760. private function handleRedirect(array $job, Response $response)
  29761. {
  29762. if ($locationHeader = $response->getHeader('location')) {
  29763. if (parse_url($locationHeader, PHP_URL_SCHEME)) {
  29764. $targetUrl = $locationHeader;
  29765. } elseif (parse_url($locationHeader, PHP_URL_HOST)) {
  29766. $targetUrl = parse_url($job['url'], PHP_URL_SCHEME).':'.$locationHeader;
  29767. } elseif ('/' === $locationHeader[0]) {
  29768. $urlHost = parse_url($job['url'], PHP_URL_HOST);
  29769. $targetUrl = preg_replace('{^(.+(?://|@)'.preg_quote($urlHost).'(?::\d+)?)(?:[/\?].*)?$}', '\1'.$locationHeader, $job['url']);
  29770. } else {
  29771. $targetUrl = preg_replace('{^(.+/)[^/?]*(?:\?.*)?$}', '\1'.$locationHeader, $job['url']);
  29772. }
  29773. }
  29774. if (!empty($targetUrl)) {
  29775. $this->io->writeError(sprintf('Following redirect (%u) %s', $job['attributes']['redirects'] + 1, Url::sanitize($targetUrl)), true, IOInterface::DEBUG);
  29776. return $targetUrl;
  29777. }
  29778. throw new TransportException('The "'.$job['url'].'" file could not be downloaded, got redirect without Location ('.$response->getStatusMessage().')');
  29779. }
  29780. private function isAuthenticatedRetryNeeded(array $job, Response $response)
  29781. {
  29782. if (in_array($response->getStatusCode(), array(401, 403)) && $job['attributes']['retryAuthFailure']) {
  29783. $result = $this->authHelper->promptAuthIfNeeded($job['url'], $job['origin'], $response->getStatusCode(), $response->getStatusMessage(), $response->getHeaders());
  29784. if ($result['retry']) {
  29785. return $result;
  29786. }
  29787. }
  29788. $locationHeader = $response->getHeader('location');
  29789. $needsAuthRetry = false;
  29790. if (
  29791. $job['origin'] === 'bitbucket.org'
  29792. && !$this->authHelper->isPublicBitBucketDownload($job['url'])
  29793. && substr($job['url'], -4) === '.zip'
  29794. && (!$locationHeader || substr($locationHeader, -4) !== '.zip')
  29795. && preg_match('{^text/html\b}i', $response->getHeader('content-type'))
  29796. ) {
  29797. $needsAuthRetry = 'Bitbucket requires authentication and it was not provided';
  29798. }
  29799. if (
  29800. $response->getStatusCode() === 404
  29801. && $this->config && in_array($job['origin'], $this->config->get('gitlab-domains'), true)
  29802. && false !== strpos($job['url'], 'archive.zip')
  29803. ) {
  29804. $needsAuthRetry = 'GitLab requires authentication and it was not provided';
  29805. }
  29806. if ($needsAuthRetry) {
  29807. if ($job['attributes']['retryAuthFailure']) {
  29808. $result = $this->authHelper->promptAuthIfNeeded($job['url'], $job['origin'], 401);
  29809. if ($result['retry']) {
  29810. return $result;
  29811. }
  29812. }
  29813. throw $this->failResponse($job, $response, $needsAuthRetry);
  29814. }
  29815. return array('retry' => false, 'storeAuth' => false);
  29816. }
  29817. private function restartJob(array $job, $url, array $attributes = array())
  29818. {
  29819. if ($job['filename']) {
  29820. @unlink($job['filename'].'~');
  29821. }
  29822. $attributes = array_merge($job['attributes'], $attributes);
  29823. $origin = Url::getOrigin($this->config, $url);
  29824. $this->initDownload($job['resolve'], $job['reject'], $origin, $url, $job['options'], $job['filename'], $attributes);
  29825. }
  29826. private function failResponse(array $job, Response $response, $errorMessage)
  29827. {
  29828. if ($job['filename']) {
  29829. @unlink($job['filename'].'~');
  29830. }
  29831. return new TransportException('The "'.$job['url'].'" file could not be downloaded ('.$errorMessage.')', $response->getStatusCode());
  29832. }
  29833. private function checkCurlResult($code)
  29834. {
  29835. if ($code != CURLM_OK && $code != CURLM_CALL_MULTI_PERFORM) {
  29836. throw new \RuntimeException(isset($this->multiErrors[$code])
  29837. ? "cURL error: {$code} ({$this->multiErrors[$code][0]}): cURL message: {$this->multiErrors[$code][1]}"
  29838. : 'Unexpected cURL error: ' . $code
  29839. );
  29840. }
  29841. }
  29842. }
  29843. <?php
  29844. namespace Composer\Util\Http;
  29845. use Composer\Json\JsonFile;
  29846. class Response
  29847. {
  29848. private $request;
  29849. private $code;
  29850. private $headers;
  29851. private $body;
  29852. public function __construct(array $request, $code, array $headers, $body)
  29853. {
  29854. if (!isset($request['url'])) {
  29855. throw new \LogicException('url key missing from request array');
  29856. }
  29857. $this->request = $request;
  29858. $this->code = (int) $code;
  29859. $this->headers = $headers;
  29860. $this->body = $body;
  29861. }
  29862. public function getStatusCode()
  29863. {
  29864. return $this->code;
  29865. }
  29866. public function getStatusMessage()
  29867. {
  29868. $value = null;
  29869. foreach ($this->headers as $header) {
  29870. if (preg_match('{^HTTP/\S+ \d+}i', $header)) {
  29871. $value = $header;
  29872. }
  29873. }
  29874. return $value;
  29875. }
  29876. public function getHeaders()
  29877. {
  29878. return $this->headers;
  29879. }
  29880. public function getHeader($name)
  29881. {
  29882. return self::findHeaderValue($this->headers, $name);
  29883. }
  29884. public function getBody()
  29885. {
  29886. return $this->body;
  29887. }
  29888. public function decodeJson()
  29889. {
  29890. return JsonFile::parseJson($this->body, $this->request['url']);
  29891. }
  29892. public function collect()
  29893. {
  29894. $this->request = $this->code = $this->headers = $this->body = null;
  29895. }
  29896. public static function findHeaderValue(array $headers, $name)
  29897. {
  29898. $value = null;
  29899. foreach ($headers as $header) {
  29900. if (preg_match('{^'.preg_quote($name).':\s*(.+?)\s*$}i', $header, $match)) {
  29901. $value = $match[1];
  29902. } elseif (preg_match('{^HTTP/}i', $header)) {
  29903. $value = null;
  29904. }
  29905. }
  29906. return $value;
  29907. }
  29908. }
  29909. <?php
  29910. namespace Composer\Util;
  29911. use Composer\Config;
  29912. use Composer\IO\IOInterface;
  29913. use Composer\Downloader\TransportException;
  29914. use Composer\CaBundle\CaBundle;
  29915. use Composer\Util\Http\Response;
  29916. use Composer\Composer;
  29917. use Composer\Package\Version\VersionParser;
  29918. use Composer\Semver\Constraint\Constraint;
  29919. use React\Promise\Promise;
  29920. class HttpDownloader
  29921. {
  29922. const STATUS_QUEUED = 1;
  29923. const STATUS_STARTED = 2;
  29924. const STATUS_COMPLETED = 3;
  29925. const STATUS_FAILED = 4;
  29926. const STATUS_ABORTED = 5;
  29927. private $io;
  29928. private $config;
  29929. private $jobs = array();
  29930. private $options = array();
  29931. private $runningJobs = 0;
  29932. private $maxJobs = 10;
  29933. private $curl;
  29934. private $rfs;
  29935. private $idGen = 0;
  29936. private $disabled;
  29937. private $allowAsync = false;
  29938. public function __construct(IOInterface $io, Config $config, array $options = array(), $disableTls = false)
  29939. {
  29940. $this->io = $io;
  29941. $this->disabled = (bool) getenv('COMPOSER_DISABLE_NETWORK');
  29942. if ($disableTls === false) {
  29943. $this->options = StreamContextFactory::getTlsDefaults($options, $io);
  29944. }
  29945. $this->options = array_replace_recursive($this->options, $options);
  29946. $this->config = $config;
  29947. if (extension_loaded('curl')) {
  29948. $this->curl = new Http\CurlDownloader($io, $config, $options, $disableTls);
  29949. }
  29950. $this->rfs = new RemoteFilesystem($io, $config, $options, $disableTls);
  29951. }
  29952. public function get($url, $options = array())
  29953. {
  29954. list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => false), true);
  29955. $this->wait($job['id']);
  29956. return $this->getResponse($job['id']);
  29957. }
  29958. public function add($url, $options = array())
  29959. {
  29960. list(, $promise) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => false));
  29961. return $promise;
  29962. }
  29963. public function copy($url, $to, $options = array())
  29964. {
  29965. list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => $to), true);
  29966. $this->wait($job['id']);
  29967. return $this->getResponse($job['id']);
  29968. }
  29969. public function addCopy($url, $to, $options = array())
  29970. {
  29971. list(, $promise) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => $to));
  29972. return $promise;
  29973. }
  29974. public function getOptions()
  29975. {
  29976. return $this->options;
  29977. }
  29978. public function setOptions(array $options)
  29979. {
  29980. $this->options = array_replace_recursive($this->options, $options);
  29981. }
  29982. private function addJob($request, $sync = false)
  29983. {
  29984. $request['options'] = array_replace_recursive($this->options, $request['options']);
  29985. $job = array(
  29986. 'id' => $this->idGen++,
  29987. 'status' => self::STATUS_QUEUED,
  29988. 'request' => $request,
  29989. 'sync' => $sync,
  29990. 'origin' => Url::getOrigin($this->config, $request['url']),
  29991. );
  29992. if (!$sync && !$this->allowAsync) {
  29993. 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');
  29994. }
  29995. if (preg_match('{^https?://([^:/]+):([^@/]+)@([^/]+)}i', $request['url'], $match)) {
  29996. $this->io->setAuthentication($job['origin'], rawurldecode($match[1]), rawurldecode($match[2]));
  29997. }
  29998. $rfs = $this->rfs;
  29999. if ($this->curl && preg_match('{^https?://}i', $job['request']['url'])) {
  30000. $resolver = function ($resolve, $reject) use (&$job) {
  30001. $job['status'] = HttpDownloader::STATUS_QUEUED;
  30002. $job['resolve'] = $resolve;
  30003. $job['reject'] = $reject;
  30004. };
  30005. } else {
  30006. $resolver = function ($resolve, $reject) use (&$job, $rfs) {
  30007. $url = $job['request']['url'];
  30008. $options = $job['request']['options'];
  30009. $job['status'] = HttpDownloader::STATUS_STARTED;
  30010. if ($job['request']['copyTo']) {
  30011. $rfs->copy($job['origin'], $url, $job['request']['copyTo'], false , $options);
  30012. $headers = $rfs->getLastHeaders();
  30013. $response = new Http\Response($job['request'], $rfs->findStatusCode($headers), $headers, $job['request']['copyTo'].'~');
  30014. $resolve($response);
  30015. } else {
  30016. $body = $rfs->getContents($job['origin'], $url, false , $options);
  30017. $headers = $rfs->getLastHeaders();
  30018. $response = new Http\Response($job['request'], $rfs->findStatusCode($headers), $headers, $body);
  30019. $resolve($response);
  30020. }
  30021. };
  30022. }
  30023. $downloader = $this;
  30024. $curl = $this->curl;
  30025. $canceler = function () use (&$job, $curl) {
  30026. if ($job['status'] === HttpDownloader::STATUS_QUEUED) {
  30027. $job['status'] = HttpDownloader::STATUS_ABORTED;
  30028. }
  30029. if ($job['status'] !== HttpDownloader::STATUS_STARTED) {
  30030. return;
  30031. }
  30032. $job['status'] = HttpDownloader::STATUS_ABORTED;
  30033. if (isset($job['curl_id'])) {
  30034. $curl->abortRequest($job['curl_id']);
  30035. }
  30036. };
  30037. $promise = new Promise($resolver, $canceler);
  30038. $promise->then(function ($response) use (&$job, $downloader) {
  30039. $job['status'] = HttpDownloader::STATUS_COMPLETED;
  30040. $job['response'] = $response;
  30041. $downloader->markJobDone();
  30042. return $response;
  30043. }, function ($e) use (&$job, $downloader) {
  30044. $job['status'] = HttpDownloader::STATUS_FAILED;
  30045. $job['exception'] = $e;
  30046. $downloader->markJobDone();
  30047. throw $e;
  30048. });
  30049. $this->jobs[$job['id']] =& $job;
  30050. if ($this->runningJobs < $this->maxJobs) {
  30051. $this->startJob($job['id']);
  30052. }
  30053. return array($job, $promise);
  30054. }
  30055. private function startJob($id)
  30056. {
  30057. $job =& $this->jobs[$id];
  30058. if ($job['status'] !== self::STATUS_QUEUED) {
  30059. return;
  30060. }
  30061. $job['status'] = self::STATUS_STARTED;
  30062. $this->runningJobs++;
  30063. $resolve = $job['resolve'];
  30064. $reject = $job['reject'];
  30065. $url = $job['request']['url'];
  30066. $options = $job['request']['options'];
  30067. $origin = $job['origin'];
  30068. if ($this->disabled) {
  30069. if (isset($job['request']['options']['http']['header']) && false !== stripos(implode('', $job['request']['options']['http']['header']), 'if-modified-since')) {
  30070. $resolve(new Response(array('url' => $url), 304, array(), ''));
  30071. } else {
  30072. $e = new TransportException('Network disabled, request canceled: '.$url, 499);
  30073. $e->setStatusCode(499);
  30074. $reject($e);
  30075. }
  30076. return;
  30077. }
  30078. if ($job['request']['copyTo']) {
  30079. $job['curl_id'] = $this->curl->download($resolve, $reject, $origin, $url, $options, $job['request']['copyTo']);
  30080. } else {
  30081. $job['curl_id'] = $this->curl->download($resolve, $reject, $origin, $url, $options);
  30082. }
  30083. }
  30084. public function markJobDone()
  30085. {
  30086. $this->runningJobs--;
  30087. }
  30088. public function wait($index = null)
  30089. {
  30090. while (true) {
  30091. if (!$this->countActiveJobs($index)) {
  30092. return;
  30093. }
  30094. usleep(1000);
  30095. }
  30096. }
  30097. public function enableAsync()
  30098. {
  30099. $this->allowAsync = true;
  30100. }
  30101. public function countActiveJobs($index = null)
  30102. {
  30103. if ($this->runningJobs < $this->maxJobs) {
  30104. foreach ($this->jobs as $job) {
  30105. if ($job['status'] === self::STATUS_QUEUED && $this->runningJobs < $this->maxJobs) {
  30106. $this->startJob($job['id']);
  30107. }
  30108. }
  30109. }
  30110. if ($this->curl) {
  30111. $this->curl->tick();
  30112. }
  30113. if (null !== $index) {
  30114. return $this->jobs[$index]['status'] < self::STATUS_COMPLETED ? 1 : 0;
  30115. }
  30116. $active = 0;
  30117. foreach ($this->jobs as $job) {
  30118. if ($job['status'] < self::STATUS_COMPLETED) {
  30119. $active++;
  30120. } elseif (!$job['sync']) {
  30121. unset($this->jobs[$job['id']]);
  30122. }
  30123. }
  30124. return $active;
  30125. }
  30126. private function getResponse($index)
  30127. {
  30128. if (!isset($this->jobs[$index])) {
  30129. throw new \LogicException('Invalid request id');
  30130. }
  30131. if ($this->jobs[$index]['status'] === self::STATUS_FAILED) {
  30132. throw $this->jobs[$index]['exception'];
  30133. }
  30134. if (!isset($this->jobs[$index]['response'])) {
  30135. throw new \LogicException('Response not available yet, call wait() first');
  30136. }
  30137. $resp = $this->jobs[$index]['response'];
  30138. unset($this->jobs[$index]);
  30139. return $resp;
  30140. }
  30141. public static function outputWarnings(IOInterface $io, $url, $data)
  30142. {
  30143. foreach (array('warning', 'info') as $type) {
  30144. if (empty($data[$type])) {
  30145. continue;
  30146. }
  30147. if (!empty($data[$type . '-versions'])) {
  30148. $versionParser = new VersionParser();
  30149. $constraint = $versionParser->parseConstraints($data[$type . '-versions']);
  30150. $composer = new Constraint('==', $versionParser->normalize(Composer::getVersion()));
  30151. if (!$constraint->matches($composer)) {
  30152. continue;
  30153. }
  30154. }
  30155. $io->writeError('<'.$type.'>'.ucfirst($type).' from '.$url.': '.$data[$type].'</'.$type.'>');
  30156. }
  30157. }
  30158. }
  30159. <?php
  30160. namespace Composer\Util;
  30161. use Composer\XdebugHandler\XdebugHandler;
  30162. class IniHelper
  30163. {
  30164. public static function getAll()
  30165. {
  30166. return XdebugHandler::getAllIniFiles();
  30167. }
  30168. public static function getMessage()
  30169. {
  30170. $paths = self::getAll();
  30171. if (empty($paths[0])) {
  30172. array_shift($paths);
  30173. }
  30174. $ini = array_shift($paths);
  30175. if (empty($ini)) {
  30176. return 'A php.ini file does not exist. You will have to create one.';
  30177. }
  30178. if (!empty($paths)) {
  30179. return 'Your command-line PHP is using multiple ini files. Run `php --ini` to show them.';
  30180. }
  30181. return 'The php.ini used by your command-line PHP is: '.$ini;
  30182. }
  30183. }
  30184. <?php
  30185. namespace Composer\Util;
  30186. use Composer\Util\HttpDownloader;
  30187. use React\Promise\Promise;
  30188. use Symfony\Component\Console\Helper\ProgressBar;
  30189. class Loop
  30190. {
  30191. private $httpDownloader;
  30192. private $processExecutor;
  30193. private $currentPromises;
  30194. public function __construct(HttpDownloader $httpDownloader, ProcessExecutor $processExecutor = null)
  30195. {
  30196. $this->httpDownloader = $httpDownloader;
  30197. $this->httpDownloader->enableAsync();
  30198. $this->processExecutor = $processExecutor;
  30199. if ($this->processExecutor) {
  30200. $this->processExecutor->enableAsync();
  30201. }
  30202. }
  30203. public function getHttpDownloader()
  30204. {
  30205. return $this->httpDownloader;
  30206. }
  30207. public function getProcessExecutor()
  30208. {
  30209. return $this->processExecutor;
  30210. }
  30211. public function wait(array $promises, ProgressBar $progress = null)
  30212. {
  30213. $uncaught = null;
  30214. \React\Promise\all($promises)->then(
  30215. function () { },
  30216. function ($e) use (&$uncaught) {
  30217. $uncaught = $e;
  30218. }
  30219. );
  30220. $this->currentPromises = $promises;
  30221. if ($progress) {
  30222. $totalJobs = 0;
  30223. if ($this->httpDownloader) {
  30224. $totalJobs += $this->httpDownloader->countActiveJobs();
  30225. }
  30226. if ($this->processExecutor) {
  30227. $totalJobs += $this->processExecutor->countActiveJobs();
  30228. }
  30229. $progress->start($totalJobs);
  30230. }
  30231. while (true) {
  30232. $activeJobs = 0;
  30233. if ($this->httpDownloader) {
  30234. $activeJobs += $this->httpDownloader->countActiveJobs();
  30235. }
  30236. if ($this->processExecutor) {
  30237. $activeJobs += $this->processExecutor->countActiveJobs();
  30238. }
  30239. if ($progress) {
  30240. $progress->setProgress($progress->getMaxSteps() - $activeJobs);
  30241. }
  30242. if (!$activeJobs) {
  30243. break;
  30244. }
  30245. usleep(5000);
  30246. }
  30247. $this->currentPromises = null;
  30248. if ($uncaught) {
  30249. throw $uncaught;
  30250. }
  30251. }
  30252. public function abortJobs()
  30253. {
  30254. if ($this->currentPromises) {
  30255. foreach ($this->currentPromises as $promise) {
  30256. $promise->cancel();
  30257. }
  30258. }
  30259. }
  30260. }
  30261. <?php
  30262. namespace Composer\Util;
  30263. class MetadataMinifier
  30264. {
  30265. public static function expand(array $versions)
  30266. {
  30267. $expanded = array();
  30268. $expandedVersion = null;
  30269. foreach ($versions as $versionData) {
  30270. if (!$expandedVersion) {
  30271. $expandedVersion = $versionData;
  30272. $expanded[] = $expandedVersion;
  30273. continue;
  30274. }
  30275. foreach ($versionData as $key => $val) {
  30276. if ($val === '__unset') {
  30277. unset($expandedVersion[$key]);
  30278. } else {
  30279. $expandedVersion[$key] = $val;
  30280. }
  30281. }
  30282. $expanded[] = $expandedVersion;
  30283. }
  30284. return $expanded;
  30285. }
  30286. public static function minify(array $versions)
  30287. {
  30288. $minifiedVersions = array();
  30289. $lastKnownVersionData = null;
  30290. foreach ($versions as $version) {
  30291. if (!$lastKnownVersionData) {
  30292. $lastKnownVersionData = $version;
  30293. $minifiedVersions[] = $version;
  30294. continue;
  30295. }
  30296. $minifiedVersion = array();
  30297. foreach ($version as $key => $val) {
  30298. if (!isset($lastKnownVersionData[$key]) || $lastKnownVersionData[$key] !== $val) {
  30299. $minifiedVersion[$key] = $val;
  30300. $lastKnownVersionData[$key] = $val;
  30301. }
  30302. }
  30303. foreach ($lastKnownVersionData as $key => $val) {
  30304. if (!isset($version[$key])) {
  30305. $minifiedVersion[$key] = "__unset";
  30306. unset($lastKnownVersionData[$key]);
  30307. }
  30308. }
  30309. $minifiedVersions[] = $minifiedVersion;
  30310. }
  30311. return $minifiedVersions;
  30312. }
  30313. }
  30314. <?php
  30315. namespace Composer\Util;
  30316. use stdClass;
  30317. class NoProxyPattern
  30318. {
  30319. protected $hostNames = array();
  30320. protected $rules = array();
  30321. protected $noproxy;
  30322. public function __construct($pattern)
  30323. {
  30324. $this->hostNames = preg_split('{[\s,]+}', $pattern, null, PREG_SPLIT_NO_EMPTY);
  30325. $this->noproxy = empty($this->hostNames) || '*' === $this->hostNames[0];
  30326. }
  30327. public function test($url)
  30328. {
  30329. if ($this->noproxy) {
  30330. return true;
  30331. }
  30332. if (!$urlData = $this->getUrlData($url)) {
  30333. return false;
  30334. }
  30335. foreach ($this->hostNames as $index => $hostName) {
  30336. if ($this->match($index, $hostName, $urlData)) {
  30337. return true;
  30338. }
  30339. }
  30340. return false;
  30341. }
  30342. protected function getUrlData($url)
  30343. {
  30344. if (!$host = parse_url($url, PHP_URL_HOST)) {
  30345. return false;
  30346. }
  30347. $port = parse_url($url, PHP_URL_PORT);
  30348. if (empty($port)) {
  30349. switch (parse_url($url, PHP_URL_SCHEME)) {
  30350. case 'http':
  30351. $port = 80;
  30352. break;
  30353. case 'https':
  30354. $port = 443;
  30355. break;
  30356. }
  30357. }
  30358. $hostName = $host . ($port ? ':' . $port : '');
  30359. list($host, $port, $err) = $this->splitHostPort($hostName);
  30360. if ($err || !$this->ipCheckData($host, $ipdata)) {
  30361. return false;
  30362. }
  30363. return $this->makeData($host, $port, $ipdata);
  30364. }
  30365. protected function match($index, $hostName, $url)
  30366. {
  30367. if (!$rule = $this->getRule($index, $hostName)) {
  30368. return false;
  30369. }
  30370. if ($rule->ipdata) {
  30371. if (!$url->ipdata) {
  30372. return false;
  30373. }
  30374. if ($rule->ipdata->netmask) {
  30375. return $this->matchRange($rule->ipdata, $url->ipdata);
  30376. }
  30377. $match = $rule->ipdata->ip === $url->ipdata->ip;
  30378. } else {
  30379. $haystack = substr($url->name, - strlen($rule->name));
  30380. $match = stripos($haystack, $rule->name) === 0;
  30381. }
  30382. if ($match && $rule->port) {
  30383. $match = $rule->port === $url->port;
  30384. }
  30385. return $match;
  30386. }
  30387. protected function matchRange(stdClass $network, stdClass $target)
  30388. {
  30389. $net = unpack('C*', $network->ip);
  30390. $mask = unpack('C*', $network->netmask);
  30391. $ip = unpack('C*', $target->ip);
  30392. for ($i = 1; $i < 17; ++$i) {
  30393. if (($net[$i] & $mask[$i]) !== ($ip[$i] & $mask[$i])) {
  30394. return false;
  30395. }
  30396. }
  30397. return true;
  30398. }
  30399. private function getRule($index, $hostName)
  30400. {
  30401. if (array_key_exists($index, $this->rules)) {
  30402. return $this->rules[$index];
  30403. }
  30404. $this->rules[$index] = null;
  30405. list($host, $port, $err) = $this->splitHostPort($hostName);
  30406. if ($err || !$this->ipCheckData($host, $ipdata, true)) {
  30407. return null;
  30408. }
  30409. $this->rules[$index] = $this->makeData($host, $port, $ipdata);
  30410. return $this->rules[$index];
  30411. }
  30412. private function ipCheckData($host, &$ipdata, $allowPrefix = false)
  30413. {
  30414. $ipdata = null;
  30415. $netmask = null;
  30416. $prefix = null;
  30417. $modified = false;
  30418. if (strpos($host, '/') !== false) {
  30419. list($host, $prefix) = explode('/', $host);
  30420. if (!$allowPrefix || !$this->validateInt($prefix, 0, 128)) {
  30421. return false;
  30422. }
  30423. $prefix = (int) $prefix;
  30424. $modified = true;
  30425. }
  30426. if (!filter_var($host, FILTER_VALIDATE_IP)) {
  30427. return !$modified;
  30428. }
  30429. list($ip, $size) = $this->ipGetAddr($host);
  30430. if ($prefix !== null) {
  30431. if ($prefix > $size * 8) {
  30432. return false;
  30433. }
  30434. list($ip, $netmask) = $this->ipGetNetwork($ip, $size, $prefix);
  30435. }
  30436. $ipdata = $this->makeIpData($ip, $size, $netmask);
  30437. return true;
  30438. }
  30439. private function ipGetAddr($host)
  30440. {
  30441. $ip = inet_pton($host);
  30442. $size = strlen($ip);
  30443. $mapped = $this->ipMapTo6($ip, $size);
  30444. return array($mapped, $size);
  30445. }
  30446. private function ipGetMask($prefix, $size)
  30447. {
  30448. $mask = '';
  30449. if ($ones = floor($prefix / 8)) {
  30450. $mask = str_repeat(chr(255), $ones);
  30451. }
  30452. if ($remainder = $prefix % 8) {
  30453. $mask .= chr(0xff ^ (0xff >> $remainder));
  30454. }
  30455. $mask = str_pad($mask, $size, chr(0));
  30456. return $this->ipMapTo6($mask, $size);
  30457. }
  30458. private function ipGetNetwork($rangeIp, $size, $prefix)
  30459. {
  30460. $netmask = $this->ipGetMask($prefix, $size);
  30461. $mask = unpack('C*', $netmask);
  30462. $ip = unpack('C*', $rangeIp);
  30463. $net = '';
  30464. for ($i = 1; $i < 17; ++$i) {
  30465. $net .= chr($ip[$i] & $mask[$i]);
  30466. }
  30467. return array($net, $netmask);
  30468. }
  30469. private function ipMapTo6($binary, $size)
  30470. {
  30471. if ($size === 4) {
  30472. $prefix = str_repeat(chr(0), 10) . str_repeat(chr(255), 2);
  30473. $binary = $prefix . $binary;
  30474. }
  30475. return $binary;
  30476. }
  30477. private function makeData($host, $port, $ipdata)
  30478. {
  30479. return (object) array(
  30480. 'host' => $host,
  30481. 'name' => '.' . ltrim($host, '.'),
  30482. 'port' => $port,
  30483. 'ipdata' => $ipdata,
  30484. );
  30485. }
  30486. private function makeIpData($ip, $size, $netmask)
  30487. {
  30488. return (object) array(
  30489. 'ip' => $ip,
  30490. 'size' => $size,
  30491. 'netmask' => $netmask,
  30492. );
  30493. }
  30494. private function splitHostPort($hostName)
  30495. {
  30496. $error = array('', '', true);
  30497. $port = 0;
  30498. $ip6 = '';
  30499. if ($hostName[0] === '[') {
  30500. $index = strpos($hostName, ']');
  30501. if (false === $index || $index < 3) {
  30502. return $error;
  30503. }
  30504. $ip6 = substr($hostName, 1, $index - 1);
  30505. $hostName = substr($hostName, $index + 1);
  30506. if (strpbrk($hostName, '[]') !== false
  30507. || substr_count($hostName, ':') > 1) {
  30508. return $error;
  30509. }
  30510. }
  30511. if (substr_count($hostName, ':') === 1) {
  30512. $index = strpos($hostName, ':');
  30513. $port = substr($hostName, $index + 1);
  30514. $hostName = substr($hostName, 0, $index);
  30515. if (!$this->validateInt($port, 1, 65535)) {
  30516. return $error;
  30517. }
  30518. $port = (int) $port;
  30519. }
  30520. $host = $ip6 . $hostName;
  30521. return array($host, $port, false);
  30522. }
  30523. private function validateInt($int, $min, $max)
  30524. {
  30525. $options = array(
  30526. 'options' => array(
  30527. 'min_range' => $min,
  30528. 'max_range' => $max)
  30529. );
  30530. return false !== filter_var($int, FILTER_VALIDATE_INT, $options);
  30531. }
  30532. }
  30533. <?php
  30534. namespace Composer\Util;
  30535. use Composer\Package\Link;
  30536. use Composer\Package\PackageInterface;
  30537. class PackageSorter
  30538. {
  30539. public static function sortPackages(array $packages) {
  30540. $usageList = array();
  30541. foreach ($packages as $package) {
  30542. foreach (array_merge($package->getRequires(), $package->getDevRequires()) as $link) {
  30543. $target = $link->getTarget();
  30544. $usageList[$target][] = $package->getName();
  30545. }
  30546. }
  30547. $computing = array();
  30548. $computed = array();
  30549. $computeImportance = function ($name) use (&$computeImportance, &$computing, &$computed, $usageList) {
  30550. if (isset($computed[$name])) {
  30551. return $computed[$name];
  30552. }
  30553. if (isset($computing[$name])) {
  30554. return 0;
  30555. }
  30556. $computing[$name] = true;
  30557. $weight = 0;
  30558. if (isset($usageList[$name])) {
  30559. foreach ($usageList[$name] as $user) {
  30560. $weight -= 1 - $computeImportance($user);
  30561. }
  30562. }
  30563. unset($computing[$name]);
  30564. $computed[$name] = $weight;
  30565. return $weight;
  30566. };
  30567. $weightList = array();
  30568. foreach ($packages as $index => $package) {
  30569. $weight = $computeImportance($package->getName());
  30570. $weightList[$index] = $weight;
  30571. }
  30572. $stable_sort = function (&$array) {
  30573. static $transform, $restore;
  30574. $i = 0;
  30575. if (!$transform) {
  30576. $transform = function (&$v, $k) use (&$i) {
  30577. $v = array($v, ++$i, $k, $v);
  30578. };
  30579. $restore = function (&$v) {
  30580. $v = $v[3];
  30581. };
  30582. }
  30583. array_walk($array, $transform);
  30584. asort($array);
  30585. array_walk($array, $restore);
  30586. };
  30587. $stable_sort($weightList);
  30588. $sortedPackages = array();
  30589. foreach (array_keys($weightList) as $index) {
  30590. $sortedPackages[] = $packages[$index];
  30591. }
  30592. return $sortedPackages;
  30593. }
  30594. }
  30595. <?php
  30596. namespace Composer\Util;
  30597. use Composer\IO\IOInterface;
  30598. use Symfony\Component\Process\Process;
  30599. class Perforce
  30600. {
  30601. protected $path;
  30602. protected $p4Depot;
  30603. protected $p4Client;
  30604. protected $p4User;
  30605. protected $p4Password;
  30606. protected $p4Port;
  30607. protected $p4Stream;
  30608. protected $p4ClientSpec;
  30609. protected $p4DepotType;
  30610. protected $p4Branch;
  30611. protected $process;
  30612. protected $uniquePerforceClientName;
  30613. protected $windowsFlag;
  30614. protected $commandResult;
  30615. protected $io;
  30616. protected $filesystem;
  30617. public function __construct($repoConfig, $port, $path, ProcessExecutor $process, $isWindows, IOInterface $io)
  30618. {
  30619. $this->windowsFlag = $isWindows;
  30620. $this->p4Port = $port;
  30621. $this->initializePath($path);
  30622. $this->process = $process;
  30623. $this->initialize($repoConfig);
  30624. $this->io = $io;
  30625. }
  30626. public static function create($repoConfig, $port, $path, ProcessExecutor $process, IOInterface $io)
  30627. {
  30628. return new Perforce($repoConfig, $port, $path, $process, Platform::isWindows(), $io);
  30629. }
  30630. public static function checkServerExists($url, ProcessExecutor $processExecutor)
  30631. {
  30632. $output = null;
  30633. return 0 === $processExecutor->execute('p4 -p ' . ProcessExecutor::escape($url) . ' info -s', $output);
  30634. }
  30635. public function initialize($repoConfig)
  30636. {
  30637. $this->uniquePerforceClientName = $this->generateUniquePerforceClientName();
  30638. if (!$repoConfig) {
  30639. return;
  30640. }
  30641. if (isset($repoConfig['unique_perforce_client_name'])) {
  30642. $this->uniquePerforceClientName = $repoConfig['unique_perforce_client_name'];
  30643. }
  30644. if (isset($repoConfig['depot'])) {
  30645. $this->p4Depot = $repoConfig['depot'];
  30646. }
  30647. if (isset($repoConfig['branch'])) {
  30648. $this->p4Branch = $repoConfig['branch'];
  30649. }
  30650. if (isset($repoConfig['p4user'])) {
  30651. $this->p4User = $repoConfig['p4user'];
  30652. } else {
  30653. $this->p4User = $this->getP4variable('P4USER');
  30654. }
  30655. if (isset($repoConfig['p4password'])) {
  30656. $this->p4Password = $repoConfig['p4password'];
  30657. }
  30658. }
  30659. public function initializeDepotAndBranch($depot, $branch)
  30660. {
  30661. if (isset($depot)) {
  30662. $this->p4Depot = $depot;
  30663. }
  30664. if (isset($branch)) {
  30665. $this->p4Branch = $branch;
  30666. }
  30667. }
  30668. public function generateUniquePerforceClientName()
  30669. {
  30670. return gethostname() . "_" . time();
  30671. }
  30672. public function cleanupClientSpec()
  30673. {
  30674. $client = $this->getClient();
  30675. $task = 'client -d ' . ProcessExecutor::escape($client);
  30676. $useP4Client = false;
  30677. $command = $this->generateP4Command($task, $useP4Client);
  30678. $this->executeCommand($command);
  30679. $clientSpec = $this->getP4ClientSpec();
  30680. $fileSystem = $this->getFilesystem();
  30681. $fileSystem->remove($clientSpec);
  30682. }
  30683. protected function executeCommand($command)
  30684. {
  30685. $this->commandResult = '';
  30686. return $this->process->execute($command, $this->commandResult);
  30687. }
  30688. public function getClient()
  30689. {
  30690. if (!isset($this->p4Client)) {
  30691. $cleanStreamName = str_replace(array('//', '/', '@'), array('', '_', ''), $this->getStream());
  30692. $this->p4Client = 'composer_perforce_' . $this->uniquePerforceClientName . '_' . $cleanStreamName;
  30693. }
  30694. return $this->p4Client;
  30695. }
  30696. protected function getPath()
  30697. {
  30698. return $this->path;
  30699. }
  30700. public function initializePath($path)
  30701. {
  30702. $this->path = $path;
  30703. $fs = $this->getFilesystem();
  30704. $fs->ensureDirectoryExists($path);
  30705. }
  30706. protected function getPort()
  30707. {
  30708. return $this->p4Port;
  30709. }
  30710. public function setStream($stream)
  30711. {
  30712. $this->p4Stream = $stream;
  30713. $index = strrpos($stream, '/');
  30714. if ($index > 2) {
  30715. $this->p4DepotType = 'stream';
  30716. }
  30717. }
  30718. public function isStream()
  30719. {
  30720. return (strcmp($this->p4DepotType, 'stream') === 0);
  30721. }
  30722. public function getStream()
  30723. {
  30724. if (!isset($this->p4Stream)) {
  30725. if ($this->isStream()) {
  30726. $this->p4Stream = '//' . $this->p4Depot . '/' . $this->p4Branch;
  30727. } else {
  30728. $this->p4Stream = '//' . $this->p4Depot;
  30729. }
  30730. }
  30731. return $this->p4Stream;
  30732. }
  30733. public function getStreamWithoutLabel($stream)
  30734. {
  30735. $index = strpos($stream, '@');
  30736. if ($index === false) {
  30737. return $stream;
  30738. }
  30739. return substr($stream, 0, $index);
  30740. }
  30741. public function getP4ClientSpec()
  30742. {
  30743. return $this->path . '/' . $this->getClient() . '.p4.spec';
  30744. }
  30745. public function getUser()
  30746. {
  30747. return $this->p4User;
  30748. }
  30749. public function setUser($user)
  30750. {
  30751. $this->p4User = $user;
  30752. }
  30753. public function queryP4User()
  30754. {
  30755. $this->getUser();
  30756. if (strlen($this->p4User) > 0) {
  30757. return;
  30758. }
  30759. $this->p4User = $this->getP4variable('P4USER');
  30760. if (strlen($this->p4User) > 0) {
  30761. return;
  30762. }
  30763. $this->p4User = $this->io->ask('Enter P4 User:');
  30764. if ($this->windowsFlag) {
  30765. $command = 'p4 set P4USER=' . $this->p4User;
  30766. } else {
  30767. $command = 'export P4USER=' . $this->p4User;
  30768. }
  30769. $this->executeCommand($command);
  30770. }
  30771. protected function getP4variable($name)
  30772. {
  30773. if ($this->windowsFlag) {
  30774. $command = 'p4 set';
  30775. $this->executeCommand($command);
  30776. $result = trim($this->commandResult);
  30777. $resArray = explode(PHP_EOL, $result);
  30778. foreach ($resArray as $line) {
  30779. $fields = explode('=', $line);
  30780. if (strcmp($name, $fields[0]) == 0) {
  30781. $index = strpos($fields[1], ' ');
  30782. if ($index === false) {
  30783. $value = $fields[1];
  30784. } else {
  30785. $value = substr($fields[1], 0, $index);
  30786. }
  30787. $value = trim($value);
  30788. return $value;
  30789. }
  30790. }
  30791. return null;
  30792. }
  30793. $command = 'echo $' . $name;
  30794. $this->executeCommand($command);
  30795. $result = trim($this->commandResult);
  30796. return $result;
  30797. }
  30798. public function queryP4Password()
  30799. {
  30800. if (isset($this->p4Password)) {
  30801. return $this->p4Password;
  30802. }
  30803. $password = $this->getP4variable('P4PASSWD');
  30804. if (strlen($password) <= 0) {
  30805. $password = $this->io->askAndHideAnswer('Enter password for Perforce user ' . $this->getUser() . ': ');
  30806. }
  30807. $this->p4Password = $password;
  30808. return $password;
  30809. }
  30810. public function generateP4Command($command, $useClient = true)
  30811. {
  30812. $p4Command = 'p4 ';
  30813. $p4Command .= '-u ' . $this->getUser() . ' ';
  30814. if ($useClient) {
  30815. $p4Command .= '-c ' . $this->getClient() . ' ';
  30816. }
  30817. $p4Command .= '-p ' . $this->getPort() . ' ' . $command;
  30818. return $p4Command;
  30819. }
  30820. public function isLoggedIn()
  30821. {
  30822. $command = $this->generateP4Command('login -s', false);
  30823. $exitCode = $this->executeCommand($command);
  30824. if ($exitCode) {
  30825. $errorOutput = $this->process->getErrorOutput();
  30826. $index = strpos($errorOutput, $this->getUser());
  30827. if ($index === false) {
  30828. $index = strpos($errorOutput, 'p4');
  30829. if ($index === false) {
  30830. return false;
  30831. }
  30832. throw new \Exception('p4 command not found in path: ' . $errorOutput);
  30833. }
  30834. throw new \Exception('Invalid user name: ' . $this->getUser());
  30835. }
  30836. return true;
  30837. }
  30838. public function connectClient()
  30839. {
  30840. $p4CreateClientCommand = $this->generateP4Command(
  30841. 'client -i < ' . str_replace(" ", "\\ ", $this->getP4ClientSpec())
  30842. );
  30843. $this->executeCommand($p4CreateClientCommand);
  30844. }
  30845. public function syncCodeBase($sourceReference)
  30846. {
  30847. $prevDir = getcwd();
  30848. chdir($this->path);
  30849. $p4SyncCommand = $this->generateP4Command('sync -f ');
  30850. if (null !== $sourceReference) {
  30851. $p4SyncCommand .= '@' . $sourceReference;
  30852. }
  30853. $this->executeCommand($p4SyncCommand);
  30854. chdir($prevDir);
  30855. }
  30856. public function writeClientSpecToFile($spec)
  30857. {
  30858. fwrite($spec, 'Client: ' . $this->getClient() . PHP_EOL . PHP_EOL);
  30859. fwrite($spec, 'Update: ' . date('Y/m/d H:i:s') . PHP_EOL . PHP_EOL);
  30860. fwrite($spec, 'Access: ' . date('Y/m/d H:i:s') . PHP_EOL);
  30861. fwrite($spec, 'Owner: ' . $this->getUser() . PHP_EOL . PHP_EOL);
  30862. fwrite($spec, 'Description:' . PHP_EOL);
  30863. fwrite($spec, ' Created by ' . $this->getUser() . ' from composer.' . PHP_EOL . PHP_EOL);
  30864. fwrite($spec, 'Root: ' . $this->getPath() . PHP_EOL . PHP_EOL);
  30865. fwrite($spec, 'Options: noallwrite noclobber nocompress unlocked modtime rmdir' . PHP_EOL . PHP_EOL);
  30866. fwrite($spec, 'SubmitOptions: revertunchanged' . PHP_EOL . PHP_EOL);
  30867. fwrite($spec, 'LineEnd: local' . PHP_EOL . PHP_EOL);
  30868. if ($this->isStream()) {
  30869. fwrite($spec, 'Stream:' . PHP_EOL);
  30870. fwrite($spec, ' ' . $this->getStreamWithoutLabel($this->p4Stream) . PHP_EOL);
  30871. } else {
  30872. fwrite(
  30873. $spec,
  30874. 'View: ' . $this->getStream() . '/... //' . $this->getClient() . '/... ' . PHP_EOL
  30875. );
  30876. }
  30877. }
  30878. public function writeP4ClientSpec()
  30879. {
  30880. $clientSpec = $this->getP4ClientSpec();
  30881. $spec = fopen($clientSpec, 'w');
  30882. try {
  30883. $this->writeClientSpecToFile($spec);
  30884. } catch (\Exception $e) {
  30885. fclose($spec);
  30886. throw $e;
  30887. }
  30888. fclose($spec);
  30889. }
  30890. protected function read($pipe, $name)
  30891. {
  30892. if (feof($pipe)) {
  30893. return;
  30894. }
  30895. $line = fgets($pipe);
  30896. while ($line !== false) {
  30897. $line = fgets($pipe);
  30898. }
  30899. }
  30900. public function windowsLogin($password)
  30901. {
  30902. $command = $this->generateP4Command(' login -a');
  30903. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  30904. $process = Process::fromShellCommandline($command, null, null, $password);
  30905. } else {
  30906. $process = new Process($command, null, null, $password);
  30907. }
  30908. return $process->run();
  30909. }
  30910. public function p4Login()
  30911. {
  30912. $this->queryP4User();
  30913. if (!$this->isLoggedIn()) {
  30914. $password = $this->queryP4Password();
  30915. if ($this->windowsFlag) {
  30916. $this->windowsLogin($password);
  30917. } else {
  30918. $command = 'echo ' . ProcessExecutor::escape($password) . ' | ' . $this->generateP4Command(' login -a', false);
  30919. $exitCode = $this->executeCommand($command);
  30920. if ($exitCode) {
  30921. throw new \Exception("Error logging in:" . $this->process->getErrorOutput());
  30922. }
  30923. }
  30924. }
  30925. }
  30926. public function getComposerInformation($identifier)
  30927. {
  30928. $composerFileContent = $this->getFileContent('composer.json', $identifier);
  30929. if (!$composerFileContent) {
  30930. return;
  30931. }
  30932. return json_decode($composerFileContent, true);
  30933. }
  30934. public function getFileContent($file, $identifier)
  30935. {
  30936. $path = $this->getFilePath($file, $identifier);
  30937. $command = $this->generateP4Command(' print ' . ProcessExecutor::escape($path));
  30938. $this->executeCommand($command);
  30939. $result = $this->commandResult;
  30940. if (!trim($result)) {
  30941. return null;
  30942. }
  30943. return $result;
  30944. }
  30945. public function getFilePath($file, $identifier)
  30946. {
  30947. $index = strpos($identifier, '@');
  30948. if ($index === false) {
  30949. return $identifier. '/' . $file;
  30950. }
  30951. $path = substr($identifier, 0, $index) . '/' . $file . substr($identifier, $index);
  30952. $command = $this->generateP4Command(' files ' . ProcessExecutor::escape($path), false);
  30953. $this->executeCommand($command);
  30954. $result = $this->commandResult;
  30955. $index2 = strpos($result, 'no such file(s).');
  30956. if ($index2 === false) {
  30957. $index3 = strpos($result, 'change');
  30958. if ($index3 !== false) {
  30959. $phrase = trim(substr($result, $index3));
  30960. $fields = explode(' ', $phrase);
  30961. return substr($identifier, 0, $index) . '/' . $file . '@' . $fields[1];
  30962. }
  30963. }
  30964. return null;
  30965. }
  30966. public function getBranches()
  30967. {
  30968. $possibleBranches = array();
  30969. if (!$this->isStream()) {
  30970. $possibleBranches[$this->p4Branch] = $this->getStream();
  30971. } else {
  30972. $command = $this->generateP4Command('streams '.ProcessExecutor::escape('//' . $this->p4Depot . '/...'));
  30973. $this->executeCommand($command);
  30974. $result = $this->commandResult;
  30975. $resArray = explode(PHP_EOL, $result);
  30976. foreach ($resArray as $line) {
  30977. $resBits = explode(' ', $line);
  30978. if (count($resBits) > 4) {
  30979. $branch = preg_replace('/[^A-Za-z0-9 ]/', '', $resBits[4]);
  30980. $possibleBranches[$branch] = $resBits[1];
  30981. }
  30982. }
  30983. }
  30984. $command = $this->generateP4Command('changes '. ProcessExecutor::escape($this->getStream() . '/...'), false);
  30985. $this->executeCommand($command);
  30986. $result = $this->commandResult;
  30987. $resArray = explode(PHP_EOL, $result);
  30988. $lastCommit = $resArray[0];
  30989. $lastCommitArr = explode(' ', $lastCommit);
  30990. $lastCommitNum = $lastCommitArr[1];
  30991. return array('master' => $possibleBranches[$this->p4Branch] . '@'. $lastCommitNum);
  30992. }
  30993. public function getTags()
  30994. {
  30995. $command = $this->generateP4Command('labels');
  30996. $this->executeCommand($command);
  30997. $result = $this->commandResult;
  30998. $resArray = explode(PHP_EOL, $result);
  30999. $tags = array();
  31000. foreach ($resArray as $line) {
  31001. if (strpos($line, 'Label') !== false) {
  31002. $fields = explode(' ', $line);
  31003. $tags[$fields[1]] = $this->getStream() . '@' . $fields[1];
  31004. }
  31005. }
  31006. return $tags;
  31007. }
  31008. public function checkStream()
  31009. {
  31010. $command = $this->generateP4Command('depots', false);
  31011. $this->executeCommand($command);
  31012. $result = $this->commandResult;
  31013. $resArray = explode(PHP_EOL, $result);
  31014. foreach ($resArray as $line) {
  31015. if (strpos($line, 'Depot') !== false) {
  31016. $fields = explode(' ', $line);
  31017. if (strcmp($this->p4Depot, $fields[1]) === 0) {
  31018. $this->p4DepotType = $fields[3];
  31019. return $this->isStream();
  31020. }
  31021. }
  31022. }
  31023. return false;
  31024. }
  31025. protected function getChangeList($reference)
  31026. {
  31027. $index = strpos($reference, '@');
  31028. if ($index === false) {
  31029. return null;
  31030. }
  31031. $label = substr($reference, $index);
  31032. $command = $this->generateP4Command(' changes -m1 ' . ProcessExecutor::escape($label));
  31033. $this->executeCommand($command);
  31034. $changes = $this->commandResult;
  31035. if (strpos($changes, 'Change') !== 0) {
  31036. return null;
  31037. }
  31038. $fields = explode(' ', $changes);
  31039. return $fields[1];
  31040. }
  31041. public function getCommitLogs($fromReference, $toReference)
  31042. {
  31043. $fromChangeList = $this->getChangeList($fromReference);
  31044. if ($fromChangeList === null) {
  31045. return null;
  31046. }
  31047. $toChangeList = $this->getChangeList($toReference);
  31048. if ($toChangeList === null) {
  31049. return null;
  31050. }
  31051. $index = strpos($fromReference, '@');
  31052. $main = substr($fromReference, 0, $index) . '/...';
  31053. $command = $this->generateP4Command('filelog ' . ProcessExecutor::escape($main . '@' . $fromChangeList. ',' . $toChangeList));
  31054. $this->executeCommand($command);
  31055. return $this->commandResult;
  31056. }
  31057. public function getFilesystem()
  31058. {
  31059. if (empty($this->filesystem)) {
  31060. $this->filesystem = new Filesystem($this->process);
  31061. }
  31062. return $this->filesystem;
  31063. }
  31064. public function setFilesystem(Filesystem $fs)
  31065. {
  31066. $this->filesystem = $fs;
  31067. }
  31068. }
  31069. <?php
  31070. namespace Composer\Util;
  31071. class Platform
  31072. {
  31073. public static function expandPath($path)
  31074. {
  31075. if (preg_match('#^~[\\/]#', $path)) {
  31076. return self::getUserDirectory() . substr($path, 1);
  31077. }
  31078. return preg_replace_callback('#^(\$|(?P<percent>%))(?P<var>\w++)(?(percent)%)(?P<path>.*)#', function ($matches) {
  31079. if (Platform::isWindows() && $matches['var'] == 'HOME') {
  31080. return (getenv('HOME') ?: getenv('USERPROFILE')) . $matches['path'];
  31081. }
  31082. return getenv($matches['var']) . $matches['path'];
  31083. }, $path);
  31084. }
  31085. public static function getUserDirectory()
  31086. {
  31087. if (false !== ($home = getenv('HOME'))) {
  31088. return $home;
  31089. }
  31090. if (self::isWindows() && false !== ($home = getenv('USERPROFILE'))) {
  31091. return $home;
  31092. }
  31093. if (\function_exists('posix_getuid') && \function_exists('posix_getpwuid')) {
  31094. $info = posix_getpwuid(posix_getuid());
  31095. return $info['dir'];
  31096. }
  31097. throw new \RuntimeException('Could not determine user directory');
  31098. }
  31099. public static function isWindows()
  31100. {
  31101. return \defined('PHP_WINDOWS_VERSION_BUILD');
  31102. }
  31103. public static function strlen($str)
  31104. {
  31105. static $useMbString = null;
  31106. if (null === $useMbString) {
  31107. $useMbString = \function_exists('mb_strlen') && ini_get('mbstring.func_overload');
  31108. }
  31109. if ($useMbString) {
  31110. return mb_strlen($str, '8bit');
  31111. }
  31112. return \strlen($str);
  31113. }
  31114. }
  31115. <?php
  31116. namespace Composer\Util;
  31117. use Composer\IO\IOInterface;
  31118. use Symfony\Component\Process\Process;
  31119. use Symfony\Component\Process\ProcessUtils;
  31120. use Symfony\Component\Process\Exception\RuntimeException;
  31121. use React\Promise\Promise;
  31122. class ProcessExecutor
  31123. {
  31124. const STATUS_QUEUED = 1;
  31125. const STATUS_STARTED = 2;
  31126. const STATUS_COMPLETED = 3;
  31127. const STATUS_FAILED = 4;
  31128. const STATUS_ABORTED = 5;
  31129. protected static $timeout = 300;
  31130. protected $captureOutput;
  31131. protected $errorOutput;
  31132. protected $io;
  31133. private $jobs = array();
  31134. private $runningJobs = 0;
  31135. private $maxJobs = 10;
  31136. private $idGen = 0;
  31137. private $allowAsync = false;
  31138. public function __construct(IOInterface $io = null)
  31139. {
  31140. $this->io = $io;
  31141. }
  31142. public function execute($command, &$output = null, $cwd = null)
  31143. {
  31144. if (func_num_args() > 1) {
  31145. return $this->doExecute($command, $cwd, false, $output);
  31146. }
  31147. return $this->doExecute($command, $cwd, false);
  31148. }
  31149. public function executeTty($command, $cwd = null)
  31150. {
  31151. return $this->doExecute($command, $cwd, true);
  31152. }
  31153. private function doExecute($command, $cwd, $tty, &$output = null)
  31154. {
  31155. if ($this->io && $this->io->isDebug()) {
  31156. $safeCommand = preg_replace_callback('{://(?P<user>[^:/\s]+):(?P<password>[^@\s/]+)@}i', function ($m) {
  31157. if (preg_match('{^[a-f0-9]{12,}$}', $m['user'])) {
  31158. return '://***:***@';
  31159. }
  31160. return '://'.$m['user'].':***@';
  31161. }, $command);
  31162. $safeCommand = preg_replace("{--password (.*[^\\\\]\') }", '--password \'***\' ', $safeCommand);
  31163. $this->io->writeError('Executing command ('.($cwd ?: 'CWD').'): '.$safeCommand);
  31164. }
  31165. if (null === $cwd && Platform::isWindows() && false !== strpos($command, 'git') && getcwd()) {
  31166. $cwd = realpath(getcwd());
  31167. }
  31168. $this->captureOutput = func_num_args() > 3;
  31169. $this->errorOutput = null;
  31170. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  31171. $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout());
  31172. } else {
  31173. $process = new Process($command, $cwd, null, null, static::getTimeout());
  31174. }
  31175. if (!Platform::isWindows() && $tty) {
  31176. try {
  31177. $process->setTty(true);
  31178. } catch (RuntimeException $e) {
  31179. }
  31180. }
  31181. $callback = is_callable($output) ? $output : array($this, 'outputHandler');
  31182. $process->run($callback);
  31183. if ($this->captureOutput && !is_callable($output)) {
  31184. $output = $process->getOutput();
  31185. }
  31186. $this->errorOutput = $process->getErrorOutput();
  31187. return $process->getExitCode();
  31188. }
  31189. public function executeAsync($command, $cwd = null)
  31190. {
  31191. if (!$this->allowAsync) {
  31192. throw new \LogicException('You must use the ProcessExecutor instance which is part of a Composer\Loop instance to be able to run async processes');
  31193. }
  31194. $job = array(
  31195. 'id' => $this->idGen++,
  31196. 'status' => self::STATUS_QUEUED,
  31197. 'command' => $command,
  31198. 'cwd' => $cwd,
  31199. );
  31200. $resolver = function ($resolve, $reject) use (&$job) {
  31201. $job['status'] = ProcessExecutor::STATUS_QUEUED;
  31202. $job['resolve'] = $resolve;
  31203. $job['reject'] = $reject;
  31204. };
  31205. $self = $this;
  31206. $canceler = function () use (&$job) {
  31207. if ($job['status'] === ProcessExecutor::STATUS_QUEUED) {
  31208. $job['status'] = ProcessExecutor::STATUS_ABORTED;
  31209. }
  31210. if ($job['status'] !== ProcessExecutor::STATUS_STARTED) {
  31211. return;
  31212. }
  31213. $job['status'] = ProcessExecutor::STATUS_ABORTED;
  31214. try {
  31215. if (defined('SIGINT')) {
  31216. $job['process']->signal(SIGINT);
  31217. }
  31218. } catch (\Exception $e) {
  31219. }
  31220. $job['process']->stop(1);
  31221. };
  31222. $promise = new Promise($resolver, $canceler);
  31223. $promise = $promise->then(function () use (&$job, $self) {
  31224. if ($job['process']->isSuccessful()) {
  31225. $job['status'] = ProcessExecutor::STATUS_COMPLETED;
  31226. } else {
  31227. $job['status'] = ProcessExecutor::STATUS_FAILED;
  31228. }
  31229. $self->markJobDone();
  31230. return $job['process'];
  31231. }, function ($e) use (&$job, $self) {
  31232. $job['status'] = ProcessExecutor::STATUS_FAILED;
  31233. $self->markJobDone();
  31234. throw $e;
  31235. });
  31236. $this->jobs[$job['id']] =& $job;
  31237. if ($this->runningJobs < $this->maxJobs) {
  31238. $this->startJob($job['id']);
  31239. }
  31240. return $promise;
  31241. }
  31242. private function startJob($id)
  31243. {
  31244. $job =& $this->jobs[$id];
  31245. if ($job['status'] !== self::STATUS_QUEUED) {
  31246. return;
  31247. }
  31248. $job['status'] = self::STATUS_STARTED;
  31249. $this->runningJobs++;
  31250. $command = $job['command'];
  31251. $cwd = $job['cwd'];
  31252. if ($this->io && $this->io->isDebug()) {
  31253. $safeCommand = preg_replace_callback('{://(?P<user>[^:/\s]+):(?P<password>[^@\s/]+)@}i', function ($m) {
  31254. if (preg_match('{^[a-f0-9]{12,}$}', $m['user'])) {
  31255. return '://***:***@';
  31256. }
  31257. return '://'.$m['user'].':***@';
  31258. }, $command);
  31259. $safeCommand = preg_replace("{--password (.*[^\\\\]\') }", '--password \'***\' ', $safeCommand);
  31260. $this->io->writeError('Executing async command ('.($cwd ?: 'CWD').'): '.$safeCommand);
  31261. }
  31262. if (null === $cwd && Platform::isWindows() && false !== strpos($command, 'git') && getcwd()) {
  31263. $cwd = realpath(getcwd());
  31264. }
  31265. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  31266. $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout());
  31267. } else {
  31268. $process = new Process($command, $cwd, null, null, static::getTimeout());
  31269. }
  31270. $job['process'] = $process;
  31271. $process->start();
  31272. }
  31273. public function wait($index = null)
  31274. {
  31275. while (true) {
  31276. if (!$this->countActiveJobs($index)) {
  31277. return;
  31278. }
  31279. usleep(1000);
  31280. }
  31281. }
  31282. public function enableAsync()
  31283. {
  31284. $this->allowAsync = true;
  31285. }
  31286. public function countActiveJobs($index = null)
  31287. {
  31288. foreach ($this->jobs as $job) {
  31289. if ($job['status'] === self::STATUS_STARTED) {
  31290. if (!$job['process']->isRunning()) {
  31291. call_user_func($job['resolve'], $job['process']);
  31292. }
  31293. }
  31294. if ($this->runningJobs < $this->maxJobs) {
  31295. if ($job['status'] === self::STATUS_QUEUED) {
  31296. $this->startJob($job['id']);
  31297. }
  31298. }
  31299. }
  31300. if (null !== $index) {
  31301. return $this->jobs[$index]['status'] < self::STATUS_COMPLETED ? 1 : 0;
  31302. }
  31303. $active = 0;
  31304. foreach ($this->jobs as $job) {
  31305. if ($job['status'] < self::STATUS_COMPLETED) {
  31306. $active++;
  31307. } else {
  31308. unset($this->jobs[$job['id']]);
  31309. }
  31310. }
  31311. return $active;
  31312. }
  31313. public function markJobDone()
  31314. {
  31315. $this->runningJobs--;
  31316. }
  31317. public function splitLines($output)
  31318. {
  31319. $output = trim($output);
  31320. return ((string) $output === '') ? array() : preg_split('{\r?\n}', $output);
  31321. }
  31322. public function getErrorOutput()
  31323. {
  31324. return $this->errorOutput;
  31325. }
  31326. public function outputHandler($type, $buffer)
  31327. {
  31328. if ($this->captureOutput) {
  31329. return;
  31330. }
  31331. if (null === $this->io) {
  31332. echo $buffer;
  31333. return;
  31334. }
  31335. if (Process::ERR === $type) {
  31336. $this->io->writeErrorRaw($buffer, false);
  31337. } else {
  31338. $this->io->writeRaw($buffer, false);
  31339. }
  31340. }
  31341. public static function getTimeout()
  31342. {
  31343. return static::$timeout;
  31344. }
  31345. public static function setTimeout($timeout)
  31346. {
  31347. static::$timeout = $timeout;
  31348. }
  31349. public static function escape($argument)
  31350. {
  31351. return self::escapeArgument($argument);
  31352. }
  31353. private static function escapeArgument($argument)
  31354. {
  31355. if ('\\' === DIRECTORY_SEPARATOR) {
  31356. if ((string) $argument === '') {
  31357. return escapeshellarg($argument);
  31358. }
  31359. $escapedArgument = '';
  31360. $quote = false;
  31361. foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
  31362. if ('"' === $part) {
  31363. $escapedArgument .= '\\"';
  31364. } elseif (self::isSurroundedBy($part, '%')) {
  31365. $escapedArgument .= '^%"'.substr($part, 1, -1).'"^%';
  31366. } else {
  31367. if ('\\' === substr($part, -1)) {
  31368. $part .= '\\';
  31369. }
  31370. $quote = true;
  31371. $escapedArgument .= $part;
  31372. }
  31373. }
  31374. if ($quote) {
  31375. $escapedArgument = '"'.$escapedArgument.'"';
  31376. }
  31377. return $escapedArgument;
  31378. }
  31379. return "'".str_replace("'", "'\\''", $argument)."'";
  31380. }
  31381. private static function isSurroundedBy($arg, $char)
  31382. {
  31383. return 2 < strlen($arg) && $char === $arg[0] && $char === $arg[strlen($arg) - 1];
  31384. }
  31385. }
  31386. <?php
  31387. namespace Composer\Util;
  31388. use Composer\Config;
  31389. use Composer\Downloader\MaxFileSizeExceededException;
  31390. use Composer\IO\IOInterface;
  31391. use Composer\Downloader\TransportException;
  31392. use Composer\CaBundle\CaBundle;
  31393. use Composer\Util\Http\Response;
  31394. class RemoteFilesystem
  31395. {
  31396. private $io;
  31397. private $config;
  31398. private $scheme;
  31399. private $bytesMax;
  31400. private $originUrl;
  31401. private $fileUrl;
  31402. private $fileName;
  31403. private $retry;
  31404. private $progress;
  31405. private $lastProgress;
  31406. private $options = array();
  31407. private $peerCertificateMap = array();
  31408. private $disableTls = false;
  31409. private $lastHeaders;
  31410. private $storeAuth;
  31411. private $authHelper;
  31412. private $degradedMode = false;
  31413. private $redirects;
  31414. private $maxRedirects = 20;
  31415. public function __construct(IOInterface $io, Config $config, array $options = array(), $disableTls = false, AuthHelper $authHelper = null)
  31416. {
  31417. $this->io = $io;
  31418. if ($disableTls === false) {
  31419. $this->options = StreamContextFactory::getTlsDefaults($options, $io);
  31420. } else {
  31421. $this->disableTls = true;
  31422. }
  31423. $this->options = array_replace_recursive($this->options, $options);
  31424. $this->config = $config;
  31425. $this->authHelper = isset($authHelper) ? $authHelper : new AuthHelper($io, $config);
  31426. }
  31427. public function copy($originUrl, $fileUrl, $fileName, $progress = true, $options = array())
  31428. {
  31429. return $this->get($originUrl, $fileUrl, $options, $fileName, $progress);
  31430. }
  31431. public function getContents($originUrl, $fileUrl, $progress = true, $options = array())
  31432. {
  31433. return $this->get($originUrl, $fileUrl, $options, null, $progress);
  31434. }
  31435. public function getOptions()
  31436. {
  31437. return $this->options;
  31438. }
  31439. public function setOptions(array $options)
  31440. {
  31441. $this->options = array_replace_recursive($this->options, $options);
  31442. }
  31443. public function isTlsDisabled()
  31444. {
  31445. return $this->disableTls === true;
  31446. }
  31447. public function getLastHeaders()
  31448. {
  31449. return $this->lastHeaders;
  31450. }
  31451. public static function findStatusCode(array $headers)
  31452. {
  31453. $value = null;
  31454. foreach ($headers as $header) {
  31455. if (preg_match('{^HTTP/\S+ (\d+)}i', $header, $match)) {
  31456. $value = (int) $match[1];
  31457. }
  31458. }
  31459. return $value;
  31460. }
  31461. public function findStatusMessage(array $headers)
  31462. {
  31463. $value = null;
  31464. foreach ($headers as $header) {
  31465. if (preg_match('{^HTTP/\S+ \d+}i', $header)) {
  31466. $value = $header;
  31467. }
  31468. }
  31469. return $value;
  31470. }
  31471. protected function get($originUrl, $fileUrl, $additionalOptions = array(), $fileName = null, $progress = true)
  31472. {
  31473. $this->scheme = parse_url($fileUrl, PHP_URL_SCHEME);
  31474. $this->bytesMax = 0;
  31475. $this->originUrl = $originUrl;
  31476. $this->fileUrl = $fileUrl;
  31477. $this->fileName = $fileName;
  31478. $this->progress = $progress;
  31479. $this->lastProgress = null;
  31480. $retryAuthFailure = true;
  31481. $this->lastHeaders = array();
  31482. $this->redirects = 1;
  31483. $tempAdditionalOptions = $additionalOptions;
  31484. if (isset($tempAdditionalOptions['retry-auth-failure'])) {
  31485. $retryAuthFailure = (bool) $tempAdditionalOptions['retry-auth-failure'];
  31486. unset($tempAdditionalOptions['retry-auth-failure']);
  31487. }
  31488. $isRedirect = false;
  31489. if (isset($tempAdditionalOptions['redirects'])) {
  31490. $this->redirects = $tempAdditionalOptions['redirects'];
  31491. $isRedirect = true;
  31492. unset($tempAdditionalOptions['redirects']);
  31493. }
  31494. $options = $this->getOptionsForUrl($originUrl, $tempAdditionalOptions);
  31495. unset($tempAdditionalOptions);
  31496. $origFileUrl = $fileUrl;
  31497. if (isset($options['gitlab-token'])) {
  31498. $fileUrl .= (false === strpos($fileUrl, '?') ? '?' : '&') . 'access_token='.$options['gitlab-token'];
  31499. unset($options['gitlab-token']);
  31500. }
  31501. if (isset($options['http'])) {
  31502. $options['http']['ignore_errors'] = true;
  31503. }
  31504. if ($this->degradedMode && strpos($fileUrl, 'http://repo.packagist.org/') === 0) {
  31505. $fileUrl = 'http://' . gethostbyname('repo.packagist.org') . substr($fileUrl, 20);
  31506. $degradedPackagist = true;
  31507. }
  31508. $maxFileSize = null;
  31509. if (isset($options['max_file_size'])) {
  31510. $maxFileSize = $options['max_file_size'];
  31511. unset($options['max_file_size']);
  31512. }
  31513. $ctx = StreamContextFactory::getContext($fileUrl, $options, array('notification' => array($this, 'callbackGet')));
  31514. $actualContextOptions = stream_context_get_options($ctx);
  31515. $usingProxy = !empty($actualContextOptions['http']['proxy']) ? ' using proxy ' . $actualContextOptions['http']['proxy'] : '';
  31516. $this->io->writeError((strpos($origFileUrl, 'http') === 0 ? 'Downloading ' : 'Reading ') . Url::sanitize($origFileUrl) . $usingProxy, true, IOInterface::DEBUG);
  31517. unset($origFileUrl, $actualContextOptions);
  31518. if ((!preg_match('{^http://(repo\.)?packagist\.org/p/}', $fileUrl) || (false === strpos($fileUrl, '$') && false === strpos($fileUrl, '%24'))) && empty($degradedPackagist) && $this->config) {
  31519. $this->config->prohibitUrlByConfig($fileUrl, $this->io);
  31520. }
  31521. if ($this->progress && !$isRedirect) {
  31522. $this->io->writeError("Downloading (<comment>connecting...</comment>)", false);
  31523. }
  31524. $errorMessage = '';
  31525. $errorCode = 0;
  31526. $result = false;
  31527. set_error_handler(function ($code, $msg) use (&$errorMessage) {
  31528. if ($errorMessage) {
  31529. $errorMessage .= "\n";
  31530. }
  31531. $errorMessage .= preg_replace('{^file_get_contents\(.*?\): }', '', $msg);
  31532. return true;
  31533. });
  31534. $http_response_header = array();
  31535. try {
  31536. $result = $this->getRemoteContents($originUrl, $fileUrl, $ctx, $http_response_header, $maxFileSize);
  31537. if (!empty($http_response_header[0])) {
  31538. $statusCode = self::findStatusCode($http_response_header);
  31539. if ($statusCode >= 400 && Response::findHeaderValue($http_response_header, 'content-type') === 'application/json') {
  31540. HttpDownloader::outputWarnings($this->io, $originUrl, json_decode($result, true));
  31541. }
  31542. if (in_array($statusCode, array(401, 403)) && $retryAuthFailure) {
  31543. $this->promptAuthAndRetry($statusCode, $this->findStatusMessage($http_response_header), $http_response_header);
  31544. }
  31545. }
  31546. $contentLength = !empty($http_response_header[0]) ? Response::findHeaderValue($http_response_header, 'content-length') : null;
  31547. if ($contentLength && Platform::strlen($result) < $contentLength) {
  31548. $e = new TransportException('Content-Length mismatch, received '.Platform::strlen($result).' bytes out of the expected '.$contentLength);
  31549. $e->setHeaders($http_response_header);
  31550. $e->setStatusCode(self::findStatusCode($http_response_header));
  31551. try {
  31552. $e->setResponse($this->decodeResult($result, $http_response_header));
  31553. } catch (\Exception $e) {
  31554. $e->setResponse($result);
  31555. }
  31556. $this->io->writeError('Content-Length mismatch, received '.Platform::strlen($result).' out of '.$contentLength.' bytes: (' . base64_encode($result).')', true, IOInterface::DEBUG);
  31557. throw $e;
  31558. }
  31559. if (PHP_VERSION_ID < 50600 && !empty($options['ssl']['peer_fingerprint'])) {
  31560. $params = stream_context_get_params($ctx);
  31561. $expectedPeerFingerprint = $options['ssl']['peer_fingerprint'];
  31562. $peerFingerprint = TlsHelper::getCertificateFingerprint($params['options']['ssl']['peer_certificate']);
  31563. if ($expectedPeerFingerprint !== $peerFingerprint) {
  31564. throw new TransportException('Peer fingerprint did not match');
  31565. }
  31566. }
  31567. } catch (\Exception $e) {
  31568. if ($e instanceof TransportException && !empty($http_response_header[0])) {
  31569. $e->setHeaders($http_response_header);
  31570. $e->setStatusCode(self::findStatusCode($http_response_header));
  31571. }
  31572. if ($e instanceof TransportException && $result !== false) {
  31573. $e->setResponse($this->decodeResult($result, $http_response_header));
  31574. }
  31575. $result = false;
  31576. }
  31577. if ($errorMessage && !filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN)) {
  31578. $errorMessage = 'allow_url_fopen must be enabled in php.ini ('.$errorMessage.')';
  31579. }
  31580. restore_error_handler();
  31581. if (isset($e) && !$this->retry) {
  31582. if (!$this->degradedMode && false !== strpos($e->getMessage(), 'Operation timed out')) {
  31583. $this->degradedMode = true;
  31584. $this->io->writeError('');
  31585. $this->io->writeError(array(
  31586. '<error>'.$e->getMessage().'</error>',
  31587. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  31588. ));
  31589. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  31590. }
  31591. throw $e;
  31592. }
  31593. $statusCode = null;
  31594. $contentType = null;
  31595. $locationHeader = null;
  31596. if (!empty($http_response_header[0])) {
  31597. $statusCode = self::findStatusCode($http_response_header);
  31598. $contentType = Response::findHeaderValue($http_response_header, 'content-type');
  31599. $locationHeader = Response::findHeaderValue($http_response_header, 'location');
  31600. }
  31601. if ($originUrl === 'bitbucket.org'
  31602. && !$this->authHelper->isPublicBitBucketDownload($fileUrl)
  31603. && substr($fileUrl, -4) === '.zip'
  31604. && (!$locationHeader || substr(parse_url($locationHeader, PHP_URL_PATH), -4) !== '.zip')
  31605. && $contentType && preg_match('{^text/html\b}i', $contentType)
  31606. ) {
  31607. $result = false;
  31608. if ($retryAuthFailure) {
  31609. $this->promptAuthAndRetry(401);
  31610. }
  31611. }
  31612. if ($statusCode === 404
  31613. && $this->config && in_array($originUrl, $this->config->get('gitlab-domains'), true)
  31614. && false !== strpos($fileUrl, 'archive.zip')
  31615. ) {
  31616. $result = false;
  31617. if ($retryAuthFailure) {
  31618. $this->promptAuthAndRetry(401);
  31619. }
  31620. }
  31621. $hasFollowedRedirect = false;
  31622. if ($statusCode >= 300 && $statusCode <= 399 && $statusCode !== 304 && $this->redirects < $this->maxRedirects) {
  31623. $hasFollowedRedirect = true;
  31624. $result = $this->handleRedirect($http_response_header, $additionalOptions, $result);
  31625. }
  31626. if ($statusCode && $statusCode >= 400 && $statusCode <= 599) {
  31627. if (!$this->retry) {
  31628. if ($this->progress && !$isRedirect) {
  31629. $this->io->overwriteError("Downloading (<error>failed</error>)", false);
  31630. }
  31631. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded ('.$http_response_header[0].')', $statusCode);
  31632. $e->setHeaders($http_response_header);
  31633. $e->setResponse($this->decodeResult($result, $http_response_header));
  31634. $e->setStatusCode($statusCode);
  31635. throw $e;
  31636. }
  31637. $result = false;
  31638. }
  31639. if ($this->progress && !$this->retry && !$isRedirect) {
  31640. $this->io->overwriteError("Downloading (".($result === false ? '<error>failed</error>' : '<comment>100%</comment>').")", false);
  31641. }
  31642. if ($result && extension_loaded('zlib') && strpos($fileUrl, 'http') === 0 && !$hasFollowedRedirect) {
  31643. try {
  31644. $result = $this->decodeResult($result, $http_response_header);
  31645. } catch (\Exception $e) {
  31646. if ($this->degradedMode) {
  31647. throw $e;
  31648. }
  31649. $this->degradedMode = true;
  31650. $this->io->writeError(array(
  31651. '',
  31652. '<error>Failed to decode response: '.$e->getMessage().'</error>',
  31653. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  31654. ));
  31655. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  31656. }
  31657. }
  31658. if (false !== $result && null !== $fileName && !$isRedirect) {
  31659. if ('' === $result) {
  31660. throw new TransportException('"'.$this->fileUrl.'" appears broken, and returned an empty 200 response');
  31661. }
  31662. $errorMessage = '';
  31663. set_error_handler(function ($code, $msg) use (&$errorMessage) {
  31664. if ($errorMessage) {
  31665. $errorMessage .= "\n";
  31666. }
  31667. $errorMessage .= preg_replace('{^file_put_contents\(.*?\): }', '', $msg);
  31668. return true;
  31669. });
  31670. $result = (bool) file_put_contents($fileName, $result);
  31671. restore_error_handler();
  31672. if (false === $result) {
  31673. throw new TransportException('The "'.$this->fileUrl.'" file could not be written to '.$fileName.': '.$errorMessage);
  31674. }
  31675. }
  31676. if (false === $result && false !== strpos($errorMessage, 'Peer certificate') && PHP_VERSION_ID < 50600) {
  31677. if (CaBundle::isOpensslParseSafe()) {
  31678. $certDetails = $this->getCertificateCnAndFp($this->fileUrl, $options);
  31679. if ($certDetails) {
  31680. $this->peerCertificateMap[$this->getUrlAuthority($this->fileUrl)] = $certDetails;
  31681. $this->retry = true;
  31682. }
  31683. } else {
  31684. $this->io->writeError('');
  31685. $this->io->writeError(sprintf(
  31686. '<error>Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.</error>',
  31687. PHP_VERSION
  31688. ));
  31689. }
  31690. }
  31691. if ($this->retry) {
  31692. $this->retry = false;
  31693. $result = $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  31694. if ($this->storeAuth && $this->config) {
  31695. $this->authHelper->storeAuth($this->originUrl, $this->storeAuth);
  31696. $this->storeAuth = false;
  31697. }
  31698. return $result;
  31699. }
  31700. if (false === $result) {
  31701. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded: '.$errorMessage, $errorCode);
  31702. if (!empty($http_response_header[0])) {
  31703. $e->setHeaders($http_response_header);
  31704. }
  31705. if (!$this->degradedMode && false !== strpos($e->getMessage(), 'Operation timed out')) {
  31706. $this->degradedMode = true;
  31707. $this->io->writeError('');
  31708. $this->io->writeError(array(
  31709. '<error>'.$e->getMessage().'</error>',
  31710. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  31711. ));
  31712. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  31713. }
  31714. throw $e;
  31715. }
  31716. if (!empty($http_response_header[0])) {
  31717. $this->lastHeaders = $http_response_header;
  31718. }
  31719. return $result;
  31720. }
  31721. protected function getRemoteContents($originUrl, $fileUrl, $context, array &$responseHeaders = null, $maxFileSize = null)
  31722. {
  31723. $result = false;
  31724. try {
  31725. $e = null;
  31726. if ($maxFileSize !== null) {
  31727. $result = file_get_contents($fileUrl, false, $context, 0, $maxFileSize);
  31728. } else {
  31729. $result = file_get_contents($fileUrl, false, $context);
  31730. }
  31731. } catch (\Throwable $e) {
  31732. } catch (\Exception $e) {
  31733. }
  31734. if ($maxFileSize !== null && Platform::strlen($result) >= $maxFileSize) {
  31735. throw new MaxFileSizeExceededException('Maximum allowed download size reached. Downloaded ' . Platform::strlen($result) . ' of allowed ' . $maxFileSize . ' bytes');
  31736. }
  31737. $responseHeaders = isset($http_response_header) ? $http_response_header : array();
  31738. if (null !== $e) {
  31739. throw $e;
  31740. }
  31741. return $result;
  31742. }
  31743. protected function callbackGet($notificationCode, $severity, $message, $messageCode, $bytesTransferred, $bytesMax)
  31744. {
  31745. switch ($notificationCode) {
  31746. case STREAM_NOTIFY_FAILURE:
  31747. if (400 === $messageCode) {
  31748. throw new TransportException("The '" . $this->fileUrl . "' URL could not be accessed: " . $message, $messageCode);
  31749. }
  31750. break;
  31751. case STREAM_NOTIFY_FILE_SIZE_IS:
  31752. $this->bytesMax = $bytesMax;
  31753. break;
  31754. case STREAM_NOTIFY_PROGRESS:
  31755. if ($this->bytesMax > 0 && $this->progress) {
  31756. $progression = min(100, round($bytesTransferred / $this->bytesMax * 100));
  31757. if ((0 === $progression % 5) && 100 !== $progression && $progression !== $this->lastProgress) {
  31758. $this->lastProgress = $progression;
  31759. $this->io->overwriteError("Downloading (<comment>$progression%</comment>)", false);
  31760. }
  31761. }
  31762. break;
  31763. default:
  31764. break;
  31765. }
  31766. }
  31767. protected function promptAuthAndRetry($httpStatus, $reason = null, $headers = array())
  31768. {
  31769. $result = $this->authHelper->promptAuthIfNeeded($this->fileUrl, $this->originUrl, $httpStatus, $reason, $headers);
  31770. $this->storeAuth = $result['storeAuth'];
  31771. $this->retry = $result['retry'];
  31772. if ($this->retry) {
  31773. throw new TransportException('RETRY');
  31774. }
  31775. }
  31776. protected function getOptionsForUrl($originUrl, $additionalOptions)
  31777. {
  31778. $tlsOptions = array();
  31779. if ($this->disableTls === false && PHP_VERSION_ID < 50600 && !stream_is_local($this->fileUrl)) {
  31780. $host = parse_url($this->fileUrl, PHP_URL_HOST);
  31781. if (PHP_VERSION_ID < 50304) {
  31782. if ($host === 'github.com' || $host === 'api.github.com') {
  31783. $host = '*.github.com';
  31784. }
  31785. }
  31786. $tlsOptions['ssl']['CN_match'] = $host;
  31787. $tlsOptions['ssl']['SNI_server_name'] = $host;
  31788. $urlAuthority = $this->getUrlAuthority($this->fileUrl);
  31789. if (isset($this->peerCertificateMap[$urlAuthority])) {
  31790. $certMap = $this->peerCertificateMap[$urlAuthority];
  31791. $this->io->writeError('', true, IOInterface::DEBUG);
  31792. $this->io->writeError(sprintf(
  31793. 'Using <info>%s</info> as CN for subjectAltName enabled host <info>%s</info>',
  31794. $certMap['cn'],
  31795. $urlAuthority
  31796. ), true, IOInterface::DEBUG);
  31797. $tlsOptions['ssl']['CN_match'] = $certMap['cn'];
  31798. $tlsOptions['ssl']['peer_fingerprint'] = $certMap['fp'];
  31799. } elseif (!CaBundle::isOpensslParseSafe() && $host === 'repo.packagist.org') {
  31800. $tlsOptions['ssl']['CN_match'] = 'packagist.org';
  31801. }
  31802. }
  31803. $headers = array();
  31804. if (extension_loaded('zlib')) {
  31805. $headers[] = 'Accept-Encoding: gzip';
  31806. }
  31807. $options = array_replace_recursive($this->options, $tlsOptions, $additionalOptions);
  31808. if (!$this->degradedMode) {
  31809. $options['http']['protocol_version'] = 1.1;
  31810. $headers[] = 'Connection: close';
  31811. }
  31812. $headers = $this->authHelper->addAuthenticationHeader($headers, $originUrl, $this->fileUrl);
  31813. $options['http']['follow_location'] = 0;
  31814. if (isset($options['http']['header']) && !is_array($options['http']['header'])) {
  31815. $options['http']['header'] = explode("\r\n", trim($options['http']['header'], "\r\n"));
  31816. }
  31817. foreach ($headers as $header) {
  31818. $options['http']['header'][] = $header;
  31819. }
  31820. return $options;
  31821. }
  31822. private function handleRedirect(array $http_response_header, array $additionalOptions, $result)
  31823. {
  31824. if ($locationHeader = Response::findHeaderValue($http_response_header, 'location')) {
  31825. if (parse_url($locationHeader, PHP_URL_SCHEME)) {
  31826. $targetUrl = $locationHeader;
  31827. } elseif (parse_url($locationHeader, PHP_URL_HOST)) {
  31828. $targetUrl = $this->scheme.':'.$locationHeader;
  31829. } elseif ('/' === $locationHeader[0]) {
  31830. $urlHost = parse_url($this->fileUrl, PHP_URL_HOST);
  31831. $targetUrl = preg_replace('{^(.+(?://|@)'.preg_quote($urlHost).'(?::\d+)?)(?:[/\?].*)?$}', '\1'.$locationHeader, $this->fileUrl);
  31832. } else {
  31833. $targetUrl = preg_replace('{^(.+/)[^/?]*(?:\?.*)?$}', '\1'.$locationHeader, $this->fileUrl);
  31834. }
  31835. }
  31836. if (!empty($targetUrl)) {
  31837. $this->redirects++;
  31838. $this->io->writeError('', true, IOInterface::DEBUG);
  31839. $this->io->writeError(sprintf('Following redirect (%u) %s', $this->redirects, Url::sanitize($targetUrl)), true, IOInterface::DEBUG);
  31840. $additionalOptions['redirects'] = $this->redirects;
  31841. return $this->get(parse_url($targetUrl, PHP_URL_HOST), $targetUrl, $additionalOptions, $this->fileName, $this->progress);
  31842. }
  31843. if (!$this->retry) {
  31844. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded, got redirect without Location ('.$http_response_header[0].')');
  31845. $e->setHeaders($http_response_header);
  31846. $e->setResponse($this->decodeResult($result, $http_response_header));
  31847. throw $e;
  31848. }
  31849. return false;
  31850. }
  31851. private function getCertificateCnAndFp($url, $options)
  31852. {
  31853. if (PHP_VERSION_ID >= 50600) {
  31854. throw new \BadMethodCallException(sprintf(
  31855. '%s must not be used on PHP >= 5.6',
  31856. __METHOD__
  31857. ));
  31858. }
  31859. $context = StreamContextFactory::getContext($url, $options, array('options' => array(
  31860. 'ssl' => array(
  31861. 'capture_peer_cert' => true,
  31862. 'verify_peer' => false,
  31863. ), ),
  31864. ));
  31865. if (false === $handle = @fopen($url, 'rb', false, $context)) {
  31866. return;
  31867. }
  31868. fclose($handle);
  31869. $handle = null;
  31870. $params = stream_context_get_params($context);
  31871. if (!empty($params['options']['ssl']['peer_certificate'])) {
  31872. $peerCertificate = $params['options']['ssl']['peer_certificate'];
  31873. if (TlsHelper::checkCertificateHost($peerCertificate, parse_url($url, PHP_URL_HOST), $commonName)) {
  31874. return array(
  31875. 'cn' => $commonName,
  31876. 'fp' => TlsHelper::getCertificateFingerprint($peerCertificate),
  31877. );
  31878. }
  31879. }
  31880. }
  31881. private function getUrlAuthority($url)
  31882. {
  31883. $defaultPorts = array(
  31884. 'ftp' => 21,
  31885. 'http' => 80,
  31886. 'https' => 443,
  31887. 'ssh2.sftp' => 22,
  31888. 'ssh2.scp' => 22,
  31889. );
  31890. $scheme = parse_url($url, PHP_URL_SCHEME);
  31891. if (!isset($defaultPorts[$scheme])) {
  31892. throw new \InvalidArgumentException(sprintf(
  31893. 'Could not get default port for unknown scheme: %s',
  31894. $scheme
  31895. ));
  31896. }
  31897. $defaultPort = $defaultPorts[$scheme];
  31898. $port = parse_url($url, PHP_URL_PORT) ?: $defaultPort;
  31899. return parse_url($url, PHP_URL_HOST).':'.$port;
  31900. }
  31901. private function decodeResult($result, $http_response_header)
  31902. {
  31903. if ($result && extension_loaded('zlib')) {
  31904. $contentEncoding = Response::findHeaderValue($http_response_header, 'content-encoding');
  31905. $decode = $contentEncoding && 'gzip' === strtolower($contentEncoding);
  31906. if ($decode) {
  31907. if (PHP_VERSION_ID >= 50400) {
  31908. $result = zlib_decode($result);
  31909. } else {
  31910. $result = file_get_contents('compress.zlib://data:application/octet-stream;base64,'.base64_encode($result));
  31911. }
  31912. if (!$result) {
  31913. throw new TransportException('Failed to decode zlib stream');
  31914. }
  31915. }
  31916. }
  31917. return $result;
  31918. }
  31919. }
  31920. <?php
  31921. namespace Composer\Util;
  31922. class Silencer
  31923. {
  31924. private static $stack = array();
  31925. public static function suppress($mask = null)
  31926. {
  31927. if (!isset($mask)) {
  31928. $mask = E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_DEPRECATED | E_USER_DEPRECATED | E_STRICT;
  31929. }
  31930. $old = error_reporting();
  31931. self::$stack[] = $old;
  31932. error_reporting($old & ~$mask);
  31933. return $old;
  31934. }
  31935. public static function restore()
  31936. {
  31937. if (!empty(self::$stack)) {
  31938. error_reporting(array_pop(self::$stack));
  31939. }
  31940. }
  31941. public static function call($callable )
  31942. {
  31943. try {
  31944. self::suppress();
  31945. $result = call_user_func_array($callable, array_slice(func_get_args(), 1));
  31946. self::restore();
  31947. return $result;
  31948. } catch (\Exception $e) {
  31949. self::restore();
  31950. throw $e;
  31951. }
  31952. }
  31953. }
  31954. <?php
  31955. namespace Composer\Util;
  31956. use Composer\Composer;
  31957. use Composer\CaBundle\CaBundle;
  31958. use Composer\Downloader\TransportException;
  31959. use Psr\Log\LoggerInterface;
  31960. final class StreamContextFactory
  31961. {
  31962. public static function getContext($url, array $defaultOptions = array(), array $defaultParams = array())
  31963. {
  31964. $options = array('http' => array(
  31965. 'follow_location' => 1,
  31966. 'max_redirects' => 20,
  31967. ));
  31968. $options = array_replace_recursive($options, self::initOptions($url, $defaultOptions));
  31969. unset($defaultOptions['http']['header']);
  31970. $options = array_replace_recursive($options, $defaultOptions);
  31971. if (isset($options['http']['header'])) {
  31972. $options['http']['header'] = self::fixHttpHeaderField($options['http']['header']);
  31973. }
  31974. return stream_context_create($options, $defaultParams);
  31975. }
  31976. public static function initOptions($url, array $options)
  31977. {
  31978. if (!isset($options['http']['header'])) {
  31979. $options['http']['header'] = array();
  31980. }
  31981. if (is_string($options['http']['header'])) {
  31982. $options['http']['header'] = explode("\r\n", $options['http']['header']);
  31983. }
  31984. if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') && (!empty($_SERVER['HTTP_PROXY']) || !empty($_SERVER['http_proxy']))) {
  31985. $proxy = parse_url(!empty($_SERVER['http_proxy']) ? $_SERVER['http_proxy'] : $_SERVER['HTTP_PROXY']);
  31986. }
  31987. if (!empty($_SERVER['CGI_HTTP_PROXY'])) {
  31988. $proxy = parse_url($_SERVER['CGI_HTTP_PROXY']);
  31989. }
  31990. if (preg_match('{^https://}i', $url) && (!empty($_SERVER['HTTPS_PROXY']) || !empty($_SERVER['https_proxy']))) {
  31991. $proxy = parse_url(!empty($_SERVER['https_proxy']) ? $_SERVER['https_proxy'] : $_SERVER['HTTPS_PROXY']);
  31992. }
  31993. if (!empty($_SERVER['NO_PROXY']) || !empty($_SERVER['no_proxy']) && parse_url($url, PHP_URL_HOST)) {
  31994. $pattern = new NoProxyPattern(!empty($_SERVER['no_proxy']) ? $_SERVER['no_proxy'] : $_SERVER['NO_PROXY']);
  31995. if ($pattern->test($url)) {
  31996. unset($proxy);
  31997. }
  31998. }
  31999. if (!empty($proxy)) {
  32000. $proxyURL = isset($proxy['scheme']) ? $proxy['scheme'] . '://' : '';
  32001. $proxyURL .= isset($proxy['host']) ? $proxy['host'] : '';
  32002. if (isset($proxy['port'])) {
  32003. $proxyURL .= ":" . $proxy['port'];
  32004. } elseif (strpos($proxyURL, 'http://') === 0) {
  32005. $proxyURL .= ":80";
  32006. } elseif (strpos($proxyURL, 'https://') === 0) {
  32007. $proxyURL .= ":443";
  32008. }
  32009. $proxyURL = str_replace(array('http://', 'https://'), array('tcp://', 'ssl://'), $proxyURL);
  32010. if (0 === strpos($proxyURL, 'ssl:') && !extension_loaded('openssl')) {
  32011. throw new \RuntimeException('You must enable the openssl extension to use a proxy over https');
  32012. }
  32013. $options['http']['proxy'] = $proxyURL;
  32014. switch (parse_url($url, PHP_URL_SCHEME)) {
  32015. case 'http':
  32016. $reqFullUriEnv = getenv('HTTP_PROXY_REQUEST_FULLURI');
  32017. if ($reqFullUriEnv === false || $reqFullUriEnv === '' || (strtolower($reqFullUriEnv) !== 'false' && (bool) $reqFullUriEnv)) {
  32018. $options['http']['request_fulluri'] = true;
  32019. }
  32020. break;
  32021. case 'https':
  32022. $reqFullUriEnv = getenv('HTTPS_PROXY_REQUEST_FULLURI');
  32023. if (strtolower($reqFullUriEnv) !== 'false' && (bool) $reqFullUriEnv) {
  32024. $options['http']['request_fulluri'] = true;
  32025. }
  32026. break;
  32027. }
  32028. if ('https' === parse_url($url, PHP_URL_SCHEME)) {
  32029. $options['ssl']['SNI_enabled'] = true;
  32030. if (PHP_VERSION_ID < 50600) {
  32031. $options['ssl']['SNI_server_name'] = parse_url($url, PHP_URL_HOST);
  32032. }
  32033. }
  32034. if (isset($proxy['user'])) {
  32035. $auth = rawurldecode($proxy['user']);
  32036. if (isset($proxy['pass'])) {
  32037. $auth .= ':' . rawurldecode($proxy['pass']);
  32038. }
  32039. $auth = base64_encode($auth);
  32040. $options['http']['header'][] = "Proxy-Authorization: Basic {$auth}";
  32041. }
  32042. }
  32043. if (defined('HHVM_VERSION')) {
  32044. $phpVersion = 'HHVM ' . HHVM_VERSION;
  32045. } else {
  32046. $phpVersion = 'PHP ' . PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
  32047. }
  32048. if (extension_loaded('curl')) {
  32049. $curl = curl_version();
  32050. $httpVersion = 'curl '.$curl['version'];
  32051. } else {
  32052. $httpVersion = 'streams';
  32053. }
  32054. if (!isset($options['http']['header']) || false === stripos(implode('', $options['http']['header']), 'user-agent')) {
  32055. $options['http']['header'][] = sprintf(
  32056. 'User-Agent: Composer/%s (%s; %s; %s; %s%s)',
  32057. Composer::getVersion(),
  32058. function_exists('php_uname') ? php_uname('s') : 'Unknown',
  32059. function_exists('php_uname') ? php_uname('r') : 'Unknown',
  32060. $phpVersion,
  32061. $httpVersion,
  32062. getenv('CI') ? '; CI' : ''
  32063. );
  32064. }
  32065. return $options;
  32066. }
  32067. public static function getTlsDefaults(array $options, LoggerInterface $logger = null)
  32068. {
  32069. $ciphers = implode(':', array(
  32070. 'ECDHE-RSA-AES128-GCM-SHA256',
  32071. 'ECDHE-ECDSA-AES128-GCM-SHA256',
  32072. 'ECDHE-RSA-AES256-GCM-SHA384',
  32073. 'ECDHE-ECDSA-AES256-GCM-SHA384',
  32074. 'DHE-RSA-AES128-GCM-SHA256',
  32075. 'DHE-DSS-AES128-GCM-SHA256',
  32076. 'kEDH+AESGCM',
  32077. 'ECDHE-RSA-AES128-SHA256',
  32078. 'ECDHE-ECDSA-AES128-SHA256',
  32079. 'ECDHE-RSA-AES128-SHA',
  32080. 'ECDHE-ECDSA-AES128-SHA',
  32081. 'ECDHE-RSA-AES256-SHA384',
  32082. 'ECDHE-ECDSA-AES256-SHA384',
  32083. 'ECDHE-RSA-AES256-SHA',
  32084. 'ECDHE-ECDSA-AES256-SHA',
  32085. 'DHE-RSA-AES128-SHA256',
  32086. 'DHE-RSA-AES128-SHA',
  32087. 'DHE-DSS-AES128-SHA256',
  32088. 'DHE-RSA-AES256-SHA256',
  32089. 'DHE-DSS-AES256-SHA',
  32090. 'DHE-RSA-AES256-SHA',
  32091. 'AES128-GCM-SHA256',
  32092. 'AES256-GCM-SHA384',
  32093. 'AES128-SHA256',
  32094. 'AES256-SHA256',
  32095. 'AES128-SHA',
  32096. 'AES256-SHA',
  32097. 'AES',
  32098. 'CAMELLIA',
  32099. 'DES-CBC3-SHA',
  32100. '!aNULL',
  32101. '!eNULL',
  32102. '!EXPORT',
  32103. '!DES',
  32104. '!RC4',
  32105. '!MD5',
  32106. '!PSK',
  32107. '!aECDH',
  32108. '!EDH-DSS-DES-CBC3-SHA',
  32109. '!EDH-RSA-DES-CBC3-SHA',
  32110. '!KRB5-DES-CBC3-SHA',
  32111. ));
  32112. $defaults = array(
  32113. 'ssl' => array(
  32114. 'ciphers' => $ciphers,
  32115. 'verify_peer' => true,
  32116. 'verify_depth' => 7,
  32117. 'SNI_enabled' => true,
  32118. 'capture_peer_cert' => true,
  32119. ),
  32120. );
  32121. if (isset($options['ssl'])) {
  32122. $defaults['ssl'] = array_replace_recursive($defaults['ssl'], $options['ssl']);
  32123. }
  32124. if (!isset($defaults['ssl']['cafile']) && !isset($defaults['ssl']['capath'])) {
  32125. $result = CaBundle::getSystemCaRootBundlePath($logger);
  32126. if (is_dir($result)) {
  32127. $defaults['ssl']['capath'] = $result;
  32128. } else {
  32129. $defaults['ssl']['cafile'] = $result;
  32130. }
  32131. }
  32132. if (isset($defaults['ssl']['cafile']) && (!is_readable($defaults['ssl']['cafile']) || !CaBundle::validateCaFile($defaults['ssl']['cafile'], $logger))) {
  32133. throw new TransportException('The configured cafile was not valid or could not be read.');
  32134. }
  32135. if (isset($defaults['ssl']['capath']) && (!is_dir($defaults['ssl']['capath']) || !is_readable($defaults['ssl']['capath']))) {
  32136. throw new TransportException('The configured capath was not valid or could not be read.');
  32137. }
  32138. if (PHP_VERSION_ID >= 50413) {
  32139. $defaults['ssl']['disable_compression'] = true;
  32140. }
  32141. return $defaults;
  32142. }
  32143. private static function fixHttpHeaderField($header)
  32144. {
  32145. if (!is_array($header)) {
  32146. $header = explode("\r\n", $header);
  32147. }
  32148. uasort($header, function ($el) {
  32149. return stripos($el, 'content-type') === 0 ? 1 : -1;
  32150. });
  32151. return $header;
  32152. }
  32153. }
  32154. <?php
  32155. namespace Composer\Util;
  32156. use Composer\Config;
  32157. use Composer\IO\IOInterface;
  32158. class Svn
  32159. {
  32160. const MAX_QTY_AUTH_TRIES = 5;
  32161. protected $credentials;
  32162. protected $hasAuth;
  32163. protected $io;
  32164. protected $url;
  32165. protected $cacheCredentials = true;
  32166. protected $process;
  32167. protected $qtyAuthTries = 0;
  32168. protected $config;
  32169. private static $version;
  32170. public function __construct($url, IOInterface $io, Config $config, ProcessExecutor $process = null)
  32171. {
  32172. $this->url = $url;
  32173. $this->io = $io;
  32174. $this->config = $config;
  32175. $this->process = $process ?: new ProcessExecutor($io);
  32176. }
  32177. public static function cleanEnv()
  32178. {
  32179. putenv("DYLD_LIBRARY_PATH");
  32180. unset($_SERVER['DYLD_LIBRARY_PATH']);
  32181. }
  32182. public function execute($command, $url, $cwd = null, $path = null, $verbose = false)
  32183. {
  32184. $this->config->prohibitUrlByConfig($url, $this->io);
  32185. return $this->executeWithAuthRetry($command, $cwd, $url, $path, $verbose);
  32186. }
  32187. public function executeLocal($command, $path, $cwd = null, $verbose = false)
  32188. {
  32189. return $this->executeWithAuthRetry($command, $cwd, '', $path, $verbose);
  32190. }
  32191. private function executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose)
  32192. {
  32193. $command = $this->getCommand($svnCommand, $url, $path);
  32194. $output = null;
  32195. $io = $this->io;
  32196. $handler = function ($type, $buffer) use (&$output, $io, $verbose) {
  32197. if ($type !== 'out') {
  32198. return;
  32199. }
  32200. if (strpos($buffer, 'Redirecting to URL ') === 0) {
  32201. return;
  32202. }
  32203. $output .= $buffer;
  32204. if ($verbose) {
  32205. $io->writeError($buffer, false);
  32206. }
  32207. };
  32208. $status = $this->process->execute($command, $handler, $cwd);
  32209. if (0 === $status) {
  32210. return $output;
  32211. }
  32212. $errorOutput = $this->process->getErrorOutput();
  32213. $fullOutput = implode("\n", array($output, $errorOutput));
  32214. if (false === stripos($fullOutput, 'Could not authenticate to server:')
  32215. && false === stripos($fullOutput, 'authorization failed')
  32216. && false === stripos($fullOutput, 'svn: E170001:')
  32217. && false === stripos($fullOutput, 'svn: E215004:')) {
  32218. throw new \RuntimeException($fullOutput);
  32219. }
  32220. if (!$this->hasAuth()) {
  32221. $this->doAuthDance();
  32222. }
  32223. if ($this->qtyAuthTries++ < self::MAX_QTY_AUTH_TRIES) {
  32224. return $this->executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose);
  32225. }
  32226. throw new \RuntimeException(
  32227. 'wrong credentials provided ('.$fullOutput.')'
  32228. );
  32229. }
  32230. public function setCacheCredentials($cacheCredentials)
  32231. {
  32232. $this->cacheCredentials = $cacheCredentials;
  32233. }
  32234. protected function doAuthDance()
  32235. {
  32236. if (!$this->io->isInteractive()) {
  32237. throw new \RuntimeException(
  32238. 'can not ask for authentication in non interactive mode'
  32239. );
  32240. }
  32241. $this->io->writeError("The Subversion server ({$this->url}) requested credentials:");
  32242. $this->hasAuth = true;
  32243. $this->credentials['username'] = $this->io->ask("Username: ");
  32244. $this->credentials['password'] = $this->io->askAndHideAnswer("Password: ");
  32245. $this->cacheCredentials = $this->io->askConfirmation("Should Subversion cache these credentials? (yes/no) ");
  32246. return $this;
  32247. }
  32248. protected function getCommand($cmd, $url, $path = null)
  32249. {
  32250. $cmd = sprintf(
  32251. '%s %s%s %s',
  32252. $cmd,
  32253. '--non-interactive ',
  32254. $this->getCredentialString(),
  32255. ProcessExecutor::escape($url)
  32256. );
  32257. if ($path) {
  32258. $cmd .= ' ' . ProcessExecutor::escape($path);
  32259. }
  32260. return $cmd;
  32261. }
  32262. protected function getCredentialString()
  32263. {
  32264. if (!$this->hasAuth()) {
  32265. return '';
  32266. }
  32267. return sprintf(
  32268. ' %s--username %s --password %s ',
  32269. $this->getAuthCache(),
  32270. ProcessExecutor::escape($this->getUsername()),
  32271. ProcessExecutor::escape($this->getPassword())
  32272. );
  32273. }
  32274. protected function getPassword()
  32275. {
  32276. if ($this->credentials === null) {
  32277. throw new \LogicException("No svn auth detected.");
  32278. }
  32279. return isset($this->credentials['password']) ? $this->credentials['password'] : '';
  32280. }
  32281. protected function getUsername()
  32282. {
  32283. if ($this->credentials === null) {
  32284. throw new \LogicException("No svn auth detected.");
  32285. }
  32286. return $this->credentials['username'];
  32287. }
  32288. protected function hasAuth()
  32289. {
  32290. if (null !== $this->hasAuth) {
  32291. return $this->hasAuth;
  32292. }
  32293. if (false === $this->createAuthFromConfig()) {
  32294. $this->createAuthFromUrl();
  32295. }
  32296. return (bool) $this->hasAuth;
  32297. }
  32298. protected function getAuthCache()
  32299. {
  32300. return $this->cacheCredentials ? '' : '--no-auth-cache ';
  32301. }
  32302. private function createAuthFromConfig()
  32303. {
  32304. if (!$this->config->has('http-basic')) {
  32305. return $this->hasAuth = false;
  32306. }
  32307. $authConfig = $this->config->get('http-basic');
  32308. $host = parse_url($this->url, PHP_URL_HOST);
  32309. if (isset($authConfig[$host])) {
  32310. $this->credentials['username'] = $authConfig[$host]['username'];
  32311. $this->credentials['password'] = $authConfig[$host]['password'];
  32312. return $this->hasAuth = true;
  32313. }
  32314. return $this->hasAuth = false;
  32315. }
  32316. private function createAuthFromUrl()
  32317. {
  32318. $uri = parse_url($this->url);
  32319. if (empty($uri['user'])) {
  32320. return $this->hasAuth = false;
  32321. }
  32322. $this->credentials['username'] = $uri['user'];
  32323. if (!empty($uri['pass'])) {
  32324. $this->credentials['password'] = $uri['pass'];
  32325. }
  32326. return $this->hasAuth = true;
  32327. }
  32328. public function binaryVersion()
  32329. {
  32330. if (!self::$version) {
  32331. if (0 === $this->process->execute('svn --version', $output)) {
  32332. if (preg_match('{(\d+(?:\.\d+)+)}', $output, $match)) {
  32333. self::$version = $match[1];
  32334. }
  32335. }
  32336. }
  32337. return self::$version;
  32338. }
  32339. }
  32340. <?php
  32341. namespace Composer\Util;
  32342. use Composer\Downloader\DownloaderInterface;
  32343. use Composer\Package\PackageInterface;
  32344. use React\Promise\PromiseInterface;
  32345. class SyncHelper
  32346. {
  32347. public static function downloadAndInstallPackageSync(Loop $loop, DownloaderInterface $downloader, $path, PackageInterface $package, PackageInterface $prevPackage = null)
  32348. {
  32349. $type = $prevPackage ? 'update' : 'install';
  32350. try {
  32351. self::await($loop, $downloader->download($package, $path, $prevPackage));
  32352. self::await($loop, $downloader->prepare($type, $package, $path, $prevPackage));
  32353. if ($type === 'update') {
  32354. self::await($loop, $downloader->update($package, $path, $prevPackage));
  32355. } else {
  32356. self::await($loop, $downloader->install($package, $path, $prevPackage));
  32357. }
  32358. } catch (\Exception $e) {
  32359. self::await($loop, $downloader->cleanup($type, $package, $path, $prevPackage));
  32360. throw $e;
  32361. }
  32362. self::await($loop, $downloader->cleanup($type, $package, $path, $prevPackage));
  32363. }
  32364. public static function await(Loop $loop, PromiseInterface $promise = null)
  32365. {
  32366. if ($promise) {
  32367. $loop->wait(array($promise));
  32368. }
  32369. }
  32370. }
  32371. <?php
  32372. namespace Composer\Util;
  32373. class Tar
  32374. {
  32375. public static function getComposerJson($pathToArchive)
  32376. {
  32377. $phar = new \PharData($pathToArchive);
  32378. if (!$phar->valid()) {
  32379. return null;
  32380. }
  32381. return self::extractComposerJsonFromFolder($phar);
  32382. }
  32383. private static function extractComposerJsonFromFolder(\PharData $phar)
  32384. {
  32385. if (isset($phar['composer.json'])) {
  32386. return $phar['composer.json']->getContent();
  32387. }
  32388. $topLevelPaths = array();
  32389. foreach ($phar as $folderFile) {
  32390. $name = $folderFile->getBasename();
  32391. if ($folderFile->isDir()) {
  32392. $topLevelPaths[$name] = true;
  32393. if (\count($topLevelPaths) > 1) {
  32394. 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)));
  32395. }
  32396. }
  32397. }
  32398. $composerJsonPath = key($topLevelPaths).'/composer.json';
  32399. if ($topLevelPaths && isset($phar[$composerJsonPath])) {
  32400. return $phar[$composerJsonPath]->getContent();
  32401. }
  32402. throw new \RuntimeException('No composer.json found either at the top level or within the topmost directory');
  32403. }
  32404. }
  32405. <?php
  32406. namespace Composer\Util;
  32407. use Composer\CaBundle\CaBundle;
  32408. final class TlsHelper
  32409. {
  32410. public static function checkCertificateHost($certificate, $hostname, &$cn = null)
  32411. {
  32412. $names = self::getCertificateNames($certificate);
  32413. if (empty($names)) {
  32414. return false;
  32415. }
  32416. $combinedNames = array_merge($names['san'], array($names['cn']));
  32417. $hostname = strtolower($hostname);
  32418. foreach ($combinedNames as $certName) {
  32419. $matcher = self::certNameMatcher($certName);
  32420. if ($matcher && $matcher($hostname)) {
  32421. $cn = $names['cn'];
  32422. return true;
  32423. }
  32424. }
  32425. return false;
  32426. }
  32427. public static function getCertificateNames($certificate)
  32428. {
  32429. if (is_array($certificate)) {
  32430. $info = $certificate;
  32431. } elseif (CaBundle::isOpensslParseSafe()) {
  32432. $info = openssl_x509_parse($certificate, false);
  32433. }
  32434. if (!isset($info['subject']['commonName'])) {
  32435. return null;
  32436. }
  32437. $commonName = strtolower($info['subject']['commonName']);
  32438. $subjectAltNames = array();
  32439. if (isset($info['extensions']['subjectAltName'])) {
  32440. $subjectAltNames = preg_split('{\s*,\s*}', $info['extensions']['subjectAltName']);
  32441. $subjectAltNames = array_filter(array_map(function ($name) {
  32442. if (0 === strpos($name, 'DNS:')) {
  32443. return strtolower(ltrim(substr($name, 4)));
  32444. }
  32445. return null;
  32446. }, $subjectAltNames));
  32447. $subjectAltNames = array_values($subjectAltNames);
  32448. }
  32449. return array(
  32450. 'cn' => $commonName,
  32451. 'san' => $subjectAltNames,
  32452. );
  32453. }
  32454. public static function getCertificateFingerprint($certificate)
  32455. {
  32456. $pubkeydetails = openssl_pkey_get_details(openssl_get_publickey($certificate));
  32457. $pubkeypem = $pubkeydetails['key'];
  32458. $start = '-----BEGIN PUBLIC KEY-----';
  32459. $end = '-----END PUBLIC KEY-----';
  32460. $pemtrim = substr($pubkeypem, strpos($pubkeypem, $start) + strlen($start), (strlen($pubkeypem) - strpos($pubkeypem, $end)) * (-1));
  32461. $der = base64_decode($pemtrim);
  32462. return sha1($der);
  32463. }
  32464. public static function isOpensslParseSafe()
  32465. {
  32466. return CaBundle::isOpensslParseSafe();
  32467. }
  32468. private static function certNameMatcher($certName)
  32469. {
  32470. $wildcards = substr_count($certName, '*');
  32471. if (0 === $wildcards) {
  32472. return function ($hostname) use ($certName) {
  32473. return $hostname === $certName;
  32474. };
  32475. }
  32476. if (1 === $wildcards) {
  32477. $components = explode('.', $certName);
  32478. if (3 > count($components)) {
  32479. return;
  32480. }
  32481. $firstComponent = $components[0];
  32482. if ('*' !== $firstComponent[strlen($firstComponent) - 1]) {
  32483. return;
  32484. }
  32485. $wildcardRegex = preg_quote($certName);
  32486. $wildcardRegex = str_replace('\\*', '[a-z0-9-]+', $wildcardRegex);
  32487. $wildcardRegex = "{^{$wildcardRegex}$}";
  32488. return function ($hostname) use ($wildcardRegex) {
  32489. return 1 === preg_match($wildcardRegex, $hostname);
  32490. };
  32491. }
  32492. }
  32493. }
  32494. <?php
  32495. namespace Composer\Util;
  32496. use Composer\Config;
  32497. class Url
  32498. {
  32499. public static function updateDistReference(Config $config, $url, $ref)
  32500. {
  32501. $host = parse_url($url, PHP_URL_HOST);
  32502. if ($host === 'api.github.com' || $host === 'github.com' || $host === 'www.github.com') {
  32503. if (preg_match('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/(zip|tar)ball/(.+)$}i', $url, $match)) {
  32504. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  32505. } elseif (preg_match('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/archive/.+\.(zip|tar)(?:\.gz)?$}i', $url, $match)) {
  32506. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  32507. } elseif (preg_match('{^https?://api\.github\.com/repos/([^/]+)/([^/]+)/(zip|tar)ball(?:/.+)?$}i', $url, $match)) {
  32508. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  32509. }
  32510. } elseif ($host === 'bitbucket.org' || $host === 'www.bitbucket.org') {
  32511. if (preg_match('{^https?://(?:www\.)?bitbucket\.org/([^/]+)/([^/]+)/get/(.+)\.(zip|tar\.gz|tar\.bz2)$}i', $url, $match)) {
  32512. $url = 'https://bitbucket.org/' . $match[1] . '/'. $match[2] . '/get/' . $ref . '.' . $match[4];
  32513. }
  32514. } elseif ($host === 'gitlab.com' || $host === 'www.gitlab.com') {
  32515. if (preg_match('{^https?://(?:www\.)?gitlab\.com/api/v[34]/projects/([^/]+)/repository/archive\.(zip|tar\.gz|tar\.bz2|tar)\?sha=.+$}i', $url, $match)) {
  32516. $url = 'https://gitlab.com/api/v4/projects/' . $match[1] . '/repository/archive.' . $match[2] . '?sha=' . $ref;
  32517. }
  32518. } elseif (in_array($host, $config->get('github-domains'), true)) {
  32519. $url = preg_replace('{(/repos/[^/]+/[^/]+/(zip|tar)ball)(?:/.+)?$}i', '$1/'.$ref, $url);
  32520. } elseif (in_array($host, $config->get('gitlab-domains'), true)) {
  32521. $url = preg_replace('{(/api/v[34]/projects/[^/]+/repository/archive\.(?:zip|tar\.gz|tar\.bz2|tar)\?sha=).+$}i', '${1}'.$ref, $url);
  32522. }
  32523. return $url;
  32524. }
  32525. public static function getOrigin(Config $config, $url)
  32526. {
  32527. if (0 === strpos($url, 'file://')) {
  32528. return $url;
  32529. }
  32530. $origin = (string) parse_url($url, PHP_URL_HOST);
  32531. if ($port = parse_url($url, PHP_URL_PORT)) {
  32532. $origin .= ':'.$port;
  32533. }
  32534. if (strpos($origin, '.github.com') === (strlen($origin) - 11)) {
  32535. return 'github.com';
  32536. }
  32537. if ($origin === 'repo.packagist.org') {
  32538. return 'packagist.org';
  32539. }
  32540. if ($origin === '') {
  32541. $origin = $url;
  32542. }
  32543. if (
  32544. is_array($config->get('gitlab-domains'))
  32545. && false === strpos($origin, '/')
  32546. && !in_array($origin, $config->get('gitlab-domains'))
  32547. ) {
  32548. foreach ($config->get('gitlab-domains') as $gitlabDomain) {
  32549. if (0 === strpos($gitlabDomain, $origin)) {
  32550. return $gitlabDomain;
  32551. }
  32552. }
  32553. }
  32554. return $origin;
  32555. }
  32556. public static function sanitize($url)
  32557. {
  32558. $url = preg_replace('{([&?]access_token=)[^&]+}', '$1***', $url);
  32559. $url = preg_replace_callback('{://(?P<user>[^:/\s@]+):(?P<password>[^@\s/]+)@}i', function ($m) {
  32560. if (preg_match('{^[a-f0-9]{12,}$}', $m['user'])) {
  32561. return '://***:***@';
  32562. }
  32563. return '://'.$m['user'].':***@';
  32564. }, $url);
  32565. return $url;
  32566. }
  32567. }
  32568. <?php
  32569. namespace Composer\Util;
  32570. class Zip
  32571. {
  32572. public static function getComposerJson($pathToZip)
  32573. {
  32574. if (!extension_loaded('zip')) {
  32575. throw new \RuntimeException('The Zip Util requires PHP\'s zip extension');
  32576. }
  32577. $zip = new \ZipArchive();
  32578. if ($zip->open($pathToZip) !== true) {
  32579. return null;
  32580. }
  32581. if (0 == $zip->numFiles) {
  32582. $zip->close();
  32583. return null;
  32584. }
  32585. $foundFileIndex = self::locateFile($zip, 'composer.json');
  32586. if (false === $foundFileIndex) {
  32587. $zip->close();
  32588. return null;
  32589. }
  32590. $content = null;
  32591. $configurationFileName = $zip->getNameIndex($foundFileIndex);
  32592. $stream = $zip->getStream($configurationFileName);
  32593. if (false !== $stream) {
  32594. $content = stream_get_contents($stream);
  32595. }
  32596. $zip->close();
  32597. return $content;
  32598. }
  32599. private static function locateFile(\ZipArchive $zip, $filename)
  32600. {
  32601. if (false !== ($index = $zip->locateName($filename)) && $zip->getFromIndex($index) !== false) {
  32602. return $index;
  32603. }
  32604. $topLevelPaths = array();
  32605. for ($i = 0; $i < $zip->numFiles; $i++) {
  32606. $name = $zip->getNameIndex($i);
  32607. $dirname = dirname($name);
  32608. if ($dirname === '.') {
  32609. $topLevelPaths[$name] = true;
  32610. if (\count($topLevelPaths) > 1) {
  32611. 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)));
  32612. }
  32613. continue;
  32614. }
  32615. if (false === strpos($dirname, '\\') && false === strpos($dirname, '/')) {
  32616. $topLevelPaths[$dirname.'/'] = true;
  32617. if (\count($topLevelPaths) > 1) {
  32618. 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)));
  32619. }
  32620. }
  32621. }
  32622. if ($topLevelPaths && false !== ($index = $zip->locateName(key($topLevelPaths).$filename)) && $zip->getFromIndex($index) !== false) {
  32623. return $index;
  32624. }
  32625. throw new \RuntimeException('No composer.json found either at the top level or within the topmost directory');
  32626. }
  32627. }
  32628. <?php
  32629. function includeIfExists($file)
  32630. {
  32631. return file_exists($file) ? include $file : false;
  32632. }
  32633. if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../../autoload.php'))) {
  32634. echo 'You must set up the project dependencies using `composer install`'.PHP_EOL.
  32635. 'See https://getcomposer.org/download/ for instructions on installing Composer'.PHP_EOL;
  32636. exit(1);
  32637. }
  32638. return $loader;
  32639. <?php
  32640. /*
  32641. * This file is part of Composer.
  32642. *
  32643. * (c) Nils Adermann <naderman@naderman.de>
  32644. * Jordi Boggiano <j.boggiano@seld.be>
  32645. *
  32646. * For the full copyright and license information, please view the LICENSE
  32647. * file that was distributed with this source code.
  32648. */
  32649. namespace Composer\Autoload;
  32650. /**
  32651. * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
  32652. *
  32653. * $loader = new \Composer\Autoload\ClassLoader();
  32654. *
  32655. * // register classes with namespaces
  32656. * $loader->add('Symfony\Component', __DIR__.'/component');
  32657. * $loader->add('Symfony', __DIR__.'/framework');
  32658. *
  32659. * // activate the autoloader
  32660. * $loader->register();
  32661. *
  32662. * // to enable searching the include path (eg. for PEAR packages)
  32663. * $loader->setUseIncludePath(true);
  32664. *
  32665. * In this example, if you try to use a class in the Symfony\Component
  32666. * namespace or one of its children (Symfony\Component\Console for instance),
  32667. * the autoloader will first look for the class under the component/
  32668. * directory, and it will then fallback to the framework/ directory if not
  32669. * found before giving up.
  32670. *
  32671. * This class is loosely based on the Symfony UniversalClassLoader.
  32672. *
  32673. * @author Fabien Potencier <fabien@symfony.com>
  32674. * @author Jordi Boggiano <j.boggiano@seld.be>
  32675. * @see https://www.php-fig.org/psr/psr-0/
  32676. * @see https://www.php-fig.org/psr/psr-4/
  32677. */
  32678. class ClassLoader
  32679. {
  32680. // PSR-4
  32681. private $prefixLengthsPsr4 = array();
  32682. private $prefixDirsPsr4 = array();
  32683. private $fallbackDirsPsr4 = array();
  32684. // PSR-0
  32685. private $prefixesPsr0 = array();
  32686. private $fallbackDirsPsr0 = array();
  32687. private $useIncludePath = false;
  32688. private $classMap = array();
  32689. private $classMapAuthoritative = false;
  32690. private $missingClasses = array();
  32691. private $apcuPrefix;
  32692. public function getPrefixes()
  32693. {
  32694. if (!empty($this->prefixesPsr0)) {
  32695. return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
  32696. }
  32697. return array();
  32698. }
  32699. public function getPrefixesPsr4()
  32700. {
  32701. return $this->prefixDirsPsr4;
  32702. }
  32703. public function getFallbackDirs()
  32704. {
  32705. return $this->fallbackDirsPsr0;
  32706. }
  32707. public function getFallbackDirsPsr4()
  32708. {
  32709. return $this->fallbackDirsPsr4;
  32710. }
  32711. public function getClassMap()
  32712. {
  32713. return $this->classMap;
  32714. }
  32715. /**
  32716. * @param array $classMap Class to filename map
  32717. */
  32718. public function addClassMap(array $classMap)
  32719. {
  32720. if ($this->classMap) {
  32721. $this->classMap = array_merge($this->classMap, $classMap);
  32722. } else {
  32723. $this->classMap = $classMap;
  32724. }
  32725. }
  32726. /**
  32727. * Registers a set of PSR-0 directories for a given prefix, either
  32728. * appending or prepending to the ones previously set for this prefix.
  32729. *
  32730. * @param string $prefix The prefix
  32731. * @param array|string $paths The PSR-0 root directories
  32732. * @param bool $prepend Whether to prepend the directories
  32733. */
  32734. public function add($prefix, $paths, $prepend = false)
  32735. {
  32736. if (!$prefix) {
  32737. if ($prepend) {
  32738. $this->fallbackDirsPsr0 = array_merge(
  32739. (array) $paths,
  32740. $this->fallbackDirsPsr0
  32741. );
  32742. } else {
  32743. $this->fallbackDirsPsr0 = array_merge(
  32744. $this->fallbackDirsPsr0,
  32745. (array) $paths
  32746. );
  32747. }
  32748. return;
  32749. }
  32750. $first = $prefix[0];
  32751. if (!isset($this->prefixesPsr0[$first][$prefix])) {
  32752. $this->prefixesPsr0[$first][$prefix] = (array) $paths;
  32753. return;
  32754. }
  32755. if ($prepend) {
  32756. $this->prefixesPsr0[$first][$prefix] = array_merge(
  32757. (array) $paths,
  32758. $this->prefixesPsr0[$first][$prefix]
  32759. );
  32760. } else {
  32761. $this->prefixesPsr0[$first][$prefix] = array_merge(
  32762. $this->prefixesPsr0[$first][$prefix],
  32763. (array) $paths
  32764. );
  32765. }
  32766. }
  32767. /**
  32768. * Registers a set of PSR-4 directories for a given namespace, either
  32769. * appending or prepending to the ones previously set for this namespace.
  32770. *
  32771. * @param string $prefix The prefix/namespace, with trailing '\\'
  32772. * @param array|string $paths The PSR-4 base directories
  32773. * @param bool $prepend Whether to prepend the directories
  32774. *
  32775. * @throws \InvalidArgumentException
  32776. */
  32777. public function addPsr4($prefix, $paths, $prepend = false)
  32778. {
  32779. if (!$prefix) {
  32780. // Register directories for the root namespace.
  32781. if ($prepend) {
  32782. $this->fallbackDirsPsr4 = array_merge(
  32783. (array) $paths,
  32784. $this->fallbackDirsPsr4
  32785. );
  32786. } else {
  32787. $this->fallbackDirsPsr4 = array_merge(
  32788. $this->fallbackDirsPsr4,
  32789. (array) $paths
  32790. );
  32791. }
  32792. } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
  32793. // Register directories for a new namespace.
  32794. $length = strlen($prefix);
  32795. if ('\\' !== $prefix[$length - 1]) {
  32796. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  32797. }
  32798. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  32799. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  32800. } elseif ($prepend) {
  32801. // Prepend directories for an already registered namespace.
  32802. $this->prefixDirsPsr4[$prefix] = array_merge(
  32803. (array) $paths,
  32804. $this->prefixDirsPsr4[$prefix]
  32805. );
  32806. } else {
  32807. // Append directories for an already registered namespace.
  32808. $this->prefixDirsPsr4[$prefix] = array_merge(
  32809. $this->prefixDirsPsr4[$prefix],
  32810. (array) $paths
  32811. );
  32812. }
  32813. }
  32814. /**
  32815. * Registers a set of PSR-0 directories for a given prefix,
  32816. * replacing any others previously set for this prefix.
  32817. *
  32818. * @param string $prefix The prefix
  32819. * @param array|string $paths The PSR-0 base directories
  32820. */
  32821. public function set($prefix, $paths)
  32822. {
  32823. if (!$prefix) {
  32824. $this->fallbackDirsPsr0 = (array) $paths;
  32825. } else {
  32826. $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
  32827. }
  32828. }
  32829. /**
  32830. * Registers a set of PSR-4 directories for a given namespace,
  32831. * replacing any others previously set for this namespace.
  32832. *
  32833. * @param string $prefix The prefix/namespace, with trailing '\\'
  32834. * @param array|string $paths The PSR-4 base directories
  32835. *
  32836. * @throws \InvalidArgumentException
  32837. */
  32838. public function setPsr4($prefix, $paths)
  32839. {
  32840. if (!$prefix) {
  32841. $this->fallbackDirsPsr4 = (array) $paths;
  32842. } else {
  32843. $length = strlen($prefix);
  32844. if ('\\' !== $prefix[$length - 1]) {
  32845. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  32846. }
  32847. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  32848. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  32849. }
  32850. }
  32851. /**
  32852. * Turns on searching the include path for class files.
  32853. *
  32854. * @param bool $useIncludePath
  32855. */
  32856. public function setUseIncludePath($useIncludePath)
  32857. {
  32858. $this->useIncludePath = $useIncludePath;
  32859. }
  32860. /**
  32861. * Can be used to check if the autoloader uses the include path to check
  32862. * for classes.
  32863. *
  32864. * @return bool
  32865. */
  32866. public function getUseIncludePath()
  32867. {
  32868. return $this->useIncludePath;
  32869. }
  32870. /**
  32871. * Turns off searching the prefix and fallback directories for classes
  32872. * that have not been registered with the class map.
  32873. *
  32874. * @param bool $classMapAuthoritative
  32875. */
  32876. public function setClassMapAuthoritative($classMapAuthoritative)
  32877. {
  32878. $this->classMapAuthoritative = $classMapAuthoritative;
  32879. }
  32880. /**
  32881. * Should class lookup fail if not found in the current class map?
  32882. *
  32883. * @return bool
  32884. */
  32885. public function isClassMapAuthoritative()
  32886. {
  32887. return $this->classMapAuthoritative;
  32888. }
  32889. /**
  32890. * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
  32891. *
  32892. * @param string|null $apcuPrefix
  32893. */
  32894. public function setApcuPrefix($apcuPrefix)
  32895. {
  32896. $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
  32897. }
  32898. /**
  32899. * The APCu prefix in use, or null if APCu caching is not enabled.
  32900. *
  32901. * @return string|null
  32902. */
  32903. public function getApcuPrefix()
  32904. {
  32905. return $this->apcuPrefix;
  32906. }
  32907. /**
  32908. * Registers this instance as an autoloader.
  32909. *
  32910. * @param bool $prepend Whether to prepend the autoloader or not
  32911. */
  32912. public function register($prepend = false)
  32913. {
  32914. spl_autoload_register(array($this, 'loadClass'), true, $prepend);
  32915. }
  32916. /**
  32917. * Unregisters this instance as an autoloader.
  32918. */
  32919. public function unregister()
  32920. {
  32921. spl_autoload_unregister(array($this, 'loadClass'));
  32922. }
  32923. /**
  32924. * Loads the given class or interface.
  32925. *
  32926. * @param string $class The name of the class
  32927. * @return bool|null True if loaded, null otherwise
  32928. */
  32929. public function loadClass($class)
  32930. {
  32931. if ($file = $this->findFile($class)) {
  32932. includeFile($file);
  32933. return true;
  32934. }
  32935. }
  32936. /**
  32937. * Finds the path to the file where the class is defined.
  32938. *
  32939. * @param string $class The name of the class
  32940. *
  32941. * @return string|false The path if found, false otherwise
  32942. */
  32943. public function findFile($class)
  32944. {
  32945. // class map lookup
  32946. if (isset($this->classMap[$class])) {
  32947. return $this->classMap[$class];
  32948. }
  32949. if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
  32950. return false;
  32951. }
  32952. if (null !== $this->apcuPrefix) {
  32953. $file = apcu_fetch($this->apcuPrefix.$class, $hit);
  32954. if ($hit) {
  32955. return $file;
  32956. }
  32957. }
  32958. $file = $this->findFileWithExtension($class, '.php');
  32959. // Search for Hack files if we are running on HHVM
  32960. if (false === $file && defined('HHVM_VERSION')) {
  32961. $file = $this->findFileWithExtension($class, '.hh');
  32962. }
  32963. if (null !== $this->apcuPrefix) {
  32964. apcu_add($this->apcuPrefix.$class, $file);
  32965. }
  32966. if (false === $file) {
  32967. // Remember that this class does not exist.
  32968. $this->missingClasses[$class] = true;
  32969. }
  32970. return $file;
  32971. }
  32972. private function findFileWithExtension($class, $ext)
  32973. {
  32974. // PSR-4 lookup
  32975. $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
  32976. $first = $class[0];
  32977. if (isset($this->prefixLengthsPsr4[$first])) {
  32978. $subPath = $class;
  32979. while (false !== $lastPos = strrpos($subPath, '\\')) {
  32980. $subPath = substr($subPath, 0, $lastPos);
  32981. $search = $subPath . '\\';
  32982. if (isset($this->prefixDirsPsr4[$search])) {
  32983. $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
  32984. foreach ($this->prefixDirsPsr4[$search] as $dir) {
  32985. if (file_exists($file = $dir . $pathEnd)) {
  32986. return $file;
  32987. }
  32988. }
  32989. }
  32990. }
  32991. }
  32992. // PSR-4 fallback dirs
  32993. foreach ($this->fallbackDirsPsr4 as $dir) {
  32994. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
  32995. return $file;
  32996. }
  32997. }
  32998. // PSR-0 lookup
  32999. if (false !== $pos = strrpos($class, '\\')) {
  33000. // namespaced class name
  33001. $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
  33002. . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
  33003. } else {
  33004. // PEAR-like class name
  33005. $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
  33006. }
  33007. if (isset($this->prefixesPsr0[$first])) {
  33008. foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
  33009. if (0 === strpos($class, $prefix)) {
  33010. foreach ($dirs as $dir) {
  33011. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  33012. return $file;
  33013. }
  33014. }
  33015. }
  33016. }
  33017. }
  33018. // PSR-0 fallback dirs
  33019. foreach ($this->fallbackDirsPsr0 as $dir) {
  33020. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  33021. return $file;
  33022. }
  33023. }
  33024. // PSR-0 include paths.
  33025. if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
  33026. return $file;
  33027. }
  33028. return false;
  33029. }
  33030. }
  33031. /**
  33032. * Scope isolated include.
  33033. *
  33034. * Prevents access to $this/self from included files.
  33035. */
  33036. function includeFile($file)
  33037. {
  33038. include $file;
  33039. }
  33040. {
  33041. "$schema": "https://json-schema.org/draft-04/schema#",
  33042. "description": "A representation of packages metadata.",
  33043. "type": "object",
  33044. "oneOf": [
  33045. { "required": [ "packages" ] },
  33046. { "required": [ "providers" ] },
  33047. { "required": [ "provider-includes", "providers-url" ] }
  33048. ],
  33049. "properties": {
  33050. "packages": {
  33051. "type": ["object", "array"],
  33052. "description": "A hashmap of package names in the form of <vendor>/<name>.",
  33053. "additionalProperties": { "$ref": "#/definitions/versions" }
  33054. },
  33055. "providers-url": {
  33056. "type": "string",
  33057. "description": "Endpoint to retrieve provider data from, e.g. '/p/%package%$%hash%.json'."
  33058. },
  33059. "provider-includes": {
  33060. "type": "object",
  33061. "description": "A hashmap of provider listings.",
  33062. "additionalProperties": { "$ref": "#/definitions/provider" }
  33063. },
  33064. "providers": {
  33065. "type": "object",
  33066. "description": "A hashmap of package names in the form of <vendor>/<name>.",
  33067. "additionalProperties": { "$ref": "#/definitions/provider" }
  33068. },
  33069. "notify-batch": {
  33070. "type": "string",
  33071. "description": "Endpoint to call after multiple packages have been installed, e.g. '/downloads/'."
  33072. },
  33073. "search": {
  33074. "type": "string",
  33075. "description": "Endpoint that provides search capabilities, e.g. '/search.json?q=%query%&type=%type%'."
  33076. },
  33077. "warning": {
  33078. "type": "string",
  33079. "description": "A message that will be output by Composer as a warning when this source is consulted."
  33080. }
  33081. },
  33082. "definitions": {
  33083. "versions": {
  33084. "type": "object",
  33085. "description": "A hashmap of versions and their metadata.",
  33086. "additionalProperties": { "$ref": "#/definitions/version" }
  33087. },
  33088. "version": {
  33089. "type": "object",
  33090. "oneOf": [
  33091. { "$ref": "#/definitions/package" },
  33092. { "$ref": "#/definitions/metapackage" }
  33093. ]
  33094. },
  33095. "package-base": {
  33096. "properties": {
  33097. "name": { "type": "string" },
  33098. "type": { "type": "string" },
  33099. "version": { "type": "string" },
  33100. "version_normalized": {
  33101. "type": "string",
  33102. "description": "Normalized version, optional but can save computational time on client side."
  33103. },
  33104. "autoload": { "type": "object" },
  33105. "require": { "type": "object" },
  33106. "replace": { "type": "object" },
  33107. "conflict": { "type": "object" },
  33108. "provide": { "type": "object" },
  33109. "time": { "type": "string" }
  33110. },
  33111. "additionalProperties": true
  33112. },
  33113. "package": {
  33114. "allOf": [
  33115. { "$ref": "#/definitions/package-base" },
  33116. {
  33117. "properties": {
  33118. "dist": { "type": "object" },
  33119. "source": { "type": "object" }
  33120. }
  33121. },
  33122. { "oneOf": [
  33123. { "required": [ "name", "version", "source" ] },
  33124. { "required": [ "name", "version", "dist" ] }
  33125. ] }
  33126. ]
  33127. },
  33128. "metapackage": {
  33129. "allOf": [
  33130. { "$ref": "#/definitions/package-base" },
  33131. {
  33132. "properties": {
  33133. "type": { "type": "string", "enum": [ "metapackage" ] }
  33134. },
  33135. "required": [ "name", "version", "type" ]
  33136. }
  33137. ]
  33138. },
  33139. "provider": {
  33140. "type": "object",
  33141. "properties": {
  33142. "sha256": {
  33143. "type": "string",
  33144. "description": "Hash value that can be used to validate the resource."
  33145. }
  33146. }
  33147. }
  33148. }
  33149. }
  33150. {
  33151. "$schema": "https://json-schema.org/draft-04/schema#",
  33152. "name": "Package",
  33153. "type": "object",
  33154. "additionalProperties": false,
  33155. "required": [ "name", "description" ],
  33156. "properties": {
  33157. "name": {
  33158. "type": "string",
  33159. "description": "Package name, including 'vendor-name/' prefix.",
  33160. "pattern": "^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$"
  33161. },
  33162. "type": {
  33163. "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.",
  33164. "type": "string",
  33165. "pattern": "^[a-z0-9-]+$"
  33166. },
  33167. "target-dir": {
  33168. "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.",
  33169. "type": "string"
  33170. },
  33171. "description": {
  33172. "type": "string",
  33173. "description": "Short package description."
  33174. },
  33175. "keywords": {
  33176. "type": "array",
  33177. "items": {
  33178. "type": "string",
  33179. "description": "A tag/keyword that this package relates to."
  33180. }
  33181. },
  33182. "homepage": {
  33183. "type": "string",
  33184. "description": "Homepage URL for the project.",
  33185. "format": "uri"
  33186. },
  33187. "readme": {
  33188. "type": "string",
  33189. "description": "Relative path to the readme document."
  33190. },
  33191. "version": {
  33192. "type": "string",
  33193. "description": "Package version, see https://getcomposer.org/doc/04-schema.md#version for more info on valid schemes.",
  33194. "pattern": "^v?\\d+(((\\.\\d+)?\\.\\d+)?\\.\\d+)?|^dev-"
  33195. },
  33196. "time": {
  33197. "type": "string",
  33198. "description": "Package release date, in 'YYYY-MM-DD', 'YYYY-MM-DD HH:MM:SS' or 'YYYY-MM-DDTHH:MM:SSZ' format."
  33199. },
  33200. "license": {
  33201. "type": ["string", "array"],
  33202. "description": "License name. Or an array of license names."
  33203. },
  33204. "authors": {
  33205. "$ref": "#/definitions/authors"
  33206. },
  33207. "require": {
  33208. "type": "object",
  33209. "description": "This is a hash of package name (keys) and version constraints (values) that are required to run this package.",
  33210. "additionalProperties": {
  33211. "type": "string"
  33212. }
  33213. },
  33214. "replace": {
  33215. "type": "object",
  33216. "description": "This is a hash of package name (keys) and version constraints (values) that can be replaced by this package.",
  33217. "additionalProperties": {
  33218. "type": "string"
  33219. }
  33220. },
  33221. "conflict": {
  33222. "type": "object",
  33223. "description": "This is a hash of package name (keys) and version constraints (values) that conflict with this package.",
  33224. "additionalProperties": {
  33225. "type": "string"
  33226. }
  33227. },
  33228. "provide": {
  33229. "type": "object",
  33230. "description": "This is a hash of package name (keys) and version constraints (values) that this package provides in addition to this package's name.",
  33231. "additionalProperties": {
  33232. "type": "string"
  33233. }
  33234. },
  33235. "require-dev": {
  33236. "type": "object",
  33237. "description": "This is a hash of package name (keys) and version constraints (values) that this package requires for developing it (testing tools and such).",
  33238. "additionalProperties": {
  33239. "type": "string"
  33240. }
  33241. },
  33242. "suggest": {
  33243. "type": "object",
  33244. "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).",
  33245. "additionalProperties": {
  33246. "type": "string"
  33247. }
  33248. },
  33249. "config": {
  33250. "type": "object",
  33251. "description": "Composer options.",
  33252. "properties": {
  33253. "process-timeout": {
  33254. "type": "integer",
  33255. "description": "The timeout in seconds for process executions, defaults to 300 (5mins)."
  33256. },
  33257. "use-include-path": {
  33258. "type": "boolean",
  33259. "description": "If true, the Composer autoloader will also look for classes in the PHP include path."
  33260. },
  33261. "preferred-install": {
  33262. "type": ["string", "object"],
  33263. "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\"}."
  33264. },
  33265. "notify-on-install": {
  33266. "type": "boolean",
  33267. "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."
  33268. },
  33269. "github-protocols": {
  33270. "type": "array",
  33271. "description": "A list of protocols to use for github.com clones, in priority order, defaults to [\"git\", \"https\", \"http\"].",
  33272. "items": {
  33273. "type": "string"
  33274. }
  33275. },
  33276. "github-oauth": {
  33277. "type": "object",
  33278. "description": "A hash of domain name => github API oauth tokens, typically {\"github.com\":\"<token>\"}.",
  33279. "additionalProperties": {
  33280. "type": "string"
  33281. }
  33282. },
  33283. "gitlab-oauth": {
  33284. "type": "object",
  33285. "description": "A hash of domain name => gitlab API oauth tokens, typically {\"gitlab.com\":\"<token>\"}.",
  33286. "additionalProperties": {
  33287. "type": "string"
  33288. }
  33289. },
  33290. "gitlab-token": {
  33291. "type": "object",
  33292. "description": "A hash of domain name => gitlab private tokens, typically {\"gitlab.com\":\"<token>\"}.",
  33293. "additionalProperties": {
  33294. "type": "string"
  33295. }
  33296. },
  33297. "bearer": {
  33298. "type": "object",
  33299. "description": "A hash of domain name => bearer authentication token, for example {\"example.com\":\"<token>\"}.",
  33300. "additionalProperties": {
  33301. "type": "string"
  33302. }
  33303. },
  33304. "disable-tls": {
  33305. "type": "boolean",
  33306. "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."
  33307. },
  33308. "secure-http": {
  33309. "type": "boolean",
  33310. "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."
  33311. },
  33312. "cafile": {
  33313. "type": "string",
  33314. "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."
  33315. },
  33316. "capath": {
  33317. "type": "string",
  33318. "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."
  33319. },
  33320. "http-basic": {
  33321. "type": "object",
  33322. "description": "A hash of domain name => {\"username\": \"...\", \"password\": \"...\"}.",
  33323. "additionalProperties": {
  33324. "type": "object",
  33325. "required": ["username", "password"],
  33326. "properties": {
  33327. "username": {
  33328. "type": "string",
  33329. "description": "The username used for HTTP Basic authentication"
  33330. },
  33331. "password": {
  33332. "type": "string",
  33333. "description": "The password used for HTTP Basic authentication"
  33334. }
  33335. }
  33336. }
  33337. },
  33338. "store-auths": {
  33339. "type": ["string", "boolean"],
  33340. "description": "What to do after prompting for authentication, one of: true (store), false (do not store) or \"prompt\" (ask every time), defaults to prompt."
  33341. },
  33342. "platform": {
  33343. "type": "object",
  33344. "description": "This is a hash of package name (keys) and version (values) that will be used to mock the platform packages on this machine.",
  33345. "additionalProperties": {
  33346. "type": "string"
  33347. }
  33348. },
  33349. "vendor-dir": {
  33350. "type": "string",
  33351. "description": "The location where all packages are installed, defaults to \"vendor\"."
  33352. },
  33353. "bin-dir": {
  33354. "type": "string",
  33355. "description": "The location where all binaries are linked, defaults to \"vendor/bin\"."
  33356. },
  33357. "data-dir": {
  33358. "type": "string",
  33359. "description": "The location where old phar files are stored, defaults to \"$home\" except on XDG Base Directory compliant unixes."
  33360. },
  33361. "cache-dir": {
  33362. "type": "string",
  33363. "description": "The location where all caches are located, defaults to \"~/.composer/cache\" on *nix and \"%LOCALAPPDATA%\\Composer\" on windows."
  33364. },
  33365. "cache-files-dir": {
  33366. "type": "string",
  33367. "description": "The location where files (zip downloads) are cached, defaults to \"{$cache-dir}/files\"."
  33368. },
  33369. "cache-repo-dir": {
  33370. "type": "string",
  33371. "description": "The location where repo (git/hg repo clones) are cached, defaults to \"{$cache-dir}/repo\"."
  33372. },
  33373. "cache-vcs-dir": {
  33374. "type": "string",
  33375. "description": "The location where vcs infos (git clones, github api calls, etc. when reading vcs repos) are cached, defaults to \"{$cache-dir}/vcs\"."
  33376. },
  33377. "cache-ttl": {
  33378. "type": "integer",
  33379. "description": "The default cache time-to-live, defaults to 15552000 (6 months)."
  33380. },
  33381. "cache-files-ttl": {
  33382. "type": "integer",
  33383. "description": "The cache time-to-live for files, defaults to the value of cache-ttl."
  33384. },
  33385. "cache-files-maxsize": {
  33386. "type": ["string", "integer"],
  33387. "description": "The cache max size for the files cache, defaults to \"300MiB\"."
  33388. },
  33389. "cache-read-only": {
  33390. "type": ["boolean"],
  33391. "description": "Whether to use the Composer cache in read-only mode."
  33392. },
  33393. "bin-compat": {
  33394. "enum": ["auto", "full"],
  33395. "description": "The compatibility of the binaries, defaults to \"auto\" (automatically guessed) and can be \"full\" (compatible with both Windows and Unix-based systems)."
  33396. },
  33397. "discard-changes": {
  33398. "type": ["string", "boolean"],
  33399. "description": "The default style of handling dirty updates, defaults to false and can be any of true, false or \"stash\"."
  33400. },
  33401. "autoloader-suffix": {
  33402. "type": "string",
  33403. "description": "Optional string to be used as a suffix for the generated Composer autoloader. When null a random one will be generated."
  33404. },
  33405. "optimize-autoloader": {
  33406. "type": "boolean",
  33407. "description": "Always optimize when dumping the autoloader."
  33408. },
  33409. "prepend-autoloader": {
  33410. "type": "boolean",
  33411. "description": "If false, the composer autoloader will not be prepended to existing autoloaders, defaults to true."
  33412. },
  33413. "classmap-authoritative": {
  33414. "type": "boolean",
  33415. "description": "If true, the composer autoloader will not scan the filesystem for classes that are not found in the class map, defaults to false."
  33416. },
  33417. "apcu-autoloader": {
  33418. "type": "boolean",
  33419. "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."
  33420. },
  33421. "github-domains": {
  33422. "type": "array",
  33423. "description": "A list of domains to use in github mode. This is used for GitHub Enterprise setups, defaults to [\"github.com\"].",
  33424. "items": {
  33425. "type": "string"
  33426. }
  33427. },
  33428. "github-expose-hostname": {
  33429. "type": "boolean",
  33430. "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."
  33431. },
  33432. "gitlab-domains": {
  33433. "type": "array",
  33434. "description": "A list of domains to use in gitlab mode. This is used for custom GitLab setups, defaults to [\"gitlab.com\"].",
  33435. "items": {
  33436. "type": "string"
  33437. }
  33438. },
  33439. "use-github-api": {
  33440. "type": "boolean",
  33441. "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."
  33442. },
  33443. "archive-format": {
  33444. "type": "string",
  33445. "description": "The default archiving format when not provided on cli, defaults to \"tar\"."
  33446. },
  33447. "archive-dir": {
  33448. "type": "string",
  33449. "description": "The default archive path when not provided on cli, defaults to \".\"."
  33450. },
  33451. "htaccess-protect": {
  33452. "type": "boolean",
  33453. "description": "Defaults to true. If set to false, Composer will not create .htaccess files in the composer home, cache, and data directories."
  33454. },
  33455. "sort-packages": {
  33456. "type": "boolean",
  33457. "description": "Defaults to false. If set to true, Composer will sort packages when adding/updating a new dependency."
  33458. },
  33459. "lock": {
  33460. "type": "boolean",
  33461. "description": "Defaults to true. If set to false, Composer will not create a composer.lock file."
  33462. },
  33463. "platform-check": {
  33464. "type": "boolean",
  33465. "description": "Defaults to true. If set to false, Composer will not create and require a platform_check.php file as part of the autoloader bootstrap."
  33466. }
  33467. }
  33468. },
  33469. "extra": {
  33470. "type": ["object", "array"],
  33471. "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.",
  33472. "additionalProperties": true
  33473. },
  33474. "autoload": {
  33475. "$ref": "#/definitions/autoload"
  33476. },
  33477. "autoload-dev": {
  33478. "type": "object",
  33479. "description": "Description of additional autoload rules for development purpose (eg. a test suite).",
  33480. "properties": {
  33481. "psr-0": {
  33482. "type": "object",
  33483. "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.",
  33484. "additionalProperties": {
  33485. "type": ["string", "array"],
  33486. "items": {
  33487. "type": "string"
  33488. }
  33489. }
  33490. },
  33491. "psr-4": {
  33492. "type": "object",
  33493. "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.",
  33494. "additionalProperties": {
  33495. "type": ["string", "array"],
  33496. "items": {
  33497. "type": "string"
  33498. }
  33499. }
  33500. },
  33501. "classmap": {
  33502. "type": "array",
  33503. "description": "This is an array of paths that contain classes to be included in the class-map generation process."
  33504. },
  33505. "files": {
  33506. "type": "array",
  33507. "description": "This is an array of files that are always required on every request."
  33508. }
  33509. }
  33510. },
  33511. "archive": {
  33512. "type": ["object"],
  33513. "description": "Options for creating package archives for distribution.",
  33514. "properties": {
  33515. "name": {
  33516. "type": "string",
  33517. "description": "A base name for archive."
  33518. },
  33519. "exclude": {
  33520. "type": "array",
  33521. "description": "A list of patterns for paths to exclude or include if prefixed with an exclamation mark."
  33522. }
  33523. }
  33524. },
  33525. "repositories": {
  33526. "type": ["object", "array"],
  33527. "description": "A set of additional repositories where packages can be found.",
  33528. "additionalProperties": {
  33529. "anyOf": [
  33530. { "$ref": "#/definitions/repository" },
  33531. { "type": "boolean", "enum": [false] }
  33532. ]
  33533. },
  33534. "items": {
  33535. "anyOf": [
  33536. { "$ref": "#/definitions/repository" },
  33537. {
  33538. "type": "object",
  33539. "additionalProperties": { "type": "boolean", "enum": [false] },
  33540. "minProperties": 1,
  33541. "maxProperties": 1
  33542. }
  33543. ]
  33544. }
  33545. },
  33546. "minimum-stability": {
  33547. "type": ["string"],
  33548. "description": "The minimum stability the packages must have to be install-able. Possible values are: dev, alpha, beta, RC, stable.",
  33549. "pattern": "^dev|alpha|beta|rc|RC|stable$"
  33550. },
  33551. "prefer-stable": {
  33552. "type": ["boolean"],
  33553. "description": "If set to true, stable packages will be preferred to dev packages when possible, even if the minimum-stability allows unstable packages."
  33554. },
  33555. "bin": {
  33556. "type": ["string", "array"],
  33557. "description": "A set of files, or a single file, that should be treated as binaries and symlinked into bin-dir (from config).",
  33558. "items": {
  33559. "type": "string"
  33560. }
  33561. },
  33562. "include-path": {
  33563. "type": ["array"],
  33564. "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.",
  33565. "items": {
  33566. "type": "string"
  33567. }
  33568. },
  33569. "scripts": {
  33570. "type": ["object"],
  33571. "description": "Script listeners that will be executed before/after some events.",
  33572. "properties": {
  33573. "pre-install-cmd": {
  33574. "type": ["array", "string"],
  33575. "description": "Occurs before the install command is executed, contains one or more Class::method callables or shell commands."
  33576. },
  33577. "post-install-cmd": {
  33578. "type": ["array", "string"],
  33579. "description": "Occurs after the install command is executed, contains one or more Class::method callables or shell commands."
  33580. },
  33581. "pre-update-cmd": {
  33582. "type": ["array", "string"],
  33583. "description": "Occurs before the update command is executed, contains one or more Class::method callables or shell commands."
  33584. },
  33585. "post-update-cmd": {
  33586. "type": ["array", "string"],
  33587. "description": "Occurs after the update command is executed, contains one or more Class::method callables or shell commands."
  33588. },
  33589. "pre-status-cmd": {
  33590. "type": ["array", "string"],
  33591. "description": "Occurs before the status command is executed, contains one or more Class::method callables or shell commands."
  33592. },
  33593. "post-status-cmd": {
  33594. "type": ["array", "string"],
  33595. "description": "Occurs after the status command is executed, contains one or more Class::method callables or shell commands."
  33596. },
  33597. "pre-package-install": {
  33598. "type": ["array", "string"],
  33599. "description": "Occurs before a package is installed, contains one or more Class::method callables or shell commands."
  33600. },
  33601. "post-package-install": {
  33602. "type": ["array", "string"],
  33603. "description": "Occurs after a package is installed, contains one or more Class::method callables or shell commands."
  33604. },
  33605. "pre-package-update": {
  33606. "type": ["array", "string"],
  33607. "description": "Occurs before a package is updated, contains one or more Class::method callables or shell commands."
  33608. },
  33609. "post-package-update": {
  33610. "type": ["array", "string"],
  33611. "description": "Occurs after a package is updated, contains one or more Class::method callables or shell commands."
  33612. },
  33613. "pre-package-uninstall": {
  33614. "type": ["array", "string"],
  33615. "description": "Occurs before a package has been uninstalled, contains one or more Class::method callables or shell commands."
  33616. },
  33617. "post-package-uninstall": {
  33618. "type": ["array", "string"],
  33619. "description": "Occurs after a package has been uninstalled, contains one or more Class::method callables or shell commands."
  33620. },
  33621. "pre-autoload-dump": {
  33622. "type": ["array", "string"],
  33623. "description": "Occurs before the autoloader is dumped, contains one or more Class::method callables or shell commands."
  33624. },
  33625. "post-autoload-dump": {
  33626. "type": ["array", "string"],
  33627. "description": "Occurs after the autoloader is dumped, contains one or more Class::method callables or shell commands."
  33628. },
  33629. "post-root-package-install": {
  33630. "type": ["array", "string"],
  33631. "description": "Occurs after the root-package is installed, contains one or more Class::method callables or shell commands."
  33632. },
  33633. "post-create-project-cmd": {
  33634. "type": ["array", "string"],
  33635. "description": "Occurs after the create-project command is executed, contains one or more Class::method callables or shell commands."
  33636. }
  33637. }
  33638. },
  33639. "scripts-descriptions": {
  33640. "type": ["object"],
  33641. "description": "Descriptions for custom commands, shown in console help.",
  33642. "additionalProperties": {
  33643. "type": "string"
  33644. }
  33645. },
  33646. "support": {
  33647. "type": "object",
  33648. "properties": {
  33649. "email": {
  33650. "type": "string",
  33651. "description": "Email address for support.",
  33652. "format": "email"
  33653. },
  33654. "issues": {
  33655. "type": "string",
  33656. "description": "URL to the issue tracker.",
  33657. "format": "uri"
  33658. },
  33659. "forum": {
  33660. "type": "string",
  33661. "description": "URL to the forum.",
  33662. "format": "uri"
  33663. },
  33664. "wiki": {
  33665. "type": "string",
  33666. "description": "URL to the wiki.",
  33667. "format": "uri"
  33668. },
  33669. "irc": {
  33670. "type": "string",
  33671. "description": "IRC channel for support, as irc://server/channel.",
  33672. "format": "uri"
  33673. },
  33674. "chat": {
  33675. "type": "string",
  33676. "description": "URL to the support chat.",
  33677. "format": "uri"
  33678. },
  33679. "source": {
  33680. "type": "string",
  33681. "description": "URL to browse or download the sources.",
  33682. "format": "uri"
  33683. },
  33684. "docs": {
  33685. "type": "string",
  33686. "description": "URL to the documentation.",
  33687. "format": "uri"
  33688. },
  33689. "rss": {
  33690. "type": "string",
  33691. "description": "URL to the RSS feed.",
  33692. "format": "uri"
  33693. }
  33694. }
  33695. },
  33696. "funding": {
  33697. "type": "array",
  33698. "description": "A list of options to fund the development and maintenance of the package.",
  33699. "items": {
  33700. "type": "object",
  33701. "properties": {
  33702. "type": {
  33703. "type": "string",
  33704. "description": "Type of funding or platform through which funding is possible."
  33705. },
  33706. "url": {
  33707. "type": "string",
  33708. "description": "URL to a website with details on funding and a way to fund the package.",
  33709. "format": "uri"
  33710. }
  33711. }
  33712. }
  33713. },
  33714. "non-feature-branches": {
  33715. "type": ["array"],
  33716. "description": "A set of string or regex patterns for non-numeric branch names that will not be handled as feature branches.",
  33717. "items": {
  33718. "type": "string"
  33719. }
  33720. },
  33721. "default-branch": {
  33722. "type": ["boolean"],
  33723. "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."
  33724. },
  33725. "abandoned": {
  33726. "type": ["boolean", "string"],
  33727. "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."
  33728. },
  33729. "_comment": {
  33730. "type": ["array", "string"],
  33731. "description": "A key to store comments in"
  33732. }
  33733. },
  33734. "definitions": {
  33735. "authors": {
  33736. "type": "array",
  33737. "description": "List of authors that contributed to the package. This is typically the main maintainers, not the full list.",
  33738. "items": {
  33739. "type": "object",
  33740. "additionalProperties": false,
  33741. "required": [ "name"],
  33742. "properties": {
  33743. "name": {
  33744. "type": "string",
  33745. "description": "Full name of the author."
  33746. },
  33747. "email": {
  33748. "type": "string",
  33749. "description": "Email address of the author.",
  33750. "format": "email"
  33751. },
  33752. "homepage": {
  33753. "type": "string",
  33754. "description": "Homepage URL for the author.",
  33755. "format": "uri"
  33756. },
  33757. "role": {
  33758. "type": "string",
  33759. "description": "Author's role in the project."
  33760. }
  33761. }
  33762. }
  33763. },
  33764. "autoload": {
  33765. "type": "object",
  33766. "description": "Description of how the package can be autoloaded.",
  33767. "properties": {
  33768. "psr-0": {
  33769. "type": "object",
  33770. "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.",
  33771. "additionalProperties": {
  33772. "type": ["string", "array"],
  33773. "items": {
  33774. "type": "string"
  33775. }
  33776. }
  33777. },
  33778. "psr-4": {
  33779. "type": "object",
  33780. "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.",
  33781. "additionalProperties": {
  33782. "type": ["string", "array"],
  33783. "items": {
  33784. "type": "string"
  33785. }
  33786. }
  33787. },
  33788. "classmap": {
  33789. "type": "array",
  33790. "description": "This is an array of paths that contain classes to be included in the class-map generation process."
  33791. },
  33792. "files": {
  33793. "type": "array",
  33794. "description": "This is an array of files that are always required on every request."
  33795. },
  33796. "exclude-from-classmap": {
  33797. "type": "array",
  33798. "description": "This is an array of patterns to exclude from autoload classmap generation. (e.g. \"exclude-from-classmap\": [\"/test/\", \"/tests/\", \"/Tests/\"]"
  33799. }
  33800. }
  33801. },
  33802. "repository": {
  33803. "type": "object",
  33804. "anyOf": [
  33805. { "$ref": "#/definitions/composer-repository" },
  33806. { "$ref": "#/definitions/vcs-repository" },
  33807. { "$ref": "#/definitions/path-repository" },
  33808. { "$ref": "#/definitions/artifact-repository" },
  33809. { "$ref": "#/definitions/pear-repository" },
  33810. { "$ref": "#/definitions/package-repository" }
  33811. ]
  33812. },
  33813. "composer-repository": {
  33814. "type": "object",
  33815. "required": ["type", "url"],
  33816. "properties": {
  33817. "type": { "type": "string", "enum": ["composer"] },
  33818. "url": { "type": "string" },
  33819. "canonical": { "type": "boolean" },
  33820. "only": {
  33821. "type": "array",
  33822. "items": {
  33823. "type": "string"
  33824. }
  33825. },
  33826. "exclude": {
  33827. "type": "array",
  33828. "items": {
  33829. "type": "string"
  33830. }
  33831. },
  33832. "options": {
  33833. "type": "object",
  33834. "additionalProperties": true
  33835. },
  33836. "allow_ssl_downgrade": { "type": "boolean" },
  33837. "force-lazy-providers": { "type": "boolean" }
  33838. }
  33839. },
  33840. "vcs-repository": {
  33841. "type": "object",
  33842. "required": ["type", "url"],
  33843. "properties": {
  33844. "type": { "type": "string", "enum": ["vcs", "github", "git", "gitlab", "git-bitbucket", "hg", "hg-bitbucket", "fossil", "perforce", "svn"] },
  33845. "url": { "type": "string" },
  33846. "canonical": { "type": "boolean" },
  33847. "only": {
  33848. "type": "array",
  33849. "items": {
  33850. "type": "string"
  33851. }
  33852. },
  33853. "exclude": {
  33854. "type": "array",
  33855. "items": {
  33856. "type": "string"
  33857. }
  33858. },
  33859. "no-api": { "type": "boolean" },
  33860. "secure-http": { "type": "boolean" },
  33861. "svn-cache-credentials": { "type": "boolean" },
  33862. "trunk-path": { "type": ["string", "boolean"] },
  33863. "branches-path": { "type": ["string", "boolean"] },
  33864. "tags-path": { "type": ["string", "boolean"] },
  33865. "package-path": { "type": "string" },
  33866. "depot": { "type": "string" },
  33867. "branch": { "type": "string" },
  33868. "unique_perforce_client_name": { "type": "string" },
  33869. "p4user": { "type": "string" },
  33870. "p4password": { "type": "string" }
  33871. }
  33872. },
  33873. "path-repository": {
  33874. "type": "object",
  33875. "required": ["type", "url"],
  33876. "properties": {
  33877. "type": { "type": "string", "enum": ["path"] },
  33878. "url": { "type": "string" },
  33879. "canonical": { "type": "boolean" },
  33880. "only": {
  33881. "type": "array",
  33882. "items": {
  33883. "type": "string"
  33884. }
  33885. },
  33886. "exclude": {
  33887. "type": "array",
  33888. "items": {
  33889. "type": "string"
  33890. }
  33891. },
  33892. "options": {
  33893. "type": "object",
  33894. "properties": {
  33895. "symlink": { "type": ["boolean", "null"] }
  33896. },
  33897. "additionalProperties": true
  33898. }
  33899. }
  33900. },
  33901. "artifact-repository": {
  33902. "type": "object",
  33903. "required": ["type", "url"],
  33904. "properties": {
  33905. "type": { "type": "string", "enum": ["artifact"] },
  33906. "url": { "type": "string" },
  33907. "canonical": { "type": "boolean" },
  33908. "only": {
  33909. "type": "array",
  33910. "items": {
  33911. "type": "string"
  33912. }
  33913. },
  33914. "exclude": {
  33915. "type": "array",
  33916. "items": {
  33917. "type": "string"
  33918. }
  33919. }
  33920. }
  33921. },
  33922. "pear-repository": {
  33923. "type": "object",
  33924. "required": ["type", "url"],
  33925. "properties": {
  33926. "type": { "type": "string", "enum": ["pear"] },
  33927. "url": { "type": "string" },
  33928. "canonical": { "type": "boolean" },
  33929. "only": {
  33930. "type": "array",
  33931. "items": {
  33932. "type": "string"
  33933. }
  33934. },
  33935. "exclude": {
  33936. "type": "array",
  33937. "items": {
  33938. "type": "string"
  33939. }
  33940. },
  33941. "vendor-alias": { "type": "string" }
  33942. }
  33943. },
  33944. "package-repository": {
  33945. "type": "object",
  33946. "required": ["type", "package"],
  33947. "properties": {
  33948. "type": { "type": "string", "enum": ["package"] },
  33949. "canonical": { "type": "boolean" },
  33950. "only": {
  33951. "type": "array",
  33952. "items": {
  33953. "type": "string"
  33954. }
  33955. },
  33956. "exclude": {
  33957. "type": "array",
  33958. "items": {
  33959. "type": "string"
  33960. }
  33961. },
  33962. "package": {
  33963. "oneOf": [
  33964. { "$ref": "#/definitions/inline-package" },
  33965. {
  33966. "type": "array",
  33967. "items": { "$ref": "#/definitions/inline-package" }
  33968. }
  33969. ]
  33970. }
  33971. }
  33972. },
  33973. "inline-package": {
  33974. "type": "object",
  33975. "required": ["name", "version"],
  33976. "properties": {
  33977. "name": {
  33978. "type": "string",
  33979. "description": "Package name, including 'vendor-name/' prefix."
  33980. },
  33981. "type": {
  33982. "type": "string"
  33983. },
  33984. "target-dir": {
  33985. "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.",
  33986. "type": "string"
  33987. },
  33988. "description": {
  33989. "type": "string"
  33990. },
  33991. "keywords": {
  33992. "type": "array",
  33993. "items": {
  33994. "type": "string"
  33995. }
  33996. },
  33997. "homepage": {
  33998. "type": "string",
  33999. "format": "uri"
  34000. },
  34001. "version": {
  34002. "type": "string"
  34003. },
  34004. "time": {
  34005. "type": "string"
  34006. },
  34007. "license": {
  34008. "type": [
  34009. "string",
  34010. "array"
  34011. ]
  34012. },
  34013. "authors": {
  34014. "$ref": "#/definitions/authors"
  34015. },
  34016. "require": {
  34017. "type": "object",
  34018. "additionalProperties": {
  34019. "type": "string"
  34020. }
  34021. },
  34022. "replace": {
  34023. "type": "object",
  34024. "additionalProperties": {
  34025. "type": "string"
  34026. }
  34027. },
  34028. "conflict": {
  34029. "type": "object",
  34030. "additionalProperties": {
  34031. "type": "string"
  34032. }
  34033. },
  34034. "provide": {
  34035. "type": "object",
  34036. "additionalProperties": {
  34037. "type": "string"
  34038. }
  34039. },
  34040. "require-dev": {
  34041. "type": "object",
  34042. "additionalProperties": {
  34043. "type": "string"
  34044. }
  34045. },
  34046. "suggest": {
  34047. "type": "object",
  34048. "additionalProperties": {
  34049. "type": "string"
  34050. }
  34051. },
  34052. "extra": {
  34053. "type": ["object", "array"],
  34054. "additionalProperties": true
  34055. },
  34056. "autoload": {
  34057. "$ref": "#/definitions/autoload"
  34058. },
  34059. "archive": {
  34060. "type": ["object"],
  34061. "properties": {
  34062. "exclude": {
  34063. "type": "array"
  34064. }
  34065. }
  34066. },
  34067. "bin": {
  34068. "type": ["string", "array"],
  34069. "description": "A set of files, or a single file, that should be treated as binaries and symlinked into bin-dir (from config).",
  34070. "items": {
  34071. "type": "string"
  34072. }
  34073. },
  34074. "include-path": {
  34075. "type": ["array"],
  34076. "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.",
  34077. "items": {
  34078. "type": "string"
  34079. }
  34080. },
  34081. "source": {
  34082. "type": "object",
  34083. "required": ["type", "url", "reference"],
  34084. "properties": {
  34085. "type": {
  34086. "type": "string"
  34087. },
  34088. "url": {
  34089. "type": "string"
  34090. },
  34091. "reference": {
  34092. "type": "string"
  34093. },
  34094. "mirrors": {
  34095. "type": "array"
  34096. }
  34097. }
  34098. },
  34099. "dist": {
  34100. "type": "object",
  34101. "required": ["type", "url"],
  34102. "properties": {
  34103. "type": {
  34104. "type": "string"
  34105. },
  34106. "url": {
  34107. "type": "string"
  34108. },
  34109. "reference": {
  34110. "type": "string"
  34111. },
  34112. "shasum": {
  34113. "type": "string"
  34114. },
  34115. "mirrors": {
  34116. "type": "array"
  34117. }
  34118. }
  34119. }
  34120. },
  34121. "additionalProperties": true
  34122. }
  34123. }
  34124. }
  34125. {
  34126. "389-exception": [
  34127. "389 Directory Server Exception"
  34128. ],
  34129. "Autoconf-exception-2.0": [
  34130. "Autoconf exception 2.0"
  34131. ],
  34132. "Autoconf-exception-3.0": [
  34133. "Autoconf exception 3.0"
  34134. ],
  34135. "Bison-exception-2.2": [
  34136. "Bison exception 2.2"
  34137. ],
  34138. "Bootloader-exception": [
  34139. "Bootloader Distribution Exception"
  34140. ],
  34141. "Classpath-exception-2.0": [
  34142. "Classpath exception 2.0"
  34143. ],
  34144. "CLISP-exception-2.0": [
  34145. "CLISP exception 2.0"
  34146. ],
  34147. "DigiRule-FOSS-exception": [
  34148. "DigiRule FOSS License Exception"
  34149. ],
  34150. "eCos-exception-2.0": [
  34151. "eCos exception 2.0"
  34152. ],
  34153. "Fawkes-Runtime-exception": [
  34154. "Fawkes Runtime Exception"
  34155. ],
  34156. "FLTK-exception": [
  34157. "FLTK exception"
  34158. ],
  34159. "Font-exception-2.0": [
  34160. "Font exception 2.0"
  34161. ],
  34162. "freertos-exception-2.0": [
  34163. "FreeRTOS Exception 2.0"
  34164. ],
  34165. "GCC-exception-2.0": [
  34166. "GCC Runtime Library exception 2.0"
  34167. ],
  34168. "GCC-exception-3.1": [
  34169. "GCC Runtime Library exception 3.1"
  34170. ],
  34171. "gnu-javamail-exception": [
  34172. "GNU JavaMail exception"
  34173. ],
  34174. "GPL-3.0-linking-exception": [
  34175. "GPL-3.0 Linking Exception"
  34176. ],
  34177. "GPL-3.0-linking-source-exception": [
  34178. "GPL-3.0 Linking Exception (with Corresponding Source)"
  34179. ],
  34180. "GPL-CC-1.0": [
  34181. "GPL Cooperation Commitment 1.0"
  34182. ],
  34183. "i2p-gpl-java-exception": [
  34184. "i2p GPL+Java Exception"
  34185. ],
  34186. "LGPL-3.0-linking-exception": [
  34187. "LGPL-3.0 Linking Exception"
  34188. ],
  34189. "Libtool-exception": [
  34190. "Libtool Exception"
  34191. ],
  34192. "Linux-syscall-note": [
  34193. "Linux Syscall Note"
  34194. ],
  34195. "LLVM-exception": [
  34196. "LLVM Exception"
  34197. ],
  34198. "LZMA-exception": [
  34199. "LZMA exception"
  34200. ],
  34201. "mif-exception": [
  34202. "Macros and Inline Functions Exception"
  34203. ],
  34204. "Nokia-Qt-exception-1.1": [
  34205. "Nokia Qt LGPL exception 1.1"
  34206. ],
  34207. "OCaml-LGPL-linking-exception": [
  34208. "OCaml LGPL Linking Exception"
  34209. ],
  34210. "OCCT-exception-1.0": [
  34211. "Open CASCADE Exception 1.0"
  34212. ],
  34213. "OpenJDK-assembly-exception-1.0": [
  34214. "OpenJDK Assembly exception 1.0"
  34215. ],
  34216. "openvpn-openssl-exception": [
  34217. "OpenVPN OpenSSL Exception"
  34218. ],
  34219. "PS-or-PDF-font-exception-20170817": [
  34220. "PS/PDF font exception (2017-08-17)"
  34221. ],
  34222. "Qt-GPL-exception-1.0": [
  34223. "Qt GPL exception 1.0"
  34224. ],
  34225. "Qt-LGPL-exception-1.1": [
  34226. "Qt LGPL exception 1.1"
  34227. ],
  34228. "Qwt-exception-1.0": [
  34229. "Qwt exception 1.0"
  34230. ],
  34231. "SHL-2.0": [
  34232. "Solderpad Hardware License v2.0"
  34233. ],
  34234. "SHL-2.1": [
  34235. "Solderpad Hardware License v2.1"
  34236. ],
  34237. "Swift-exception": [
  34238. "Swift Exception"
  34239. ],
  34240. "u-boot-exception-2.0": [
  34241. "U-Boot exception 2.0"
  34242. ],
  34243. "Universal-FOSS-exception-1.0": [
  34244. "Universal FOSS Exception, Version 1.0"
  34245. ],
  34246. "WxWindows-exception-3.1": [
  34247. "WxWindows Library Exception 3.1"
  34248. ]
  34249. }{
  34250. "0BSD": [
  34251. "BSD Zero Clause License",
  34252. true,
  34253. false
  34254. ],
  34255. "AAL": [
  34256. "Attribution Assurance License",
  34257. true,
  34258. false
  34259. ],
  34260. "Abstyles": [
  34261. "Abstyles License",
  34262. false,
  34263. false
  34264. ],
  34265. "Adobe-2006": [
  34266. "Adobe Systems Incorporated Source Code License Agreement",
  34267. false,
  34268. false
  34269. ],
  34270. "Adobe-Glyph": [
  34271. "Adobe Glyph List License",
  34272. false,
  34273. false
  34274. ],
  34275. "ADSL": [
  34276. "Amazon Digital Services License",
  34277. false,
  34278. false
  34279. ],
  34280. "AFL-1.1": [
  34281. "Academic Free License v1.1",
  34282. true,
  34283. false
  34284. ],
  34285. "AFL-1.2": [
  34286. "Academic Free License v1.2",
  34287. true,
  34288. false
  34289. ],
  34290. "AFL-2.0": [
  34291. "Academic Free License v2.0",
  34292. true,
  34293. false
  34294. ],
  34295. "AFL-2.1": [
  34296. "Academic Free License v2.1",
  34297. true,
  34298. false
  34299. ],
  34300. "AFL-3.0": [
  34301. "Academic Free License v3.0",
  34302. true,
  34303. false
  34304. ],
  34305. "Afmparse": [
  34306. "Afmparse License",
  34307. false,
  34308. false
  34309. ],
  34310. "AGPL-1.0": [
  34311. "Affero General Public License v1.0",
  34312. false,
  34313. true
  34314. ],
  34315. "AGPL-1.0-only": [
  34316. "Affero General Public License v1.0 only",
  34317. false,
  34318. false
  34319. ],
  34320. "AGPL-1.0-or-later": [
  34321. "Affero General Public License v1.0 or later",
  34322. false,
  34323. false
  34324. ],
  34325. "AGPL-3.0": [
  34326. "GNU Affero General Public License v3.0",
  34327. true,
  34328. true
  34329. ],
  34330. "AGPL-3.0-only": [
  34331. "GNU Affero General Public License v3.0 only",
  34332. true,
  34333. false
  34334. ],
  34335. "AGPL-3.0-or-later": [
  34336. "GNU Affero General Public License v3.0 or later",
  34337. true,
  34338. false
  34339. ],
  34340. "Aladdin": [
  34341. "Aladdin Free Public License",
  34342. false,
  34343. false
  34344. ],
  34345. "AMDPLPA": [
  34346. "AMD's plpa_map.c License",
  34347. false,
  34348. false
  34349. ],
  34350. "AML": [
  34351. "Apple MIT License",
  34352. false,
  34353. false
  34354. ],
  34355. "AMPAS": [
  34356. "Academy of Motion Picture Arts and Sciences BSD",
  34357. false,
  34358. false
  34359. ],
  34360. "ANTLR-PD": [
  34361. "ANTLR Software Rights Notice",
  34362. false,
  34363. false
  34364. ],
  34365. "Apache-1.0": [
  34366. "Apache License 1.0",
  34367. false,
  34368. false
  34369. ],
  34370. "Apache-1.1": [
  34371. "Apache License 1.1",
  34372. true,
  34373. false
  34374. ],
  34375. "Apache-2.0": [
  34376. "Apache License 2.0",
  34377. true,
  34378. false
  34379. ],
  34380. "APAFML": [
  34381. "Adobe Postscript AFM License",
  34382. false,
  34383. false
  34384. ],
  34385. "APL-1.0": [
  34386. "Adaptive Public License 1.0",
  34387. true,
  34388. false
  34389. ],
  34390. "APSL-1.0": [
  34391. "Apple Public Source License 1.0",
  34392. true,
  34393. false
  34394. ],
  34395. "APSL-1.1": [
  34396. "Apple Public Source License 1.1",
  34397. true,
  34398. false
  34399. ],
  34400. "APSL-1.2": [
  34401. "Apple Public Source License 1.2",
  34402. true,
  34403. false
  34404. ],
  34405. "APSL-2.0": [
  34406. "Apple Public Source License 2.0",
  34407. true,
  34408. false
  34409. ],
  34410. "Artistic-1.0": [
  34411. "Artistic License 1.0",
  34412. true,
  34413. false
  34414. ],
  34415. "Artistic-1.0-cl8": [
  34416. "Artistic License 1.0 w/clause 8",
  34417. true,
  34418. false
  34419. ],
  34420. "Artistic-1.0-Perl": [
  34421. "Artistic License 1.0 (Perl)",
  34422. true,
  34423. false
  34424. ],
  34425. "Artistic-2.0": [
  34426. "Artistic License 2.0",
  34427. true,
  34428. false
  34429. ],
  34430. "Bahyph": [
  34431. "Bahyph License",
  34432. false,
  34433. false
  34434. ],
  34435. "Barr": [
  34436. "Barr License",
  34437. false,
  34438. false
  34439. ],
  34440. "Beerware": [
  34441. "Beerware License",
  34442. false,
  34443. false
  34444. ],
  34445. "BitTorrent-1.0": [
  34446. "BitTorrent Open Source License v1.0",
  34447. false,
  34448. false
  34449. ],
  34450. "BitTorrent-1.1": [
  34451. "BitTorrent Open Source License v1.1",
  34452. false,
  34453. false
  34454. ],
  34455. "blessing": [
  34456. "SQLite Blessing",
  34457. false,
  34458. false
  34459. ],
  34460. "BlueOak-1.0.0": [
  34461. "Blue Oak Model License 1.0.0",
  34462. false,
  34463. false
  34464. ],
  34465. "Borceux": [
  34466. "Borceux license",
  34467. false,
  34468. false
  34469. ],
  34470. "BSD-1-Clause": [
  34471. "BSD 1-Clause License",
  34472. true,
  34473. false
  34474. ],
  34475. "BSD-2-Clause": [
  34476. "BSD 2-Clause \"Simplified\" License",
  34477. true,
  34478. false
  34479. ],
  34480. "BSD-2-Clause-FreeBSD": [
  34481. "BSD 2-Clause FreeBSD License",
  34482. false,
  34483. false
  34484. ],
  34485. "BSD-2-Clause-NetBSD": [
  34486. "BSD 2-Clause NetBSD License",
  34487. false,
  34488. true
  34489. ],
  34490. "BSD-2-Clause-Patent": [
  34491. "BSD-2-Clause Plus Patent License",
  34492. true,
  34493. false
  34494. ],
  34495. "BSD-3-Clause": [
  34496. "BSD 3-Clause \"New\" or \"Revised\" License",
  34497. true,
  34498. false
  34499. ],
  34500. "BSD-3-Clause-Attribution": [
  34501. "BSD with attribution",
  34502. false,
  34503. false
  34504. ],
  34505. "BSD-3-Clause-Clear": [
  34506. "BSD 3-Clause Clear License",
  34507. false,
  34508. false
  34509. ],
  34510. "BSD-3-Clause-LBNL": [
  34511. "Lawrence Berkeley National Labs BSD variant license",
  34512. true,
  34513. false
  34514. ],
  34515. "BSD-3-Clause-No-Nuclear-License": [
  34516. "BSD 3-Clause No Nuclear License",
  34517. false,
  34518. false
  34519. ],
  34520. "BSD-3-Clause-No-Nuclear-License-2014": [
  34521. "BSD 3-Clause No Nuclear License 2014",
  34522. false,
  34523. false
  34524. ],
  34525. "BSD-3-Clause-No-Nuclear-Warranty": [
  34526. "BSD 3-Clause No Nuclear Warranty",
  34527. false,
  34528. false
  34529. ],
  34530. "BSD-3-Clause-Open-MPI": [
  34531. "BSD 3-Clause Open MPI variant",
  34532. false,
  34533. false
  34534. ],
  34535. "BSD-4-Clause": [
  34536. "BSD 4-Clause \"Original\" or \"Old\" License",
  34537. false,
  34538. false
  34539. ],
  34540. "BSD-4-Clause-UC": [
  34541. "BSD-4-Clause (University of California-Specific)",
  34542. false,
  34543. false
  34544. ],
  34545. "BSD-Protection": [
  34546. "BSD Protection License",
  34547. false,
  34548. false
  34549. ],
  34550. "BSD-Source-Code": [
  34551. "BSD Source Code Attribution",
  34552. false,
  34553. false
  34554. ],
  34555. "BSL-1.0": [
  34556. "Boost Software License 1.0",
  34557. true,
  34558. false
  34559. ],
  34560. "bzip2-1.0.5": [
  34561. "bzip2 and libbzip2 License v1.0.5",
  34562. false,
  34563. false
  34564. ],
  34565. "bzip2-1.0.6": [
  34566. "bzip2 and libbzip2 License v1.0.6",
  34567. false,
  34568. false
  34569. ],
  34570. "CAL-1.0": [
  34571. "Cryptographic Autonomy License 1.0",
  34572. true,
  34573. false
  34574. ],
  34575. "CAL-1.0-Combined-Work-Exception": [
  34576. "Cryptographic Autonomy License 1.0 (Combined Work Exception)",
  34577. true,
  34578. false
  34579. ],
  34580. "Caldera": [
  34581. "Caldera License",
  34582. false,
  34583. false
  34584. ],
  34585. "CATOSL-1.1": [
  34586. "Computer Associates Trusted Open Source License 1.1",
  34587. true,
  34588. false
  34589. ],
  34590. "CC-BY-1.0": [
  34591. "Creative Commons Attribution 1.0 Generic",
  34592. false,
  34593. false
  34594. ],
  34595. "CC-BY-2.0": [
  34596. "Creative Commons Attribution 2.0 Generic",
  34597. false,
  34598. false
  34599. ],
  34600. "CC-BY-2.5": [
  34601. "Creative Commons Attribution 2.5 Generic",
  34602. false,
  34603. false
  34604. ],
  34605. "CC-BY-3.0": [
  34606. "Creative Commons Attribution 3.0 Unported",
  34607. false,
  34608. false
  34609. ],
  34610. "CC-BY-4.0": [
  34611. "Creative Commons Attribution 4.0 International",
  34612. false,
  34613. false
  34614. ],
  34615. "CC-BY-NC-1.0": [
  34616. "Creative Commons Attribution Non Commercial 1.0 Generic",
  34617. false,
  34618. false
  34619. ],
  34620. "CC-BY-NC-2.0": [
  34621. "Creative Commons Attribution Non Commercial 2.0 Generic",
  34622. false,
  34623. false
  34624. ],
  34625. "CC-BY-NC-2.5": [
  34626. "Creative Commons Attribution Non Commercial 2.5 Generic",
  34627. false,
  34628. false
  34629. ],
  34630. "CC-BY-NC-3.0": [
  34631. "Creative Commons Attribution Non Commercial 3.0 Unported",
  34632. false,
  34633. false
  34634. ],
  34635. "CC-BY-NC-4.0": [
  34636. "Creative Commons Attribution Non Commercial 4.0 International",
  34637. false,
  34638. false
  34639. ],
  34640. "CC-BY-NC-ND-1.0": [
  34641. "Creative Commons Attribution Non Commercial No Derivatives 1.0 Generic",
  34642. false,
  34643. false
  34644. ],
  34645. "CC-BY-NC-ND-2.0": [
  34646. "Creative Commons Attribution Non Commercial No Derivatives 2.0 Generic",
  34647. false,
  34648. false
  34649. ],
  34650. "CC-BY-NC-ND-2.5": [
  34651. "Creative Commons Attribution Non Commercial No Derivatives 2.5 Generic",
  34652. false,
  34653. false
  34654. ],
  34655. "CC-BY-NC-ND-3.0": [
  34656. "Creative Commons Attribution Non Commercial No Derivatives 3.0 Unported",
  34657. false,
  34658. false
  34659. ],
  34660. "CC-BY-NC-ND-4.0": [
  34661. "Creative Commons Attribution Non Commercial No Derivatives 4.0 International",
  34662. false,
  34663. false
  34664. ],
  34665. "CC-BY-NC-SA-1.0": [
  34666. "Creative Commons Attribution Non Commercial Share Alike 1.0 Generic",
  34667. false,
  34668. false
  34669. ],
  34670. "CC-BY-NC-SA-2.0": [
  34671. "Creative Commons Attribution Non Commercial Share Alike 2.0 Generic",
  34672. false,
  34673. false
  34674. ],
  34675. "CC-BY-NC-SA-2.5": [
  34676. "Creative Commons Attribution Non Commercial Share Alike 2.5 Generic",
  34677. false,
  34678. false
  34679. ],
  34680. "CC-BY-NC-SA-3.0": [
  34681. "Creative Commons Attribution Non Commercial Share Alike 3.0 Unported",
  34682. false,
  34683. false
  34684. ],
  34685. "CC-BY-NC-SA-4.0": [
  34686. "Creative Commons Attribution Non Commercial Share Alike 4.0 International",
  34687. false,
  34688. false
  34689. ],
  34690. "CC-BY-ND-1.0": [
  34691. "Creative Commons Attribution No Derivatives 1.0 Generic",
  34692. false,
  34693. false
  34694. ],
  34695. "CC-BY-ND-2.0": [
  34696. "Creative Commons Attribution No Derivatives 2.0 Generic",
  34697. false,
  34698. false
  34699. ],
  34700. "CC-BY-ND-2.5": [
  34701. "Creative Commons Attribution No Derivatives 2.5 Generic",
  34702. false,
  34703. false
  34704. ],
  34705. "CC-BY-ND-3.0": [
  34706. "Creative Commons Attribution No Derivatives 3.0 Unported",
  34707. false,
  34708. false
  34709. ],
  34710. "CC-BY-ND-4.0": [
  34711. "Creative Commons Attribution No Derivatives 4.0 International",
  34712. false,
  34713. false
  34714. ],
  34715. "CC-BY-SA-1.0": [
  34716. "Creative Commons Attribution Share Alike 1.0 Generic",
  34717. false,
  34718. false
  34719. ],
  34720. "CC-BY-SA-2.0": [
  34721. "Creative Commons Attribution Share Alike 2.0 Generic",
  34722. false,
  34723. false
  34724. ],
  34725. "CC-BY-SA-2.5": [
  34726. "Creative Commons Attribution Share Alike 2.5 Generic",
  34727. false,
  34728. false
  34729. ],
  34730. "CC-BY-SA-3.0": [
  34731. "Creative Commons Attribution Share Alike 3.0 Unported",
  34732. false,
  34733. false
  34734. ],
  34735. "CC-BY-SA-4.0": [
  34736. "Creative Commons Attribution Share Alike 4.0 International",
  34737. false,
  34738. false
  34739. ],
  34740. "CC-PDDC": [
  34741. "Creative Commons Public Domain Dedication and Certification",
  34742. false,
  34743. false
  34744. ],
  34745. "CC0-1.0": [
  34746. "Creative Commons Zero v1.0 Universal",
  34747. false,
  34748. false
  34749. ],
  34750. "CDDL-1.0": [
  34751. "Common Development and Distribution License 1.0",
  34752. true,
  34753. false
  34754. ],
  34755. "CDDL-1.1": [
  34756. "Common Development and Distribution License 1.1",
  34757. false,
  34758. false
  34759. ],
  34760. "CDLA-Permissive-1.0": [
  34761. "Community Data License Agreement Permissive 1.0",
  34762. false,
  34763. false
  34764. ],
  34765. "CDLA-Sharing-1.0": [
  34766. "Community Data License Agreement Sharing 1.0",
  34767. false,
  34768. false
  34769. ],
  34770. "CECILL-1.0": [
  34771. "CeCILL Free Software License Agreement v1.0",
  34772. false,
  34773. false
  34774. ],
  34775. "CECILL-1.1": [
  34776. "CeCILL Free Software License Agreement v1.1",
  34777. false,
  34778. false
  34779. ],
  34780. "CECILL-2.0": [
  34781. "CeCILL Free Software License Agreement v2.0",
  34782. false,
  34783. false
  34784. ],
  34785. "CECILL-2.1": [
  34786. "CeCILL Free Software License Agreement v2.1",
  34787. true,
  34788. false
  34789. ],
  34790. "CECILL-B": [
  34791. "CeCILL-B Free Software License Agreement",
  34792. false,
  34793. false
  34794. ],
  34795. "CECILL-C": [
  34796. "CeCILL-C Free Software License Agreement",
  34797. false,
  34798. false
  34799. ],
  34800. "CERN-OHL-1.1": [
  34801. "CERN Open Hardware Licence v1.1",
  34802. false,
  34803. false
  34804. ],
  34805. "CERN-OHL-1.2": [
  34806. "CERN Open Hardware Licence v1.2",
  34807. false,
  34808. false
  34809. ],
  34810. "CERN-OHL-P-2.0": [
  34811. "CERN Open Hardware Licence Version 2 - Permissive",
  34812. false,
  34813. false
  34814. ],
  34815. "CERN-OHL-S-2.0": [
  34816. "CERN Open Hardware Licence Version 2 - Strongly Reciprocal",
  34817. false,
  34818. false
  34819. ],
  34820. "CERN-OHL-W-2.0": [
  34821. "CERN Open Hardware Licence Version 2 - Weakly Reciprocal",
  34822. false,
  34823. false
  34824. ],
  34825. "ClArtistic": [
  34826. "Clarified Artistic License",
  34827. false,
  34828. false
  34829. ],
  34830. "CNRI-Jython": [
  34831. "CNRI Jython License",
  34832. false,
  34833. false
  34834. ],
  34835. "CNRI-Python": [
  34836. "CNRI Python License",
  34837. true,
  34838. false
  34839. ],
  34840. "CNRI-Python-GPL-Compatible": [
  34841. "CNRI Python Open Source GPL Compatible License Agreement",
  34842. false,
  34843. false
  34844. ],
  34845. "Condor-1.1": [
  34846. "Condor Public License v1.1",
  34847. false,
  34848. false
  34849. ],
  34850. "copyleft-next-0.3.0": [
  34851. "copyleft-next 0.3.0",
  34852. false,
  34853. false
  34854. ],
  34855. "copyleft-next-0.3.1": [
  34856. "copyleft-next 0.3.1",
  34857. false,
  34858. false
  34859. ],
  34860. "CPAL-1.0": [
  34861. "Common Public Attribution License 1.0",
  34862. true,
  34863. false
  34864. ],
  34865. "CPL-1.0": [
  34866. "Common Public License 1.0",
  34867. true,
  34868. false
  34869. ],
  34870. "CPOL-1.02": [
  34871. "Code Project Open License 1.02",
  34872. false,
  34873. false
  34874. ],
  34875. "Crossword": [
  34876. "Crossword License",
  34877. false,
  34878. false
  34879. ],
  34880. "CrystalStacker": [
  34881. "CrystalStacker License",
  34882. false,
  34883. false
  34884. ],
  34885. "CUA-OPL-1.0": [
  34886. "CUA Office Public License v1.0",
  34887. true,
  34888. false
  34889. ],
  34890. "Cube": [
  34891. "Cube License",
  34892. false,
  34893. false
  34894. ],
  34895. "curl": [
  34896. "curl License",
  34897. false,
  34898. false
  34899. ],
  34900. "D-FSL-1.0": [
  34901. "Deutsche Freie Software Lizenz",
  34902. false,
  34903. false
  34904. ],
  34905. "diffmark": [
  34906. "diffmark license",
  34907. false,
  34908. false
  34909. ],
  34910. "DOC": [
  34911. "DOC License",
  34912. false,
  34913. false
  34914. ],
  34915. "Dotseqn": [
  34916. "Dotseqn License",
  34917. false,
  34918. false
  34919. ],
  34920. "DSDP": [
  34921. "DSDP License",
  34922. false,
  34923. false
  34924. ],
  34925. "dvipdfm": [
  34926. "dvipdfm License",
  34927. false,
  34928. false
  34929. ],
  34930. "ECL-1.0": [
  34931. "Educational Community License v1.0",
  34932. true,
  34933. false
  34934. ],
  34935. "ECL-2.0": [
  34936. "Educational Community License v2.0",
  34937. true,
  34938. false
  34939. ],
  34940. "eCos-2.0": [
  34941. "eCos license version 2.0",
  34942. false,
  34943. true
  34944. ],
  34945. "EFL-1.0": [
  34946. "Eiffel Forum License v1.0",
  34947. true,
  34948. false
  34949. ],
  34950. "EFL-2.0": [
  34951. "Eiffel Forum License v2.0",
  34952. true,
  34953. false
  34954. ],
  34955. "eGenix": [
  34956. "eGenix.com Public License 1.1.0",
  34957. false,
  34958. false
  34959. ],
  34960. "Entessa": [
  34961. "Entessa Public License v1.0",
  34962. true,
  34963. false
  34964. ],
  34965. "EPL-1.0": [
  34966. "Eclipse Public License 1.0",
  34967. true,
  34968. false
  34969. ],
  34970. "EPL-2.0": [
  34971. "Eclipse Public License 2.0",
  34972. true,
  34973. false
  34974. ],
  34975. "ErlPL-1.1": [
  34976. "Erlang Public License v1.1",
  34977. false,
  34978. false
  34979. ],
  34980. "etalab-2.0": [
  34981. "Etalab Open License 2.0",
  34982. false,
  34983. false
  34984. ],
  34985. "EUDatagrid": [
  34986. "EU DataGrid Software License",
  34987. true,
  34988. false
  34989. ],
  34990. "EUPL-1.0": [
  34991. "European Union Public License 1.0",
  34992. false,
  34993. false
  34994. ],
  34995. "EUPL-1.1": [
  34996. "European Union Public License 1.1",
  34997. true,
  34998. false
  34999. ],
  35000. "EUPL-1.2": [
  35001. "European Union Public License 1.2",
  35002. true,
  35003. false
  35004. ],
  35005. "Eurosym": [
  35006. "Eurosym License",
  35007. false,
  35008. false
  35009. ],
  35010. "Fair": [
  35011. "Fair License",
  35012. true,
  35013. false
  35014. ],
  35015. "Frameworx-1.0": [
  35016. "Frameworx Open License 1.0",
  35017. true,
  35018. false
  35019. ],
  35020. "FreeImage": [
  35021. "FreeImage Public License v1.0",
  35022. false,
  35023. false
  35024. ],
  35025. "FSFAP": [
  35026. "FSF All Permissive License",
  35027. false,
  35028. false
  35029. ],
  35030. "FSFUL": [
  35031. "FSF Unlimited License",
  35032. false,
  35033. false
  35034. ],
  35035. "FSFULLR": [
  35036. "FSF Unlimited License (with License Retention)",
  35037. false,
  35038. false
  35039. ],
  35040. "FTL": [
  35041. "Freetype Project License",
  35042. false,
  35043. false
  35044. ],
  35045. "GFDL-1.1": [
  35046. "GNU Free Documentation License v1.1",
  35047. false,
  35048. true
  35049. ],
  35050. "GFDL-1.1-only": [
  35051. "GNU Free Documentation License v1.1 only",
  35052. false,
  35053. false
  35054. ],
  35055. "GFDL-1.1-or-later": [
  35056. "GNU Free Documentation License v1.1 or later",
  35057. false,
  35058. false
  35059. ],
  35060. "GFDL-1.2": [
  35061. "GNU Free Documentation License v1.2",
  35062. false,
  35063. true
  35064. ],
  35065. "GFDL-1.2-only": [
  35066. "GNU Free Documentation License v1.2 only",
  35067. false,
  35068. false
  35069. ],
  35070. "GFDL-1.2-or-later": [
  35071. "GNU Free Documentation License v1.2 or later",
  35072. false,
  35073. false
  35074. ],
  35075. "GFDL-1.3": [
  35076. "GNU Free Documentation License v1.3",
  35077. false,
  35078. true
  35079. ],
  35080. "GFDL-1.3-only": [
  35081. "GNU Free Documentation License v1.3 only",
  35082. false,
  35083. false
  35084. ],
  35085. "GFDL-1.3-or-later": [
  35086. "GNU Free Documentation License v1.3 or later",
  35087. false,
  35088. false
  35089. ],
  35090. "Giftware": [
  35091. "Giftware License",
  35092. false,
  35093. false
  35094. ],
  35095. "GL2PS": [
  35096. "GL2PS License",
  35097. false,
  35098. false
  35099. ],
  35100. "Glide": [
  35101. "3dfx Glide License",
  35102. false,
  35103. false
  35104. ],
  35105. "Glulxe": [
  35106. "Glulxe License",
  35107. false,
  35108. false
  35109. ],
  35110. "gnuplot": [
  35111. "gnuplot License",
  35112. false,
  35113. false
  35114. ],
  35115. "GPL-1.0": [
  35116. "GNU General Public License v1.0 only",
  35117. false,
  35118. true
  35119. ],
  35120. "GPL-1.0+": [
  35121. "GNU General Public License v1.0 or later",
  35122. false,
  35123. true
  35124. ],
  35125. "GPL-1.0-only": [
  35126. "GNU General Public License v1.0 only",
  35127. false,
  35128. false
  35129. ],
  35130. "GPL-1.0-or-later": [
  35131. "GNU General Public License v1.0 or later",
  35132. false,
  35133. false
  35134. ],
  35135. "GPL-2.0": [
  35136. "GNU General Public License v2.0 only",
  35137. true,
  35138. true
  35139. ],
  35140. "GPL-2.0+": [
  35141. "GNU General Public License v2.0 or later",
  35142. true,
  35143. true
  35144. ],
  35145. "GPL-2.0-only": [
  35146. "GNU General Public License v2.0 only",
  35147. true,
  35148. false
  35149. ],
  35150. "GPL-2.0-or-later": [
  35151. "GNU General Public License v2.0 or later",
  35152. true,
  35153. false
  35154. ],
  35155. "GPL-2.0-with-autoconf-exception": [
  35156. "GNU General Public License v2.0 w/Autoconf exception",
  35157. false,
  35158. true
  35159. ],
  35160. "GPL-2.0-with-bison-exception": [
  35161. "GNU General Public License v2.0 w/Bison exception",
  35162. false,
  35163. true
  35164. ],
  35165. "GPL-2.0-with-classpath-exception": [
  35166. "GNU General Public License v2.0 w/Classpath exception",
  35167. false,
  35168. true
  35169. ],
  35170. "GPL-2.0-with-font-exception": [
  35171. "GNU General Public License v2.0 w/Font exception",
  35172. false,
  35173. true
  35174. ],
  35175. "GPL-2.0-with-GCC-exception": [
  35176. "GNU General Public License v2.0 w/GCC Runtime Library exception",
  35177. false,
  35178. true
  35179. ],
  35180. "GPL-3.0": [
  35181. "GNU General Public License v3.0 only",
  35182. true,
  35183. true
  35184. ],
  35185. "GPL-3.0+": [
  35186. "GNU General Public License v3.0 or later",
  35187. true,
  35188. true
  35189. ],
  35190. "GPL-3.0-only": [
  35191. "GNU General Public License v3.0 only",
  35192. true,
  35193. false
  35194. ],
  35195. "GPL-3.0-or-later": [
  35196. "GNU General Public License v3.0 or later",
  35197. true,
  35198. false
  35199. ],
  35200. "GPL-3.0-with-autoconf-exception": [
  35201. "GNU General Public License v3.0 w/Autoconf exception",
  35202. false,
  35203. true
  35204. ],
  35205. "GPL-3.0-with-GCC-exception": [
  35206. "GNU General Public License v3.0 w/GCC Runtime Library exception",
  35207. true,
  35208. true
  35209. ],
  35210. "gSOAP-1.3b": [
  35211. "gSOAP Public License v1.3b",
  35212. false,
  35213. false
  35214. ],
  35215. "HaskellReport": [
  35216. "Haskell Language Report License",
  35217. false,
  35218. false
  35219. ],
  35220. "Hippocratic-2.1": [
  35221. "Hippocratic License 2.1",
  35222. false,
  35223. false
  35224. ],
  35225. "HPND": [
  35226. "Historical Permission Notice and Disclaimer",
  35227. true,
  35228. false
  35229. ],
  35230. "HPND-sell-variant": [
  35231. "Historical Permission Notice and Disclaimer - sell variant",
  35232. false,
  35233. false
  35234. ],
  35235. "IBM-pibs": [
  35236. "IBM PowerPC Initialization and Boot Software",
  35237. false,
  35238. false
  35239. ],
  35240. "ICU": [
  35241. "ICU License",
  35242. false,
  35243. false
  35244. ],
  35245. "IJG": [
  35246. "Independent JPEG Group License",
  35247. false,
  35248. false
  35249. ],
  35250. "ImageMagick": [
  35251. "ImageMagick License",
  35252. false,
  35253. false
  35254. ],
  35255. "iMatix": [
  35256. "iMatix Standard Function Library Agreement",
  35257. false,
  35258. false
  35259. ],
  35260. "Imlib2": [
  35261. "Imlib2 License",
  35262. false,
  35263. false
  35264. ],
  35265. "Info-ZIP": [
  35266. "Info-ZIP License",
  35267. false,
  35268. false
  35269. ],
  35270. "Intel": [
  35271. "Intel Open Source License",
  35272. true,
  35273. false
  35274. ],
  35275. "Intel-ACPI": [
  35276. "Intel ACPI Software License Agreement",
  35277. false,
  35278. false
  35279. ],
  35280. "Interbase-1.0": [
  35281. "Interbase Public License v1.0",
  35282. false,
  35283. false
  35284. ],
  35285. "IPA": [
  35286. "IPA Font License",
  35287. true,
  35288. false
  35289. ],
  35290. "IPL-1.0": [
  35291. "IBM Public License v1.0",
  35292. true,
  35293. false
  35294. ],
  35295. "ISC": [
  35296. "ISC License",
  35297. true,
  35298. false
  35299. ],
  35300. "JasPer-2.0": [
  35301. "JasPer License",
  35302. false,
  35303. false
  35304. ],
  35305. "JPNIC": [
  35306. "Japan Network Information Center License",
  35307. false,
  35308. false
  35309. ],
  35310. "JSON": [
  35311. "JSON License",
  35312. false,
  35313. false
  35314. ],
  35315. "LAL-1.2": [
  35316. "Licence Art Libre 1.2",
  35317. false,
  35318. false
  35319. ],
  35320. "LAL-1.3": [
  35321. "Licence Art Libre 1.3",
  35322. false,
  35323. false
  35324. ],
  35325. "Latex2e": [
  35326. "Latex2e License",
  35327. false,
  35328. false
  35329. ],
  35330. "Leptonica": [
  35331. "Leptonica License",
  35332. false,
  35333. false
  35334. ],
  35335. "LGPL-2.0": [
  35336. "GNU Library General Public License v2 only",
  35337. true,
  35338. true
  35339. ],
  35340. "LGPL-2.0+": [
  35341. "GNU Library General Public License v2 or later",
  35342. true,
  35343. true
  35344. ],
  35345. "LGPL-2.0-only": [
  35346. "GNU Library General Public License v2 only",
  35347. true,
  35348. false
  35349. ],
  35350. "LGPL-2.0-or-later": [
  35351. "GNU Library General Public License v2 or later",
  35352. true,
  35353. false
  35354. ],
  35355. "LGPL-2.1": [
  35356. "GNU Lesser General Public License v2.1 only",
  35357. true,
  35358. true
  35359. ],
  35360. "LGPL-2.1+": [
  35361. "GNU Library General Public License v2.1 or later",
  35362. true,
  35363. true
  35364. ],
  35365. "LGPL-2.1-only": [
  35366. "GNU Lesser General Public License v2.1 only",
  35367. true,
  35368. false
  35369. ],
  35370. "LGPL-2.1-or-later": [
  35371. "GNU Lesser General Public License v2.1 or later",
  35372. true,
  35373. false
  35374. ],
  35375. "LGPL-3.0": [
  35376. "GNU Lesser General Public License v3.0 only",
  35377. true,
  35378. true
  35379. ],
  35380. "LGPL-3.0+": [
  35381. "GNU Lesser General Public License v3.0 or later",
  35382. true,
  35383. true
  35384. ],
  35385. "LGPL-3.0-only": [
  35386. "GNU Lesser General Public License v3.0 only",
  35387. true,
  35388. false
  35389. ],
  35390. "LGPL-3.0-or-later": [
  35391. "GNU Lesser General Public License v3.0 or later",
  35392. true,
  35393. false
  35394. ],
  35395. "LGPLLR": [
  35396. "Lesser General Public License For Linguistic Resources",
  35397. false,
  35398. false
  35399. ],
  35400. "Libpng": [
  35401. "libpng License",
  35402. false,
  35403. false
  35404. ],
  35405. "libpng-2.0": [
  35406. "PNG Reference Library version 2",
  35407. false,
  35408. false
  35409. ],
  35410. "libselinux-1.0": [
  35411. "libselinux public domain notice",
  35412. false,
  35413. false
  35414. ],
  35415. "libtiff": [
  35416. "libtiff License",
  35417. false,
  35418. false
  35419. ],
  35420. "LiLiQ-P-1.1": [
  35421. "Licence Libre du Qu\u00e9bec \u2013 Permissive version 1.1",
  35422. true,
  35423. false
  35424. ],
  35425. "LiLiQ-R-1.1": [
  35426. "Licence Libre du Qu\u00e9bec \u2013 R\u00e9ciprocit\u00e9 version 1.1",
  35427. true,
  35428. false
  35429. ],
  35430. "LiLiQ-Rplus-1.1": [
  35431. "Licence Libre du Qu\u00e9bec \u2013 R\u00e9ciprocit\u00e9 forte version 1.1",
  35432. true,
  35433. false
  35434. ],
  35435. "Linux-OpenIB": [
  35436. "Linux Kernel Variant of OpenIB.org license",
  35437. false,
  35438. false
  35439. ],
  35440. "LPL-1.0": [
  35441. "Lucent Public License Version 1.0",
  35442. true,
  35443. false
  35444. ],
  35445. "LPL-1.02": [
  35446. "Lucent Public License v1.02",
  35447. true,
  35448. false
  35449. ],
  35450. "LPPL-1.0": [
  35451. "LaTeX Project Public License v1.0",
  35452. false,
  35453. false
  35454. ],
  35455. "LPPL-1.1": [
  35456. "LaTeX Project Public License v1.1",
  35457. false,
  35458. false
  35459. ],
  35460. "LPPL-1.2": [
  35461. "LaTeX Project Public License v1.2",
  35462. false,
  35463. false
  35464. ],
  35465. "LPPL-1.3a": [
  35466. "LaTeX Project Public License v1.3a",
  35467. false,
  35468. false
  35469. ],
  35470. "LPPL-1.3c": [
  35471. "LaTeX Project Public License v1.3c",
  35472. true,
  35473. false
  35474. ],
  35475. "MakeIndex": [
  35476. "MakeIndex License",
  35477. false,
  35478. false
  35479. ],
  35480. "MirOS": [
  35481. "The MirOS Licence",
  35482. true,
  35483. false
  35484. ],
  35485. "MIT": [
  35486. "MIT License",
  35487. true,
  35488. false
  35489. ],
  35490. "MIT-0": [
  35491. "MIT No Attribution",
  35492. false,
  35493. false
  35494. ],
  35495. "MIT-advertising": [
  35496. "Enlightenment License (e16)",
  35497. false,
  35498. false
  35499. ],
  35500. "MIT-CMU": [
  35501. "CMU License",
  35502. false,
  35503. false
  35504. ],
  35505. "MIT-enna": [
  35506. "enna License",
  35507. false,
  35508. false
  35509. ],
  35510. "MIT-feh": [
  35511. "feh License",
  35512. false,
  35513. false
  35514. ],
  35515. "MITNFA": [
  35516. "MIT +no-false-attribs license",
  35517. false,
  35518. false
  35519. ],
  35520. "Motosoto": [
  35521. "Motosoto License",
  35522. true,
  35523. false
  35524. ],
  35525. "mpich2": [
  35526. "mpich2 License",
  35527. false,
  35528. false
  35529. ],
  35530. "MPL-1.0": [
  35531. "Mozilla Public License 1.0",
  35532. true,
  35533. false
  35534. ],
  35535. "MPL-1.1": [
  35536. "Mozilla Public License 1.1",
  35537. true,
  35538. false
  35539. ],
  35540. "MPL-2.0": [
  35541. "Mozilla Public License 2.0",
  35542. true,
  35543. false
  35544. ],
  35545. "MPL-2.0-no-copyleft-exception": [
  35546. "Mozilla Public License 2.0 (no copyleft exception)",
  35547. true,
  35548. false
  35549. ],
  35550. "MS-PL": [
  35551. "Microsoft Public License",
  35552. true,
  35553. false
  35554. ],
  35555. "MS-RL": [
  35556. "Microsoft Reciprocal License",
  35557. true,
  35558. false
  35559. ],
  35560. "MTLL": [
  35561. "Matrix Template Library License",
  35562. false,
  35563. false
  35564. ],
  35565. "MulanPSL-1.0": [
  35566. "Mulan Permissive Software License, Version 1",
  35567. false,
  35568. false
  35569. ],
  35570. "MulanPSL-2.0": [
  35571. "Mulan Permissive Software License, Version 2",
  35572. true,
  35573. false
  35574. ],
  35575. "Multics": [
  35576. "Multics License",
  35577. true,
  35578. false
  35579. ],
  35580. "Mup": [
  35581. "Mup License",
  35582. false,
  35583. false
  35584. ],
  35585. "NASA-1.3": [
  35586. "NASA Open Source Agreement 1.3",
  35587. true,
  35588. false
  35589. ],
  35590. "Naumen": [
  35591. "Naumen Public License",
  35592. true,
  35593. false
  35594. ],
  35595. "NBPL-1.0": [
  35596. "Net Boolean Public License v1",
  35597. false,
  35598. false
  35599. ],
  35600. "NCGL-UK-2.0": [
  35601. "Non-Commercial Government Licence",
  35602. false,
  35603. false
  35604. ],
  35605. "NCSA": [
  35606. "University of Illinois/NCSA Open Source License",
  35607. true,
  35608. false
  35609. ],
  35610. "Net-SNMP": [
  35611. "Net-SNMP License",
  35612. false,
  35613. false
  35614. ],
  35615. "NetCDF": [
  35616. "NetCDF license",
  35617. false,
  35618. false
  35619. ],
  35620. "Newsletr": [
  35621. "Newsletr License",
  35622. false,
  35623. false
  35624. ],
  35625. "NGPL": [
  35626. "Nethack General Public License",
  35627. true,
  35628. false
  35629. ],
  35630. "NLOD-1.0": [
  35631. "Norwegian Licence for Open Government Data",
  35632. false,
  35633. false
  35634. ],
  35635. "NLPL": [
  35636. "No Limit Public License",
  35637. false,
  35638. false
  35639. ],
  35640. "Nokia": [
  35641. "Nokia Open Source License",
  35642. true,
  35643. false
  35644. ],
  35645. "NOSL": [
  35646. "Netizen Open Source License",
  35647. false,
  35648. false
  35649. ],
  35650. "Noweb": [
  35651. "Noweb License",
  35652. false,
  35653. false
  35654. ],
  35655. "NPL-1.0": [
  35656. "Netscape Public License v1.0",
  35657. false,
  35658. false
  35659. ],
  35660. "NPL-1.1": [
  35661. "Netscape Public License v1.1",
  35662. false,
  35663. false
  35664. ],
  35665. "NPOSL-3.0": [
  35666. "Non-Profit Open Software License 3.0",
  35667. true,
  35668. false
  35669. ],
  35670. "NRL": [
  35671. "NRL License",
  35672. false,
  35673. false
  35674. ],
  35675. "NTP": [
  35676. "NTP License",
  35677. true,
  35678. false
  35679. ],
  35680. "NTP-0": [
  35681. "NTP No Attribution",
  35682. false,
  35683. false
  35684. ],
  35685. "Nunit": [
  35686. "Nunit License",
  35687. false,
  35688. true
  35689. ],
  35690. "O-UDA-1.0": [
  35691. "Open Use of Data Agreement v1.0",
  35692. false,
  35693. false
  35694. ],
  35695. "OCCT-PL": [
  35696. "Open CASCADE Technology Public License",
  35697. false,
  35698. false
  35699. ],
  35700. "OCLC-2.0": [
  35701. "OCLC Research Public License 2.0",
  35702. true,
  35703. false
  35704. ],
  35705. "ODbL-1.0": [
  35706. "ODC Open Database License v1.0",
  35707. false,
  35708. false
  35709. ],
  35710. "ODC-By-1.0": [
  35711. "Open Data Commons Attribution License v1.0",
  35712. false,
  35713. false
  35714. ],
  35715. "OFL-1.0": [
  35716. "SIL Open Font License 1.0",
  35717. false,
  35718. false
  35719. ],
  35720. "OFL-1.0-no-RFN": [
  35721. "SIL Open Font License 1.0 with no Reserved Font Name",
  35722. false,
  35723. false
  35724. ],
  35725. "OFL-1.0-RFN": [
  35726. "SIL Open Font License 1.0 with Reserved Font Name",
  35727. false,
  35728. false
  35729. ],
  35730. "OFL-1.1": [
  35731. "SIL Open Font License 1.1",
  35732. true,
  35733. false
  35734. ],
  35735. "OFL-1.1-no-RFN": [
  35736. "SIL Open Font License 1.1 with no Reserved Font Name",
  35737. true,
  35738. false
  35739. ],
  35740. "OFL-1.1-RFN": [
  35741. "SIL Open Font License 1.1 with Reserved Font Name",
  35742. true,
  35743. false
  35744. ],
  35745. "OGC-1.0": [
  35746. "OGC Software License, Version 1.0",
  35747. false,
  35748. false
  35749. ],
  35750. "OGL-Canada-2.0": [
  35751. "Open Government Licence - Canada",
  35752. false,
  35753. false
  35754. ],
  35755. "OGL-UK-1.0": [
  35756. "Open Government Licence v1.0",
  35757. false,
  35758. false
  35759. ],
  35760. "OGL-UK-2.0": [
  35761. "Open Government Licence v2.0",
  35762. false,
  35763. false
  35764. ],
  35765. "OGL-UK-3.0": [
  35766. "Open Government Licence v3.0",
  35767. false,
  35768. false
  35769. ],
  35770. "OGTSL": [
  35771. "Open Group Test Suite License",
  35772. true,
  35773. false
  35774. ],
  35775. "OLDAP-1.1": [
  35776. "Open LDAP Public License v1.1",
  35777. false,
  35778. false
  35779. ],
  35780. "OLDAP-1.2": [
  35781. "Open LDAP Public License v1.2",
  35782. false,
  35783. false
  35784. ],
  35785. "OLDAP-1.3": [
  35786. "Open LDAP Public License v1.3",
  35787. false,
  35788. false
  35789. ],
  35790. "OLDAP-1.4": [
  35791. "Open LDAP Public License v1.4",
  35792. false,
  35793. false
  35794. ],
  35795. "OLDAP-2.0": [
  35796. "Open LDAP Public License v2.0 (or possibly 2.0A and 2.0B)",
  35797. false,
  35798. false
  35799. ],
  35800. "OLDAP-2.0.1": [
  35801. "Open LDAP Public License v2.0.1",
  35802. false,
  35803. false
  35804. ],
  35805. "OLDAP-2.1": [
  35806. "Open LDAP Public License v2.1",
  35807. false,
  35808. false
  35809. ],
  35810. "OLDAP-2.2": [
  35811. "Open LDAP Public License v2.2",
  35812. false,
  35813. false
  35814. ],
  35815. "OLDAP-2.2.1": [
  35816. "Open LDAP Public License v2.2.1",
  35817. false,
  35818. false
  35819. ],
  35820. "OLDAP-2.2.2": [
  35821. "Open LDAP Public License 2.2.2",
  35822. false,
  35823. false
  35824. ],
  35825. "OLDAP-2.3": [
  35826. "Open LDAP Public License v2.3",
  35827. false,
  35828. false
  35829. ],
  35830. "OLDAP-2.4": [
  35831. "Open LDAP Public License v2.4",
  35832. false,
  35833. false
  35834. ],
  35835. "OLDAP-2.5": [
  35836. "Open LDAP Public License v2.5",
  35837. false,
  35838. false
  35839. ],
  35840. "OLDAP-2.6": [
  35841. "Open LDAP Public License v2.6",
  35842. false,
  35843. false
  35844. ],
  35845. "OLDAP-2.7": [
  35846. "Open LDAP Public License v2.7",
  35847. false,
  35848. false
  35849. ],
  35850. "OLDAP-2.8": [
  35851. "Open LDAP Public License v2.8",
  35852. false,
  35853. false
  35854. ],
  35855. "OML": [
  35856. "Open Market License",
  35857. false,
  35858. false
  35859. ],
  35860. "OpenSSL": [
  35861. "OpenSSL License",
  35862. false,
  35863. false
  35864. ],
  35865. "OPL-1.0": [
  35866. "Open Public License v1.0",
  35867. false,
  35868. false
  35869. ],
  35870. "OSET-PL-2.1": [
  35871. "OSET Public License version 2.1",
  35872. true,
  35873. false
  35874. ],
  35875. "OSL-1.0": [
  35876. "Open Software License 1.0",
  35877. true,
  35878. false
  35879. ],
  35880. "OSL-1.1": [
  35881. "Open Software License 1.1",
  35882. false,
  35883. false
  35884. ],
  35885. "OSL-2.0": [
  35886. "Open Software License 2.0",
  35887. true,
  35888. false
  35889. ],
  35890. "OSL-2.1": [
  35891. "Open Software License 2.1",
  35892. true,
  35893. false
  35894. ],
  35895. "OSL-3.0": [
  35896. "Open Software License 3.0",
  35897. true,
  35898. false
  35899. ],
  35900. "Parity-6.0.0": [
  35901. "The Parity Public License 6.0.0",
  35902. false,
  35903. false
  35904. ],
  35905. "Parity-7.0.0": [
  35906. "The Parity Public License 7.0.0",
  35907. false,
  35908. false
  35909. ],
  35910. "PDDL-1.0": [
  35911. "ODC Public Domain Dedication & License 1.0",
  35912. false,
  35913. false
  35914. ],
  35915. "PHP-3.0": [
  35916. "PHP License v3.0",
  35917. true,
  35918. false
  35919. ],
  35920. "PHP-3.01": [
  35921. "PHP License v3.01",
  35922. false,
  35923. false
  35924. ],
  35925. "Plexus": [
  35926. "Plexus Classworlds License",
  35927. false,
  35928. false
  35929. ],
  35930. "PolyForm-Noncommercial-1.0.0": [
  35931. "PolyForm Noncommercial License 1.0.0",
  35932. false,
  35933. false
  35934. ],
  35935. "PolyForm-Small-Business-1.0.0": [
  35936. "PolyForm Small Business License 1.0.0",
  35937. false,
  35938. false
  35939. ],
  35940. "PostgreSQL": [
  35941. "PostgreSQL License",
  35942. true,
  35943. false
  35944. ],
  35945. "PSF-2.0": [
  35946. "Python Software Foundation License 2.0",
  35947. false,
  35948. false
  35949. ],
  35950. "psfrag": [
  35951. "psfrag License",
  35952. false,
  35953. false
  35954. ],
  35955. "psutils": [
  35956. "psutils License",
  35957. false,
  35958. false
  35959. ],
  35960. "Python-2.0": [
  35961. "Python License 2.0",
  35962. true,
  35963. false
  35964. ],
  35965. "Qhull": [
  35966. "Qhull License",
  35967. false,
  35968. false
  35969. ],
  35970. "QPL-1.0": [
  35971. "Q Public License 1.0",
  35972. true,
  35973. false
  35974. ],
  35975. "Rdisc": [
  35976. "Rdisc License",
  35977. false,
  35978. false
  35979. ],
  35980. "RHeCos-1.1": [
  35981. "Red Hat eCos Public License v1.1",
  35982. false,
  35983. false
  35984. ],
  35985. "RPL-1.1": [
  35986. "Reciprocal Public License 1.1",
  35987. true,
  35988. false
  35989. ],
  35990. "RPL-1.5": [
  35991. "Reciprocal Public License 1.5",
  35992. true,
  35993. false
  35994. ],
  35995. "RPSL-1.0": [
  35996. "RealNetworks Public Source License v1.0",
  35997. true,
  35998. false
  35999. ],
  36000. "RSA-MD": [
  36001. "RSA Message-Digest License",
  36002. false,
  36003. false
  36004. ],
  36005. "RSCPL": [
  36006. "Ricoh Source Code Public License",
  36007. true,
  36008. false
  36009. ],
  36010. "Ruby": [
  36011. "Ruby License",
  36012. false,
  36013. false
  36014. ],
  36015. "SAX-PD": [
  36016. "Sax Public Domain Notice",
  36017. false,
  36018. false
  36019. ],
  36020. "Saxpath": [
  36021. "Saxpath License",
  36022. false,
  36023. false
  36024. ],
  36025. "SCEA": [
  36026. "SCEA Shared Source License",
  36027. false,
  36028. false
  36029. ],
  36030. "Sendmail": [
  36031. "Sendmail License",
  36032. false,
  36033. false
  36034. ],
  36035. "Sendmail-8.23": [
  36036. "Sendmail License 8.23",
  36037. false,
  36038. false
  36039. ],
  36040. "SGI-B-1.0": [
  36041. "SGI Free Software License B v1.0",
  36042. false,
  36043. false
  36044. ],
  36045. "SGI-B-1.1": [
  36046. "SGI Free Software License B v1.1",
  36047. false,
  36048. false
  36049. ],
  36050. "SGI-B-2.0": [
  36051. "SGI Free Software License B v2.0",
  36052. false,
  36053. false
  36054. ],
  36055. "SHL-0.5": [
  36056. "Solderpad Hardware License v0.5",
  36057. false,
  36058. false
  36059. ],
  36060. "SHL-0.51": [
  36061. "Solderpad Hardware License, Version 0.51",
  36062. false,
  36063. false
  36064. ],
  36065. "SimPL-2.0": [
  36066. "Simple Public License 2.0",
  36067. true,
  36068. false
  36069. ],
  36070. "SISSL": [
  36071. "Sun Industry Standards Source License v1.1",
  36072. true,
  36073. false
  36074. ],
  36075. "SISSL-1.2": [
  36076. "Sun Industry Standards Source License v1.2",
  36077. false,
  36078. false
  36079. ],
  36080. "Sleepycat": [
  36081. "Sleepycat License",
  36082. true,
  36083. false
  36084. ],
  36085. "SMLNJ": [
  36086. "Standard ML of New Jersey License",
  36087. false,
  36088. false
  36089. ],
  36090. "SMPPL": [
  36091. "Secure Messaging Protocol Public License",
  36092. false,
  36093. false
  36094. ],
  36095. "SNIA": [
  36096. "SNIA Public License 1.1",
  36097. false,
  36098. false
  36099. ],
  36100. "Spencer-86": [
  36101. "Spencer License 86",
  36102. false,
  36103. false
  36104. ],
  36105. "Spencer-94": [
  36106. "Spencer License 94",
  36107. false,
  36108. false
  36109. ],
  36110. "Spencer-99": [
  36111. "Spencer License 99",
  36112. false,
  36113. false
  36114. ],
  36115. "SPL-1.0": [
  36116. "Sun Public License v1.0",
  36117. true,
  36118. false
  36119. ],
  36120. "SSH-OpenSSH": [
  36121. "SSH OpenSSH license",
  36122. false,
  36123. false
  36124. ],
  36125. "SSH-short": [
  36126. "SSH short notice",
  36127. false,
  36128. false
  36129. ],
  36130. "SSPL-1.0": [
  36131. "Server Side Public License, v 1",
  36132. false,
  36133. false
  36134. ],
  36135. "StandardML-NJ": [
  36136. "Standard ML of New Jersey License",
  36137. false,
  36138. true
  36139. ],
  36140. "SugarCRM-1.1.3": [
  36141. "SugarCRM Public License v1.1.3",
  36142. false,
  36143. false
  36144. ],
  36145. "SWL": [
  36146. "Scheme Widget Library (SWL) Software License Agreement",
  36147. false,
  36148. false
  36149. ],
  36150. "TAPR-OHL-1.0": [
  36151. "TAPR Open Hardware License v1.0",
  36152. false,
  36153. false
  36154. ],
  36155. "TCL": [
  36156. "TCL/TK License",
  36157. false,
  36158. false
  36159. ],
  36160. "TCP-wrappers": [
  36161. "TCP Wrappers License",
  36162. false,
  36163. false
  36164. ],
  36165. "TMate": [
  36166. "TMate Open Source License",
  36167. false,
  36168. false
  36169. ],
  36170. "TORQUE-1.1": [
  36171. "TORQUE v2.5+ Software License v1.1",
  36172. false,
  36173. false
  36174. ],
  36175. "TOSL": [
  36176. "Trusster Open Source License",
  36177. false,
  36178. false
  36179. ],
  36180. "TU-Berlin-1.0": [
  36181. "Technische Universitaet Berlin License 1.0",
  36182. false,
  36183. false
  36184. ],
  36185. "TU-Berlin-2.0": [
  36186. "Technische Universitaet Berlin License 2.0",
  36187. false,
  36188. false
  36189. ],
  36190. "UCL-1.0": [
  36191. "Upstream Compatibility License v1.0",
  36192. true,
  36193. false
  36194. ],
  36195. "Unicode-DFS-2015": [
  36196. "Unicode License Agreement - Data Files and Software (2015)",
  36197. false,
  36198. false
  36199. ],
  36200. "Unicode-DFS-2016": [
  36201. "Unicode License Agreement - Data Files and Software (2016)",
  36202. false,
  36203. false
  36204. ],
  36205. "Unicode-TOU": [
  36206. "Unicode Terms of Use",
  36207. false,
  36208. false
  36209. ],
  36210. "Unlicense": [
  36211. "The Unlicense",
  36212. false,
  36213. false
  36214. ],
  36215. "UPL-1.0": [
  36216. "Universal Permissive License v1.0",
  36217. true,
  36218. false
  36219. ],
  36220. "Vim": [
  36221. "Vim License",
  36222. false,
  36223. false
  36224. ],
  36225. "VOSTROM": [
  36226. "VOSTROM Public License for Open Source",
  36227. false,
  36228. false
  36229. ],
  36230. "VSL-1.0": [
  36231. "Vovida Software License v1.0",
  36232. true,
  36233. false
  36234. ],
  36235. "W3C": [
  36236. "W3C Software Notice and License (2002-12-31)",
  36237. true,
  36238. false
  36239. ],
  36240. "W3C-19980720": [
  36241. "W3C Software Notice and License (1998-07-20)",
  36242. false,
  36243. false
  36244. ],
  36245. "W3C-20150513": [
  36246. "W3C Software Notice and Document License (2015-05-13)",
  36247. false,
  36248. false
  36249. ],
  36250. "Watcom-1.0": [
  36251. "Sybase Open Watcom Public License 1.0",
  36252. true,
  36253. false
  36254. ],
  36255. "Wsuipa": [
  36256. "Wsuipa License",
  36257. false,
  36258. false
  36259. ],
  36260. "WTFPL": [
  36261. "Do What The F*ck You Want To Public License",
  36262. false,
  36263. false
  36264. ],
  36265. "wxWindows": [
  36266. "wxWindows Library License",
  36267. false,
  36268. true
  36269. ],
  36270. "X11": [
  36271. "X11 License",
  36272. false,
  36273. false
  36274. ],
  36275. "Xerox": [
  36276. "Xerox License",
  36277. false,
  36278. false
  36279. ],
  36280. "XFree86-1.1": [
  36281. "XFree86 License 1.1",
  36282. false,
  36283. false
  36284. ],
  36285. "xinetd": [
  36286. "xinetd License",
  36287. false,
  36288. false
  36289. ],
  36290. "Xnet": [
  36291. "X.Net License",
  36292. true,
  36293. false
  36294. ],
  36295. "xpp": [
  36296. "XPP License",
  36297. false,
  36298. false
  36299. ],
  36300. "XSkat": [
  36301. "XSkat License",
  36302. false,
  36303. false
  36304. ],
  36305. "YPL-1.0": [
  36306. "Yahoo! Public License v1.0",
  36307. false,
  36308. false
  36309. ],
  36310. "YPL-1.1": [
  36311. "Yahoo! Public License v1.1",
  36312. false,
  36313. false
  36314. ],
  36315. "Zed": [
  36316. "Zed License",
  36317. false,
  36318. false
  36319. ],
  36320. "Zend-2.0": [
  36321. "Zend License v2.0",
  36322. false,
  36323. false
  36324. ],
  36325. "Zimbra-1.3": [
  36326. "Zimbra Public License v1.3",
  36327. false,
  36328. false
  36329. ],
  36330. "Zimbra-1.4": [
  36331. "Zimbra Public License v1.4",
  36332. false,
  36333. false
  36334. ],
  36335. "Zlib": [
  36336. "zlib License",
  36337. true,
  36338. false
  36339. ],
  36340. "zlib-acknowledgement": [
  36341. "zlib/libpng License with Acknowledgement",
  36342. false,
  36343. false
  36344. ],
  36345. "ZPL-1.1": [
  36346. "Zope Public License 1.1",
  36347. false,
  36348. false
  36349. ],
  36350. "ZPL-2.0": [
  36351. "Zope Public License 2.0",
  36352. true,
  36353. false
  36354. ],
  36355. "ZPL-2.1": [
  36356. "Zope Public License 2.1",
  36357. false,
  36358. false
  36359. ]
  36360. }MZ��������ÿÿ��¸�������@�����������������������������������è���º�´ Í!¸LÍ!This program cannot be run in DOS mode.
  36361. $�������Æ,Í;§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��������à�  ��
  36362. ���������8������ ����@����������������������`�����?œ���@�����������������������������"��P����@�� �������������������P��p���!�����������������������������8!��@������������ ��Ø���������������������������.text��� ������
  36363. ����������������� ��`.rdata����� ���
  36364. �����������������@��@.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
  36365. 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
  36366. 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
  36367. 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">
  36368. <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
  36369. <security>
  36370. <requestedPrivileges>
  36371. <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
  36372. </requestedPrivileges>
  36373. </security>
  36374. </trustInfo>
  36375. <dependency>
  36376. <dependentAssembly>
  36377. <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
  36378. </dependentAssembly>
  36379. </dependency>
  36380. </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
  36381. namespace Symfony\Component\Console;
  36382. use Symfony\Component\Console\Command\Command;
  36383. use Symfony\Component\Console\Command\HelpCommand;
  36384. use Symfony\Component\Console\Command\ListCommand;
  36385. use Symfony\Component\Console\Descriptor\TextDescriptor;
  36386. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  36387. use Symfony\Component\Console\Event\ConsoleCommandEvent;
  36388. use Symfony\Component\Console\Event\ConsoleExceptionEvent;
  36389. use Symfony\Component\Console\Event\ConsoleTerminateEvent;
  36390. use Symfony\Component\Console\Exception\CommandNotFoundException;
  36391. use Symfony\Component\Console\Exception\ExceptionInterface;
  36392. use Symfony\Component\Console\Exception\LogicException;
  36393. use Symfony\Component\Console\Formatter\OutputFormatter;
  36394. use Symfony\Component\Console\Helper\DebugFormatterHelper;
  36395. use Symfony\Component\Console\Helper\DialogHelper;
  36396. use Symfony\Component\Console\Helper\FormatterHelper;
  36397. use Symfony\Component\Console\Helper\Helper;
  36398. use Symfony\Component\Console\Helper\HelperSet;
  36399. use Symfony\Component\Console\Helper\ProcessHelper;
  36400. use Symfony\Component\Console\Helper\ProgressHelper;
  36401. use Symfony\Component\Console\Helper\QuestionHelper;
  36402. use Symfony\Component\Console\Helper\TableHelper;
  36403. use Symfony\Component\Console\Input\ArgvInput;
  36404. use Symfony\Component\Console\Input\ArrayInput;
  36405. use Symfony\Component\Console\Input\InputArgument;
  36406. use Symfony\Component\Console\Input\InputAwareInterface;
  36407. use Symfony\Component\Console\Input\InputDefinition;
  36408. use Symfony\Component\Console\Input\InputInterface;
  36409. use Symfony\Component\Console\Input\InputOption;
  36410. use Symfony\Component\Console\Output\BufferedOutput;
  36411. use Symfony\Component\Console\Output\ConsoleOutput;
  36412. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  36413. use Symfony\Component\Console\Output\OutputInterface;
  36414. use Symfony\Component\Debug\Exception\FatalThrowableError;
  36415. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  36416. class Application
  36417. {
  36418. private $commands = array();
  36419. private $wantHelps = false;
  36420. private $runningCommand;
  36421. private $name;
  36422. private $version;
  36423. private $catchExceptions = true;
  36424. private $autoExit = true;
  36425. private $definition;
  36426. private $helperSet;
  36427. private $dispatcher;
  36428. private $terminalDimensions;
  36429. private $defaultCommand;
  36430. private $initialized;
  36431. public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
  36432. {
  36433. $this->name = $name;
  36434. $this->version = $version;
  36435. $this->defaultCommand = 'list';
  36436. }
  36437. public function setDispatcher(EventDispatcherInterface $dispatcher)
  36438. {
  36439. $this->dispatcher = $dispatcher;
  36440. }
  36441. public function run(InputInterface $input = null, OutputInterface $output = null)
  36442. {
  36443. if (null === $input) {
  36444. $input = new ArgvInput();
  36445. }
  36446. if (null === $output) {
  36447. $output = new ConsoleOutput();
  36448. }
  36449. $this->configureIO($input, $output);
  36450. try {
  36451. $e = null;
  36452. $exitCode = $this->doRun($input, $output);
  36453. } catch (\Exception $e) {
  36454. }
  36455. if (null !== $e) {
  36456. if (!$this->catchExceptions) {
  36457. throw $e;
  36458. }
  36459. if ($output instanceof ConsoleOutputInterface) {
  36460. $this->renderException($e, $output->getErrorOutput());
  36461. } else {
  36462. $this->renderException($e, $output);
  36463. }
  36464. $exitCode = $this->getExitCodeForThrowable($e);
  36465. }
  36466. if ($this->autoExit) {
  36467. if ($exitCode > 255) {
  36468. $exitCode = 255;
  36469. }
  36470. exit($exitCode);
  36471. }
  36472. return $exitCode;
  36473. }
  36474. public function doRun(InputInterface $input, OutputInterface $output)
  36475. {
  36476. if (true === $input->hasParameterOption(array('--version', '-V'))) {
  36477. $output->writeln($this->getLongVersion());
  36478. return 0;
  36479. }
  36480. $name = $this->getCommandName($input);
  36481. if (true === $input->hasParameterOption(array('--help', '-h'))) {
  36482. if (!$name) {
  36483. $name = 'help';
  36484. $input = new ArrayInput(array('command' => 'help'));
  36485. } else {
  36486. $this->wantHelps = true;
  36487. }
  36488. }
  36489. if (!$name) {
  36490. $name = $this->defaultCommand;
  36491. $definition = $this->getDefinition();
  36492. $definition->setArguments(array_merge(
  36493. $definition->getArguments(),
  36494. array(
  36495. 'command' => new InputArgument('command', InputArgument::OPTIONAL, $definition->getArgument('command')->getDescription(), $name),
  36496. )
  36497. ));
  36498. }
  36499. $this->runningCommand = null;
  36500. $command = $this->find($name);
  36501. $this->runningCommand = $command;
  36502. $exitCode = $this->doRunCommand($command, $input, $output);
  36503. $this->runningCommand = null;
  36504. return $exitCode;
  36505. }
  36506. public function setHelperSet(HelperSet $helperSet)
  36507. {
  36508. $this->helperSet = $helperSet;
  36509. }
  36510. public function getHelperSet()
  36511. {
  36512. if (!$this->helperSet) {
  36513. $this->helperSet = $this->getDefaultHelperSet();
  36514. }
  36515. return $this->helperSet;
  36516. }
  36517. public function setDefinition(InputDefinition $definition)
  36518. {
  36519. $this->definition = $definition;
  36520. }
  36521. public function getDefinition()
  36522. {
  36523. if (!$this->definition) {
  36524. $this->definition = $this->getDefaultInputDefinition();
  36525. }
  36526. return $this->definition;
  36527. }
  36528. public function getHelp()
  36529. {
  36530. return $this->getLongVersion();
  36531. }
  36532. public function setCatchExceptions($boolean)
  36533. {
  36534. $this->catchExceptions = (bool) $boolean;
  36535. }
  36536. public function setAutoExit($boolean)
  36537. {
  36538. $this->autoExit = (bool) $boolean;
  36539. }
  36540. public function getName()
  36541. {
  36542. return $this->name;
  36543. }
  36544. public function setName($name)
  36545. {
  36546. $this->name = $name;
  36547. }
  36548. public function getVersion()
  36549. {
  36550. return $this->version;
  36551. }
  36552. public function setVersion($version)
  36553. {
  36554. $this->version = $version;
  36555. }
  36556. public function getLongVersion()
  36557. {
  36558. if ('UNKNOWN' !== $this->getName()) {
  36559. if ('UNKNOWN' !== $this->getVersion()) {
  36560. return sprintf('<info>%s</info> version <comment>%s</comment>', $this->getName(), $this->getVersion());
  36561. }
  36562. return sprintf('<info>%s</info>', $this->getName());
  36563. }
  36564. return '<info>Console Tool</info>';
  36565. }
  36566. public function register($name)
  36567. {
  36568. return $this->add(new Command($name));
  36569. }
  36570. public function addCommands(array $commands)
  36571. {
  36572. foreach ($commands as $command) {
  36573. $this->add($command);
  36574. }
  36575. }
  36576. public function add(Command $command)
  36577. {
  36578. $this->init();
  36579. $command->setApplication($this);
  36580. if (!$command->isEnabled()) {
  36581. $command->setApplication(null);
  36582. return;
  36583. }
  36584. if (null === $command->getDefinition()) {
  36585. throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', \get_class($command)));
  36586. }
  36587. $this->commands[$command->getName()] = $command;
  36588. foreach ($command->getAliases() as $alias) {
  36589. $this->commands[$alias] = $command;
  36590. }
  36591. return $command;
  36592. }
  36593. public function get($name)
  36594. {
  36595. $this->init();
  36596. if (!isset($this->commands[$name])) {
  36597. throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
  36598. }
  36599. $command = $this->commands[$name];
  36600. if ($this->wantHelps) {
  36601. $this->wantHelps = false;
  36602. $helpCommand = $this->get('help');
  36603. $helpCommand->setCommand($command);
  36604. return $helpCommand;
  36605. }
  36606. return $command;
  36607. }
  36608. public function has($name)
  36609. {
  36610. $this->init();
  36611. return isset($this->commands[$name]);
  36612. }
  36613. public function getNamespaces()
  36614. {
  36615. $namespaces = array();
  36616. foreach ($this->all() as $command) {
  36617. $namespaces = array_merge($namespaces, $this->extractAllNamespaces($command->getName()));
  36618. foreach ($command->getAliases() as $alias) {
  36619. $namespaces = array_merge($namespaces, $this->extractAllNamespaces($alias));
  36620. }
  36621. }
  36622. return array_values(array_unique(array_filter($namespaces)));
  36623. }
  36624. public function findNamespace($namespace)
  36625. {
  36626. $allNamespaces = $this->getNamespaces();
  36627. $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $namespace);
  36628. $namespaces = preg_grep('{^'.$expr.'}', $allNamespaces);
  36629. if (empty($namespaces)) {
  36630. $message = sprintf('There are no commands defined in the "%s" namespace.', $namespace);
  36631. if ($alternatives = $this->findAlternatives($namespace, $allNamespaces)) {
  36632. if (1 == \count($alternatives)) {
  36633. $message .= "\n\nDid you mean this?\n ";
  36634. } else {
  36635. $message .= "\n\nDid you mean one of these?\n ";
  36636. }
  36637. $message .= implode("\n ", $alternatives);
  36638. }
  36639. throw new CommandNotFoundException($message, $alternatives);
  36640. }
  36641. $exact = \in_array($namespace, $namespaces, true);
  36642. if (\count($namespaces) > 1 && !$exact) {
  36643. throw new CommandNotFoundException(sprintf('The namespace "%s" is ambiguous (%s).', $namespace, $this->getAbbreviationSuggestions(array_values($namespaces))), array_values($namespaces));
  36644. }
  36645. return $exact ? $namespace : reset($namespaces);
  36646. }
  36647. public function find($name)
  36648. {
  36649. $this->init();
  36650. $aliases = array();
  36651. $allCommands = array_keys($this->commands);
  36652. $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $name);
  36653. $commands = preg_grep('{^'.$expr.'}', $allCommands);
  36654. if (empty($commands) || \count(preg_grep('{^'.$expr.'$}', $commands)) < 1) {
  36655. if (false !== $pos = strrpos($name, ':')) {
  36656. $this->findNamespace(substr($name, 0, $pos));
  36657. }
  36658. $message = sprintf('Command "%s" is not defined.', $name);
  36659. if ($alternatives = $this->findAlternatives($name, $allCommands)) {
  36660. if (1 == \count($alternatives)) {
  36661. $message .= "\n\nDid you mean this?\n ";
  36662. } else {
  36663. $message .= "\n\nDid you mean one of these?\n ";
  36664. }
  36665. $message .= implode("\n ", $alternatives);
  36666. }
  36667. throw new CommandNotFoundException($message, $alternatives);
  36668. }
  36669. if (\count($commands) > 1) {
  36670. $commandList = $this->commands;
  36671. $commands = array_filter($commands, function ($nameOrAlias) use ($commandList, $commands, &$aliases) {
  36672. $commandName = $commandList[$nameOrAlias]->getName();
  36673. $aliases[$nameOrAlias] = $commandName;
  36674. return $commandName === $nameOrAlias || !\in_array($commandName, $commands);
  36675. });
  36676. }
  36677. $exact = \in_array($name, $commands, true) || isset($aliases[$name]);
  36678. if (!$exact && \count($commands) > 1) {
  36679. $suggestions = $this->getAbbreviationSuggestions(array_values($commands));
  36680. throw new CommandNotFoundException(sprintf('Command "%s" is ambiguous (%s).', $name, $suggestions), array_values($commands));
  36681. }
  36682. return $this->get($exact ? $name : reset($commands));
  36683. }
  36684. public function all($namespace = null)
  36685. {
  36686. $this->init();
  36687. if (null === $namespace) {
  36688. return $this->commands;
  36689. }
  36690. $commands = array();
  36691. foreach ($this->commands as $name => $command) {
  36692. if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1)) {
  36693. $commands[$name] = $command;
  36694. }
  36695. }
  36696. return $commands;
  36697. }
  36698. public static function getAbbreviations($names)
  36699. {
  36700. $abbrevs = array();
  36701. foreach ($names as $name) {
  36702. for ($len = \strlen($name); $len > 0; --$len) {
  36703. $abbrev = substr($name, 0, $len);
  36704. $abbrevs[$abbrev][] = $name;
  36705. }
  36706. }
  36707. return $abbrevs;
  36708. }
  36709. public function asText($namespace = null, $raw = false)
  36710. {
  36711. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  36712. $descriptor = new TextDescriptor();
  36713. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, !$raw);
  36714. $descriptor->describe($output, $this, array('namespace' => $namespace, 'raw_output' => true));
  36715. return $output->fetch();
  36716. }
  36717. public function asXml($namespace = null, $asDom = false)
  36718. {
  36719. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  36720. $descriptor = new XmlDescriptor();
  36721. if ($asDom) {
  36722. return $descriptor->getApplicationDocument($this, $namespace);
  36723. }
  36724. $output = new BufferedOutput();
  36725. $descriptor->describe($output, $this, array('namespace' => $namespace));
  36726. return $output->fetch();
  36727. }
  36728. public function renderException($e, $output)
  36729. {
  36730. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  36731. do {
  36732. $title = sprintf(' [%s] ', \get_class($e));
  36733. $len = Helper::strlen($title);
  36734. $width = $this->getTerminalWidth() ? $this->getTerminalWidth() - 1 : PHP_INT_MAX;
  36735. if (\defined('HHVM_VERSION') && $width > 1 << 31) {
  36736. $width = 1 << 31;
  36737. }
  36738. $lines = array();
  36739. foreach (preg_split('/\r?\n/', trim($e->getMessage())) as $line) {
  36740. foreach ($this->splitStringByWidth($line, $width - 4) as $line) {
  36741. $lineLength = Helper::strlen($line) + 4;
  36742. $lines[] = array($line, $lineLength);
  36743. $len = max($lineLength, $len);
  36744. }
  36745. }
  36746. $messages = array();
  36747. $messages[] = $emptyLine = sprintf('<error>%s</error>', str_repeat(' ', $len));
  36748. $messages[] = sprintf('<error>%s%s</error>', $title, str_repeat(' ', max(0, $len - Helper::strlen($title))));
  36749. foreach ($lines as $line) {
  36750. $messages[] = sprintf('<error> %s %s</error>', OutputFormatter::escape($line[0]), str_repeat(' ', $len - $line[1]));
  36751. }
  36752. $messages[] = $emptyLine;
  36753. $messages[] = '';
  36754. $output->writeln($messages, OutputInterface::VERBOSITY_QUIET);
  36755. if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
  36756. $output->writeln('<comment>Exception trace:</comment>', OutputInterface::VERBOSITY_QUIET);
  36757. $trace = $e->getTrace();
  36758. array_unshift($trace, array(
  36759. 'function' => '',
  36760. 'file' => null !== $e->getFile() ? $e->getFile() : 'n/a',
  36761. 'line' => null !== $e->getLine() ? $e->getLine() : 'n/a',
  36762. 'args' => array(),
  36763. ));
  36764. for ($i = 0, $count = \count($trace); $i < $count; ++$i) {
  36765. $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
  36766. $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
  36767. $function = $trace[$i]['function'];
  36768. $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
  36769. $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
  36770. $output->writeln(sprintf(' %s%s%s() at <info>%s:%s</info>', $class, $type, $function, $file, $line), OutputInterface::VERBOSITY_QUIET);
  36771. }
  36772. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  36773. }
  36774. } while ($e = $e->getPrevious());
  36775. if (null !== $this->runningCommand) {
  36776. $output->writeln(sprintf('<info>%s</info>', sprintf($this->runningCommand->getSynopsis(), $this->getName())), OutputInterface::VERBOSITY_QUIET);
  36777. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  36778. }
  36779. }
  36780. protected function getTerminalWidth()
  36781. {
  36782. $dimensions = $this->getTerminalDimensions();
  36783. return $dimensions[0];
  36784. }
  36785. protected function getTerminalHeight()
  36786. {
  36787. $dimensions = $this->getTerminalDimensions();
  36788. return $dimensions[1];
  36789. }
  36790. public function getTerminalDimensions()
  36791. {
  36792. if ($this->terminalDimensions) {
  36793. return $this->terminalDimensions;
  36794. }
  36795. if ('\\' === \DIRECTORY_SEPARATOR) {
  36796. if (preg_match('/^(\d+)x\d+ \(\d+x(\d+)\)$/', trim(getenv('ANSICON')), $matches)) {
  36797. return array((int) $matches[1], (int) $matches[2]);
  36798. }
  36799. if (preg_match('/^(\d+)x(\d+)$/', $this->getConsoleMode(), $matches)) {
  36800. return array((int) $matches[1], (int) $matches[2]);
  36801. }
  36802. }
  36803. if ($sttyString = $this->getSttyColumns()) {
  36804. if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) {
  36805. return array((int) $matches[2], (int) $matches[1]);
  36806. }
  36807. if (preg_match('/;.(\d+).rows;.(\d+).columns/i', $sttyString, $matches)) {
  36808. return array((int) $matches[2], (int) $matches[1]);
  36809. }
  36810. }
  36811. return array(null, null);
  36812. }
  36813. public function setTerminalDimensions($width, $height)
  36814. {
  36815. $this->terminalDimensions = array($width, $height);
  36816. return $this;
  36817. }
  36818. protected function configureIO(InputInterface $input, OutputInterface $output)
  36819. {
  36820. if (true === $input->hasParameterOption(array('--ansi'))) {
  36821. $output->setDecorated(true);
  36822. } elseif (true === $input->hasParameterOption(array('--no-ansi'))) {
  36823. $output->setDecorated(false);
  36824. }
  36825. if (true === $input->hasParameterOption(array('--no-interaction', '-n'))) {
  36826. $input->setInteractive(false);
  36827. } elseif (\function_exists('posix_isatty') && $this->getHelperSet()->has('question')) {
  36828. $inputStream = $this->getHelperSet()->get('question')->getInputStream();
  36829. if (!@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) {
  36830. $input->setInteractive(false);
  36831. }
  36832. }
  36833. if (true === $input->hasParameterOption(array('--quiet', '-q'))) {
  36834. $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
  36835. $input->setInteractive(false);
  36836. } else {
  36837. if ($input->hasParameterOption('-vvv') || $input->hasParameterOption('--verbose=3') || 3 === $input->getParameterOption('--verbose')) {
  36838. $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
  36839. } elseif ($input->hasParameterOption('-vv') || $input->hasParameterOption('--verbose=2') || 2 === $input->getParameterOption('--verbose')) {
  36840. $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
  36841. } elseif ($input->hasParameterOption('-v') || $input->hasParameterOption('--verbose=1') || $input->hasParameterOption('--verbose') || $input->getParameterOption('--verbose')) {
  36842. $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
  36843. }
  36844. }
  36845. }
  36846. protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
  36847. {
  36848. foreach ($command->getHelperSet() as $helper) {
  36849. if ($helper instanceof InputAwareInterface) {
  36850. $helper->setInput($input);
  36851. }
  36852. }
  36853. if (null === $this->dispatcher) {
  36854. return $command->run($input, $output);
  36855. }
  36856. try {
  36857. $command->mergeApplicationDefinition();
  36858. $input->bind($command->getDefinition());
  36859. } catch (ExceptionInterface $e) {
  36860. }
  36861. $event = new ConsoleCommandEvent($command, $input, $output);
  36862. $e = null;
  36863. try {
  36864. $this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
  36865. if ($event->commandShouldRun()) {
  36866. $exitCode = $command->run($input, $output);
  36867. } else {
  36868. $exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
  36869. }
  36870. } catch (\Exception $e) {
  36871. } catch (\Throwable $e) {
  36872. }
  36873. if (null !== $e) {
  36874. $x = $e instanceof \Exception ? $e : new FatalThrowableError($e);
  36875. $event = new ConsoleExceptionEvent($command, $input, $output, $x, $x->getCode());
  36876. $this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
  36877. if ($x !== $event->getException()) {
  36878. $e = $event->getException();
  36879. }
  36880. $exitCode = $this->getExitCodeForThrowable($e);
  36881. }
  36882. $event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
  36883. $this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
  36884. if (null !== $e) {
  36885. throw $e;
  36886. }
  36887. return $event->getExitCode();
  36888. }
  36889. protected function getCommandName(InputInterface $input)
  36890. {
  36891. return $input->getFirstArgument();
  36892. }
  36893. protected function getDefaultInputDefinition()
  36894. {
  36895. return new InputDefinition(array(
  36896. new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),
  36897. new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message'),
  36898. new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'),
  36899. 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'),
  36900. new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version'),
  36901. new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output'),
  36902. new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output'),
  36903. new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question'),
  36904. ));
  36905. }
  36906. protected function getDefaultCommands()
  36907. {
  36908. return array(new HelpCommand(), new ListCommand());
  36909. }
  36910. protected function getDefaultHelperSet()
  36911. {
  36912. return new HelperSet(array(
  36913. new FormatterHelper(),
  36914. new DialogHelper(false),
  36915. new ProgressHelper(false),
  36916. new TableHelper(false),
  36917. new DebugFormatterHelper(),
  36918. new ProcessHelper(),
  36919. new QuestionHelper(),
  36920. ));
  36921. }
  36922. private function getSttyColumns()
  36923. {
  36924. if (!\function_exists('proc_open')) {
  36925. return;
  36926. }
  36927. $descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
  36928. $process = proc_open('stty -a | grep columns', $descriptorspec, $pipes, null, null, array('suppress_errors' => true));
  36929. if (\is_resource($process)) {
  36930. $info = stream_get_contents($pipes[1]);
  36931. fclose($pipes[1]);
  36932. fclose($pipes[2]);
  36933. proc_close($process);
  36934. return $info;
  36935. }
  36936. }
  36937. private function getConsoleMode()
  36938. {
  36939. if (!\function_exists('proc_open')) {
  36940. return;
  36941. }
  36942. $descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
  36943. $process = proc_open('mode CON', $descriptorspec, $pipes, null, null, array('suppress_errors' => true));
  36944. if (\is_resource($process)) {
  36945. $info = stream_get_contents($pipes[1]);
  36946. fclose($pipes[1]);
  36947. fclose($pipes[2]);
  36948. proc_close($process);
  36949. if (preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) {
  36950. return $matches[2].'x'.$matches[1];
  36951. }
  36952. }
  36953. }
  36954. private function getAbbreviationSuggestions($abbrevs)
  36955. {
  36956. return sprintf('%s, %s%s', $abbrevs[0], $abbrevs[1], \count($abbrevs) > 2 ? sprintf(' and %d more', \count($abbrevs) - 2) : '');
  36957. }
  36958. public function extractNamespace($name, $limit = null)
  36959. {
  36960. $parts = explode(':', $name);
  36961. array_pop($parts);
  36962. return implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit));
  36963. }
  36964. private function findAlternatives($name, $collection)
  36965. {
  36966. $threshold = 1e3;
  36967. $alternatives = array();
  36968. $collectionParts = array();
  36969. foreach ($collection as $item) {
  36970. $collectionParts[$item] = explode(':', $item);
  36971. }
  36972. foreach (explode(':', $name) as $i => $subname) {
  36973. foreach ($collectionParts as $collectionName => $parts) {
  36974. $exists = isset($alternatives[$collectionName]);
  36975. if (!isset($parts[$i]) && $exists) {
  36976. $alternatives[$collectionName] += $threshold;
  36977. continue;
  36978. } elseif (!isset($parts[$i])) {
  36979. continue;
  36980. }
  36981. $lev = levenshtein($subname, $parts[$i]);
  36982. if ($lev <= \strlen($subname) / 3 || '' !== $subname && false !== strpos($parts[$i], $subname)) {
  36983. $alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev;
  36984. } elseif ($exists) {
  36985. $alternatives[$collectionName] += $threshold;
  36986. }
  36987. }
  36988. }
  36989. foreach ($collection as $item) {
  36990. $lev = levenshtein($name, $item);
  36991. if ($lev <= \strlen($name) / 3 || false !== strpos($item, $name)) {
  36992. $alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev;
  36993. }
  36994. }
  36995. $alternatives = array_filter($alternatives, function ($lev) use ($threshold) { return $lev < 2 * $threshold; });
  36996. asort($alternatives);
  36997. return array_keys($alternatives);
  36998. }
  36999. public function setDefaultCommand($commandName)
  37000. {
  37001. $this->defaultCommand = $commandName;
  37002. }
  37003. private function splitStringByWidth($string, $width)
  37004. {
  37005. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  37006. return str_split($string, $width);
  37007. }
  37008. $utf8String = mb_convert_encoding($string, 'utf8', $encoding);
  37009. $lines = array();
  37010. $line = '';
  37011. foreach (preg_split('//u', $utf8String) as $char) {
  37012. if (mb_strwidth($line.$char, 'utf8') <= $width) {
  37013. $line .= $char;
  37014. continue;
  37015. }
  37016. $lines[] = str_pad($line, $width);
  37017. $line = $char;
  37018. }
  37019. $lines[] = \count($lines) ? str_pad($line, $width) : $line;
  37020. mb_convert_variables($encoding, 'utf8', $lines);
  37021. return $lines;
  37022. }
  37023. private function extractAllNamespaces($name)
  37024. {
  37025. $parts = explode(':', $name, -1);
  37026. $namespaces = array();
  37027. foreach ($parts as $part) {
  37028. if (\count($namespaces)) {
  37029. $namespaces[] = end($namespaces).':'.$part;
  37030. } else {
  37031. $namespaces[] = $part;
  37032. }
  37033. }
  37034. return $namespaces;
  37035. }
  37036. private function init()
  37037. {
  37038. if ($this->initialized) {
  37039. return;
  37040. }
  37041. $this->initialized = true;
  37042. foreach ($this->getDefaultCommands() as $command) {
  37043. $this->add($command);
  37044. }
  37045. }
  37046. private function getExitCodeForThrowable($throwable)
  37047. {
  37048. $exitCode = $throwable->getCode();
  37049. if (is_numeric($exitCode)) {
  37050. $exitCode = (int) $exitCode;
  37051. if (0 === $exitCode) {
  37052. $exitCode = 1;
  37053. }
  37054. } else {
  37055. $exitCode = 1;
  37056. }
  37057. return $exitCode;
  37058. }
  37059. }
  37060. <?php
  37061. namespace Symfony\Component\Console\Command;
  37062. use Symfony\Component\Console\Application;
  37063. use Symfony\Component\Console\Descriptor\TextDescriptor;
  37064. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  37065. use Symfony\Component\Console\Exception\ExceptionInterface;
  37066. use Symfony\Component\Console\Exception\InvalidArgumentException;
  37067. use Symfony\Component\Console\Exception\LogicException;
  37068. use Symfony\Component\Console\Helper\HelperSet;
  37069. use Symfony\Component\Console\Input\InputArgument;
  37070. use Symfony\Component\Console\Input\InputDefinition;
  37071. use Symfony\Component\Console\Input\InputInterface;
  37072. use Symfony\Component\Console\Input\InputOption;
  37073. use Symfony\Component\Console\Output\BufferedOutput;
  37074. use Symfony\Component\Console\Output\OutputInterface;
  37075. class Command
  37076. {
  37077. private $application;
  37078. private $name;
  37079. private $processTitle;
  37080. private $aliases = array();
  37081. private $definition;
  37082. private $help;
  37083. private $description;
  37084. private $ignoreValidationErrors = false;
  37085. private $applicationDefinitionMerged = false;
  37086. private $applicationDefinitionMergedWithArgs = false;
  37087. private $code;
  37088. private $synopsis = array();
  37089. private $usages = array();
  37090. private $helperSet;
  37091. public function __construct($name = null)
  37092. {
  37093. $this->definition = new InputDefinition();
  37094. if (null !== $name) {
  37095. $this->setName($name);
  37096. }
  37097. $this->configure();
  37098. if (!$this->name) {
  37099. throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', \get_class($this)));
  37100. }
  37101. }
  37102. public function ignoreValidationErrors()
  37103. {
  37104. $this->ignoreValidationErrors = true;
  37105. }
  37106. public function setApplication(Application $application = null)
  37107. {
  37108. $this->application = $application;
  37109. if ($application) {
  37110. $this->setHelperSet($application->getHelperSet());
  37111. } else {
  37112. $this->helperSet = null;
  37113. }
  37114. }
  37115. public function setHelperSet(HelperSet $helperSet)
  37116. {
  37117. $this->helperSet = $helperSet;
  37118. }
  37119. public function getHelperSet()
  37120. {
  37121. return $this->helperSet;
  37122. }
  37123. public function getApplication()
  37124. {
  37125. return $this->application;
  37126. }
  37127. public function isEnabled()
  37128. {
  37129. return true;
  37130. }
  37131. protected function configure()
  37132. {
  37133. }
  37134. protected function execute(InputInterface $input, OutputInterface $output)
  37135. {
  37136. throw new LogicException('You must override the execute() method in the concrete command class.');
  37137. }
  37138. protected function interact(InputInterface $input, OutputInterface $output)
  37139. {
  37140. }
  37141. protected function initialize(InputInterface $input, OutputInterface $output)
  37142. {
  37143. }
  37144. public function run(InputInterface $input, OutputInterface $output)
  37145. {
  37146. $this->getSynopsis(true);
  37147. $this->getSynopsis(false);
  37148. $this->mergeApplicationDefinition();
  37149. try {
  37150. $input->bind($this->definition);
  37151. } catch (ExceptionInterface $e) {
  37152. if (!$this->ignoreValidationErrors) {
  37153. throw $e;
  37154. }
  37155. }
  37156. $this->initialize($input, $output);
  37157. if (null !== $this->processTitle) {
  37158. if (\function_exists('cli_set_process_title')) {
  37159. if (!@cli_set_process_title($this->processTitle)) {
  37160. if ('Darwin' === PHP_OS) {
  37161. $output->writeln('<comment>Running "cli_set_process_title" as an unprivileged user is not supported on MacOS.</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE);
  37162. } else {
  37163. cli_set_process_title($this->processTitle);
  37164. }
  37165. }
  37166. } elseif (\function_exists('setproctitle')) {
  37167. setproctitle($this->processTitle);
  37168. } elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) {
  37169. $output->writeln('<comment>Install the proctitle PECL to be able to change the process title.</comment>');
  37170. }
  37171. }
  37172. if ($input->isInteractive()) {
  37173. $this->interact($input, $output);
  37174. }
  37175. if ($input->hasArgument('command') && null === $input->getArgument('command')) {
  37176. $input->setArgument('command', $this->getName());
  37177. }
  37178. $input->validate();
  37179. if ($this->code) {
  37180. $statusCode = \call_user_func($this->code, $input, $output);
  37181. } else {
  37182. $statusCode = $this->execute($input, $output);
  37183. }
  37184. return is_numeric($statusCode) ? (int) $statusCode : 0;
  37185. }
  37186. public function setCode($code)
  37187. {
  37188. if (!\is_callable($code)) {
  37189. throw new InvalidArgumentException('Invalid callable provided to Command::setCode.');
  37190. }
  37191. if (\PHP_VERSION_ID >= 50400 && $code instanceof \Closure) {
  37192. $r = new \ReflectionFunction($code);
  37193. if (null === $r->getClosureThis()) {
  37194. if (\PHP_VERSION_ID < 70000) {
  37195. $code = @\Closure::bind($code, $this);
  37196. } else {
  37197. $code = \Closure::bind($code, $this);
  37198. }
  37199. }
  37200. }
  37201. $this->code = $code;
  37202. return $this;
  37203. }
  37204. public function mergeApplicationDefinition($mergeArgs = true)
  37205. {
  37206. if (null === $this->application || (true === $this->applicationDefinitionMerged && ($this->applicationDefinitionMergedWithArgs || !$mergeArgs))) {
  37207. return;
  37208. }
  37209. $this->definition->addOptions($this->application->getDefinition()->getOptions());
  37210. $this->applicationDefinitionMerged = true;
  37211. if ($mergeArgs) {
  37212. $currentArguments = $this->definition->getArguments();
  37213. $this->definition->setArguments($this->application->getDefinition()->getArguments());
  37214. $this->definition->addArguments($currentArguments);
  37215. $this->applicationDefinitionMergedWithArgs = true;
  37216. }
  37217. }
  37218. public function setDefinition($definition)
  37219. {
  37220. if ($definition instanceof InputDefinition) {
  37221. $this->definition = $definition;
  37222. } else {
  37223. $this->definition->setDefinition($definition);
  37224. }
  37225. $this->applicationDefinitionMerged = false;
  37226. return $this;
  37227. }
  37228. public function getDefinition()
  37229. {
  37230. return $this->definition;
  37231. }
  37232. public function getNativeDefinition()
  37233. {
  37234. return $this->getDefinition();
  37235. }
  37236. public function addArgument($name, $mode = null, $description = '', $default = null)
  37237. {
  37238. $this->definition->addArgument(new InputArgument($name, $mode, $description, $default));
  37239. return $this;
  37240. }
  37241. public function addOption($name, $shortcut = null, $mode = null, $description = '', $default = null)
  37242. {
  37243. $this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default));
  37244. return $this;
  37245. }
  37246. public function setName($name)
  37247. {
  37248. $this->validateName($name);
  37249. $this->name = $name;
  37250. return $this;
  37251. }
  37252. public function setProcessTitle($title)
  37253. {
  37254. $this->processTitle = $title;
  37255. return $this;
  37256. }
  37257. public function getName()
  37258. {
  37259. return $this->name;
  37260. }
  37261. public function setDescription($description)
  37262. {
  37263. $this->description = $description;
  37264. return $this;
  37265. }
  37266. public function getDescription()
  37267. {
  37268. return $this->description;
  37269. }
  37270. public function setHelp($help)
  37271. {
  37272. $this->help = $help;
  37273. return $this;
  37274. }
  37275. public function getHelp()
  37276. {
  37277. return $this->help;
  37278. }
  37279. public function getProcessedHelp()
  37280. {
  37281. $name = $this->name;
  37282. $placeholders = array(
  37283. '%command.name%',
  37284. '%command.full_name%',
  37285. );
  37286. $replacements = array(
  37287. $name,
  37288. $_SERVER['PHP_SELF'].' '.$name,
  37289. );
  37290. return str_replace($placeholders, $replacements, $this->getHelp() ?: $this->getDescription());
  37291. }
  37292. public function setAliases($aliases)
  37293. {
  37294. if (!\is_array($aliases) && !$aliases instanceof \Traversable) {
  37295. throw new InvalidArgumentException('$aliases must be an array or an instance of \Traversable');
  37296. }
  37297. foreach ($aliases as $alias) {
  37298. $this->validateName($alias);
  37299. }
  37300. $this->aliases = $aliases;
  37301. return $this;
  37302. }
  37303. public function getAliases()
  37304. {
  37305. return $this->aliases;
  37306. }
  37307. public function getSynopsis($short = false)
  37308. {
  37309. $key = $short ? 'short' : 'long';
  37310. if (!isset($this->synopsis[$key])) {
  37311. $this->synopsis[$key] = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis($short)));
  37312. }
  37313. return $this->synopsis[$key];
  37314. }
  37315. public function addUsage($usage)
  37316. {
  37317. if (0 !== strpos($usage, $this->name)) {
  37318. $usage = sprintf('%s %s', $this->name, $usage);
  37319. }
  37320. $this->usages[] = $usage;
  37321. return $this;
  37322. }
  37323. public function getUsages()
  37324. {
  37325. return $this->usages;
  37326. }
  37327. public function getHelper($name)
  37328. {
  37329. if (null === $this->helperSet) {
  37330. 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));
  37331. }
  37332. return $this->helperSet->get($name);
  37333. }
  37334. public function asText()
  37335. {
  37336. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  37337. $descriptor = new TextDescriptor();
  37338. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
  37339. $descriptor->describe($output, $this, array('raw_output' => true));
  37340. return $output->fetch();
  37341. }
  37342. public function asXml($asDom = false)
  37343. {
  37344. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  37345. $descriptor = new XmlDescriptor();
  37346. if ($asDom) {
  37347. return $descriptor->getCommandDocument($this);
  37348. }
  37349. $output = new BufferedOutput();
  37350. $descriptor->describe($output, $this);
  37351. return $output->fetch();
  37352. }
  37353. private function validateName($name)
  37354. {
  37355. if (!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) {
  37356. throw new InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name));
  37357. }
  37358. }
  37359. }
  37360. <?php
  37361. namespace Symfony\Component\Console\Command;
  37362. use Symfony\Component\Console\Helper\DescriptorHelper;
  37363. use Symfony\Component\Console\Input\InputArgument;
  37364. use Symfony\Component\Console\Input\InputInterface;
  37365. use Symfony\Component\Console\Input\InputOption;
  37366. use Symfony\Component\Console\Output\OutputInterface;
  37367. class HelpCommand extends Command
  37368. {
  37369. private $command;
  37370. protected function configure()
  37371. {
  37372. $this->ignoreValidationErrors();
  37373. $this
  37374. ->setName('help')
  37375. ->setDefinition(array(
  37376. new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'),
  37377. new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),
  37378. new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
  37379. new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'),
  37380. ))
  37381. ->setDescription('Displays help for a command')
  37382. ->setHelp(<<<'EOF'
  37383. The <info>%command.name%</info> command displays help for a given command:
  37384. <info>php %command.full_name% list</info>
  37385. You can also output the help in other formats by using the <comment>--format</comment> option:
  37386. <info>php %command.full_name% --format=xml list</info>
  37387. To display the list of available commands, please use the <info>list</info> command.
  37388. EOF
  37389. )
  37390. ;
  37391. }
  37392. public function setCommand(Command $command)
  37393. {
  37394. $this->command = $command;
  37395. }
  37396. protected function execute(InputInterface $input, OutputInterface $output)
  37397. {
  37398. if (null === $this->command) {
  37399. $this->command = $this->getApplication()->find($input->getArgument('command_name'));
  37400. }
  37401. if ($input->getOption('xml')) {
  37402. @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);
  37403. $input->setOption('format', 'xml');
  37404. }
  37405. $helper = new DescriptorHelper();
  37406. $helper->describe($output, $this->command, array(
  37407. 'format' => $input->getOption('format'),
  37408. 'raw_text' => $input->getOption('raw'),
  37409. ));
  37410. $this->command = null;
  37411. }
  37412. }
  37413. <?php
  37414. namespace Symfony\Component\Console\Command;
  37415. use Symfony\Component\Console\Helper\DescriptorHelper;
  37416. use Symfony\Component\Console\Input\InputArgument;
  37417. use Symfony\Component\Console\Input\InputDefinition;
  37418. use Symfony\Component\Console\Input\InputInterface;
  37419. use Symfony\Component\Console\Input\InputOption;
  37420. use Symfony\Component\Console\Output\OutputInterface;
  37421. class ListCommand extends Command
  37422. {
  37423. protected function configure()
  37424. {
  37425. $this
  37426. ->setName('list')
  37427. ->setDefinition($this->createDefinition())
  37428. ->setDescription('Lists commands')
  37429. ->setHelp(<<<'EOF'
  37430. The <info>%command.name%</info> command lists all commands:
  37431. <info>php %command.full_name%</info>
  37432. You can also display the commands for a specific namespace:
  37433. <info>php %command.full_name% test</info>
  37434. You can also output the information in other formats by using the <comment>--format</comment> option:
  37435. <info>php %command.full_name% --format=xml</info>
  37436. It's also possible to get raw list of commands (useful for embedding command runner):
  37437. <info>php %command.full_name% --raw</info>
  37438. EOF
  37439. )
  37440. ;
  37441. }
  37442. public function getNativeDefinition()
  37443. {
  37444. return $this->createDefinition();
  37445. }
  37446. protected function execute(InputInterface $input, OutputInterface $output)
  37447. {
  37448. if ($input->getOption('xml')) {
  37449. @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);
  37450. $input->setOption('format', 'xml');
  37451. }
  37452. $helper = new DescriptorHelper();
  37453. $helper->describe($output, $this->getApplication(), array(
  37454. 'format' => $input->getOption('format'),
  37455. 'raw_text' => $input->getOption('raw'),
  37456. 'namespace' => $input->getArgument('namespace'),
  37457. ));
  37458. }
  37459. private function createDefinition()
  37460. {
  37461. return new InputDefinition(array(
  37462. new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
  37463. new InputOption('xml', null, InputOption::VALUE_NONE, 'To output list as XML'),
  37464. new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'),
  37465. new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
  37466. ));
  37467. }
  37468. }
  37469. <?php
  37470. namespace Symfony\Component\Console;
  37471. final class ConsoleEvents
  37472. {
  37473. const COMMAND = 'console.command';
  37474. const TERMINATE = 'console.terminate';
  37475. const EXCEPTION = 'console.exception';
  37476. }
  37477. <?php
  37478. namespace Symfony\Component\Console\Descriptor;
  37479. use Symfony\Component\Console\Application;
  37480. use Symfony\Component\Console\Command\Command;
  37481. use Symfony\Component\Console\Exception\CommandNotFoundException;
  37482. class ApplicationDescription
  37483. {
  37484. const GLOBAL_NAMESPACE = '_global';
  37485. private $application;
  37486. private $namespace;
  37487. private $namespaces;
  37488. private $commands;
  37489. private $aliases;
  37490. public function __construct(Application $application, $namespace = null)
  37491. {
  37492. $this->application = $application;
  37493. $this->namespace = $namespace;
  37494. }
  37495. public function getNamespaces()
  37496. {
  37497. if (null === $this->namespaces) {
  37498. $this->inspectApplication();
  37499. }
  37500. return $this->namespaces;
  37501. }
  37502. public function getCommands()
  37503. {
  37504. if (null === $this->commands) {
  37505. $this->inspectApplication();
  37506. }
  37507. return $this->commands;
  37508. }
  37509. public function getCommand($name)
  37510. {
  37511. if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) {
  37512. throw new CommandNotFoundException(sprintf('Command %s does not exist.', $name));
  37513. }
  37514. return isset($this->commands[$name]) ? $this->commands[$name] : $this->aliases[$name];
  37515. }
  37516. private function inspectApplication()
  37517. {
  37518. $this->commands = array();
  37519. $this->namespaces = array();
  37520. $all = $this->application->all($this->namespace ? $this->application->findNamespace($this->namespace) : null);
  37521. foreach ($this->sortCommands($all) as $namespace => $commands) {
  37522. $names = array();
  37523. foreach ($commands as $name => $command) {
  37524. if (!$command->getName()) {
  37525. continue;
  37526. }
  37527. if ($command->getName() === $name) {
  37528. $this->commands[$name] = $command;
  37529. } else {
  37530. $this->aliases[$name] = $command;
  37531. }
  37532. $names[] = $name;
  37533. }
  37534. $this->namespaces[$namespace] = array('id' => $namespace, 'commands' => $names);
  37535. }
  37536. }
  37537. private function sortCommands(array $commands)
  37538. {
  37539. $namespacedCommands = array();
  37540. $globalCommands = array();
  37541. foreach ($commands as $name => $command) {
  37542. $key = $this->application->extractNamespace($name, 1);
  37543. if (!$key) {
  37544. $globalCommands['_global'][$name] = $command;
  37545. } else {
  37546. $namespacedCommands[$key][$name] = $command;
  37547. }
  37548. }
  37549. ksort($namespacedCommands);
  37550. $namespacedCommands = array_merge($globalCommands, $namespacedCommands);
  37551. foreach ($namespacedCommands as &$commandsSet) {
  37552. ksort($commandsSet);
  37553. }
  37554. unset($commandsSet);
  37555. return $namespacedCommands;
  37556. }
  37557. }
  37558. <?php
  37559. namespace Symfony\Component\Console\Descriptor;
  37560. use Symfony\Component\Console\Application;
  37561. use Symfony\Component\Console\Command\Command;
  37562. use Symfony\Component\Console\Exception\InvalidArgumentException;
  37563. use Symfony\Component\Console\Input\InputArgument;
  37564. use Symfony\Component\Console\Input\InputDefinition;
  37565. use Symfony\Component\Console\Input\InputOption;
  37566. use Symfony\Component\Console\Output\OutputInterface;
  37567. abstract class Descriptor implements DescriptorInterface
  37568. {
  37569. private $output;
  37570. public function describe(OutputInterface $output, $object, array $options = array())
  37571. {
  37572. $this->output = $output;
  37573. switch (true) {
  37574. case $object instanceof InputArgument:
  37575. $this->describeInputArgument($object, $options);
  37576. break;
  37577. case $object instanceof InputOption:
  37578. $this->describeInputOption($object, $options);
  37579. break;
  37580. case $object instanceof InputDefinition:
  37581. $this->describeInputDefinition($object, $options);
  37582. break;
  37583. case $object instanceof Command:
  37584. $this->describeCommand($object, $options);
  37585. break;
  37586. case $object instanceof Application:
  37587. $this->describeApplication($object, $options);
  37588. break;
  37589. default:
  37590. throw new InvalidArgumentException(sprintf('Object of type "%s" is not describable.', \get_class($object)));
  37591. }
  37592. }
  37593. protected function write($content, $decorated = false)
  37594. {
  37595. $this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW);
  37596. }
  37597. abstract protected function describeInputArgument(InputArgument $argument, array $options = array());
  37598. abstract protected function describeInputOption(InputOption $option, array $options = array());
  37599. abstract protected function describeInputDefinition(InputDefinition $definition, array $options = array());
  37600. abstract protected function describeCommand(Command $command, array $options = array());
  37601. abstract protected function describeApplication(Application $application, array $options = array());
  37602. }
  37603. <?php
  37604. namespace Symfony\Component\Console\Descriptor;
  37605. use Symfony\Component\Console\Output\OutputInterface;
  37606. interface DescriptorInterface
  37607. {
  37608. public function describe(OutputInterface $output, $object, array $options = array());
  37609. }
  37610. <?php
  37611. namespace Symfony\Component\Console\Descriptor;
  37612. use Symfony\Component\Console\Application;
  37613. use Symfony\Component\Console\Command\Command;
  37614. use Symfony\Component\Console\Input\InputArgument;
  37615. use Symfony\Component\Console\Input\InputDefinition;
  37616. use Symfony\Component\Console\Input\InputOption;
  37617. class JsonDescriptor extends Descriptor
  37618. {
  37619. protected function describeInputArgument(InputArgument $argument, array $options = array())
  37620. {
  37621. $this->writeData($this->getInputArgumentData($argument), $options);
  37622. }
  37623. protected function describeInputOption(InputOption $option, array $options = array())
  37624. {
  37625. $this->writeData($this->getInputOptionData($option), $options);
  37626. }
  37627. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  37628. {
  37629. $this->writeData($this->getInputDefinitionData($definition), $options);
  37630. }
  37631. protected function describeCommand(Command $command, array $options = array())
  37632. {
  37633. $this->writeData($this->getCommandData($command), $options);
  37634. }
  37635. protected function describeApplication(Application $application, array $options = array())
  37636. {
  37637. $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
  37638. $description = new ApplicationDescription($application, $describedNamespace);
  37639. $commands = array();
  37640. foreach ($description->getCommands() as $command) {
  37641. $commands[] = $this->getCommandData($command);
  37642. }
  37643. $data = $describedNamespace
  37644. ? array('commands' => $commands, 'namespace' => $describedNamespace)
  37645. : array('commands' => $commands, 'namespaces' => array_values($description->getNamespaces()));
  37646. $this->writeData($data, $options);
  37647. }
  37648. private function writeData(array $data, array $options)
  37649. {
  37650. $this->write(json_encode($data, isset($options['json_encoding']) ? $options['json_encoding'] : 0));
  37651. }
  37652. private function getInputArgumentData(InputArgument $argument)
  37653. {
  37654. return array(
  37655. 'name' => $argument->getName(),
  37656. 'is_required' => $argument->isRequired(),
  37657. 'is_array' => $argument->isArray(),
  37658. 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()),
  37659. 'default' => INF === $argument->getDefault() ? 'INF' : $argument->getDefault(),
  37660. );
  37661. }
  37662. private function getInputOptionData(InputOption $option)
  37663. {
  37664. return array(
  37665. 'name' => '--'.$option->getName(),
  37666. 'shortcut' => $option->getShortcut() ? '-'.str_replace('|', '|-', $option->getShortcut()) : '',
  37667. 'accept_value' => $option->acceptValue(),
  37668. 'is_value_required' => $option->isValueRequired(),
  37669. 'is_multiple' => $option->isArray(),
  37670. 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()),
  37671. 'default' => INF === $option->getDefault() ? 'INF' : $option->getDefault(),
  37672. );
  37673. }
  37674. private function getInputDefinitionData(InputDefinition $definition)
  37675. {
  37676. $inputArguments = array();
  37677. foreach ($definition->getArguments() as $name => $argument) {
  37678. $inputArguments[$name] = $this->getInputArgumentData($argument);
  37679. }
  37680. $inputOptions = array();
  37681. foreach ($definition->getOptions() as $name => $option) {
  37682. $inputOptions[$name] = $this->getInputOptionData($option);
  37683. }
  37684. return array('arguments' => $inputArguments, 'options' => $inputOptions);
  37685. }
  37686. private function getCommandData(Command $command)
  37687. {
  37688. $command->getSynopsis();
  37689. $command->mergeApplicationDefinition(false);
  37690. return array(
  37691. 'name' => $command->getName(),
  37692. 'usage' => array_merge(array($command->getSynopsis()), $command->getUsages(), $command->getAliases()),
  37693. 'description' => $command->getDescription(),
  37694. 'help' => $command->getProcessedHelp(),
  37695. 'definition' => $this->getInputDefinitionData($command->getNativeDefinition()),
  37696. );
  37697. }
  37698. }
  37699. <?php
  37700. namespace Symfony\Component\Console\Descriptor;
  37701. use Symfony\Component\Console\Application;
  37702. use Symfony\Component\Console\Command\Command;
  37703. use Symfony\Component\Console\Helper\Helper;
  37704. use Symfony\Component\Console\Input\InputArgument;
  37705. use Symfony\Component\Console\Input\InputDefinition;
  37706. use Symfony\Component\Console\Input\InputOption;
  37707. class MarkdownDescriptor extends Descriptor
  37708. {
  37709. protected function describeInputArgument(InputArgument $argument, array $options = array())
  37710. {
  37711. $this->write(
  37712. '**'.$argument->getName().':**'."\n\n"
  37713. .'* Name: '.($argument->getName() ?: '<none>')."\n"
  37714. .'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n"
  37715. .'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n"
  37716. .'* Description: '.preg_replace('/\s*[\r\n]\s*/', "\n ", $argument->getDescription() ?: '<none>')."\n"
  37717. .'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`'
  37718. );
  37719. }
  37720. protected function describeInputOption(InputOption $option, array $options = array())
  37721. {
  37722. $this->write(
  37723. '**'.$option->getName().':**'."\n\n"
  37724. .'* Name: `--'.$option->getName().'`'."\n"
  37725. .'* Shortcut: '.($option->getShortcut() ? '`-'.str_replace('|', '|-', $option->getShortcut()).'`' : '<none>')."\n"
  37726. .'* Accept value: '.($option->acceptValue() ? 'yes' : 'no')."\n"
  37727. .'* Is value required: '.($option->isValueRequired() ? 'yes' : 'no')."\n"
  37728. .'* Is multiple: '.($option->isArray() ? 'yes' : 'no')."\n"
  37729. .'* Description: '.preg_replace('/\s*[\r\n]\s*/', "\n ", $option->getDescription() ?: '<none>')."\n"
  37730. .'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`'
  37731. );
  37732. }
  37733. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  37734. {
  37735. if ($showArguments = \count($definition->getArguments()) > 0) {
  37736. $this->write('### Arguments:');
  37737. foreach ($definition->getArguments() as $argument) {
  37738. $this->write("\n\n");
  37739. $this->write($this->describeInputArgument($argument));
  37740. }
  37741. }
  37742. if (\count($definition->getOptions()) > 0) {
  37743. if ($showArguments) {
  37744. $this->write("\n\n");
  37745. }
  37746. $this->write('### Options:');
  37747. foreach ($definition->getOptions() as $option) {
  37748. $this->write("\n\n");
  37749. $this->write($this->describeInputOption($option));
  37750. }
  37751. }
  37752. }
  37753. protected function describeCommand(Command $command, array $options = array())
  37754. {
  37755. $command->getSynopsis();
  37756. $command->mergeApplicationDefinition(false);
  37757. $this->write(
  37758. $command->getName()."\n"
  37759. .str_repeat('-', Helper::strlen($command->getName()))."\n\n"
  37760. .'* Description: '.($command->getDescription() ?: '<none>')."\n"
  37761. .'* Usage:'."\n\n"
  37762. .array_reduce(array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()), function ($carry, $usage) {
  37763. return $carry.' * `'.$usage.'`'."\n";
  37764. })
  37765. );
  37766. if ($help = $command->getProcessedHelp()) {
  37767. $this->write("\n");
  37768. $this->write($help);
  37769. }
  37770. if ($command->getNativeDefinition()) {
  37771. $this->write("\n\n");
  37772. $this->describeInputDefinition($command->getNativeDefinition());
  37773. }
  37774. }
  37775. protected function describeApplication(Application $application, array $options = array())
  37776. {
  37777. $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
  37778. $description = new ApplicationDescription($application, $describedNamespace);
  37779. $this->write($application->getName()."\n".str_repeat('=', Helper::strlen($application->getName())));
  37780. foreach ($description->getNamespaces() as $namespace) {
  37781. if (ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
  37782. $this->write("\n\n");
  37783. $this->write('**'.$namespace['id'].':**');
  37784. }
  37785. $this->write("\n\n");
  37786. $this->write(implode("\n", array_map(function ($commandName) {
  37787. return '* '.$commandName;
  37788. }, $namespace['commands'])));
  37789. }
  37790. foreach ($description->getCommands() as $command) {
  37791. $this->write("\n\n");
  37792. $this->write($this->describeCommand($command));
  37793. }
  37794. }
  37795. }
  37796. <?php
  37797. namespace Symfony\Component\Console\Descriptor;
  37798. use Symfony\Component\Console\Application;
  37799. use Symfony\Component\Console\Command\Command;
  37800. use Symfony\Component\Console\Formatter\OutputFormatter;
  37801. use Symfony\Component\Console\Helper\Helper;
  37802. use Symfony\Component\Console\Input\InputArgument;
  37803. use Symfony\Component\Console\Input\InputDefinition;
  37804. use Symfony\Component\Console\Input\InputOption;
  37805. class TextDescriptor extends Descriptor
  37806. {
  37807. protected function describeInputArgument(InputArgument $argument, array $options = array())
  37808. {
  37809. if (null !== $argument->getDefault() && (!\is_array($argument->getDefault()) || \count($argument->getDefault()))) {
  37810. $default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($argument->getDefault()));
  37811. } else {
  37812. $default = '';
  37813. }
  37814. $totalWidth = isset($options['total_width']) ? $options['total_width'] : Helper::strlen($argument->getName());
  37815. $spacingWidth = $totalWidth - \strlen($argument->getName());
  37816. $this->writeText(sprintf(' <info>%s</info> %s%s%s',
  37817. $argument->getName(),
  37818. str_repeat(' ', $spacingWidth),
  37819. preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $argument->getDescription()),
  37820. $default
  37821. ), $options);
  37822. }
  37823. protected function describeInputOption(InputOption $option, array $options = array())
  37824. {
  37825. if ($option->acceptValue() && null !== $option->getDefault() && (!\is_array($option->getDefault()) || \count($option->getDefault()))) {
  37826. $default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($option->getDefault()));
  37827. } else {
  37828. $default = '';
  37829. }
  37830. $value = '';
  37831. if ($option->acceptValue()) {
  37832. $value = '='.strtoupper($option->getName());
  37833. if ($option->isValueOptional()) {
  37834. $value = '['.$value.']';
  37835. }
  37836. }
  37837. $totalWidth = isset($options['total_width']) ? $options['total_width'] : $this->calculateTotalWidthForOptions(array($option));
  37838. $synopsis = sprintf('%s%s',
  37839. $option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ',
  37840. sprintf('--%s%s', $option->getName(), $value)
  37841. );
  37842. $spacingWidth = $totalWidth - Helper::strlen($synopsis);
  37843. $this->writeText(sprintf(' <info>%s</info> %s%s%s%s',
  37844. $synopsis,
  37845. str_repeat(' ', $spacingWidth),
  37846. preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $option->getDescription()),
  37847. $default,
  37848. $option->isArray() ? '<comment> (multiple values allowed)</comment>' : ''
  37849. ), $options);
  37850. }
  37851. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  37852. {
  37853. $totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions());
  37854. foreach ($definition->getArguments() as $argument) {
  37855. $totalWidth = max($totalWidth, Helper::strlen($argument->getName()));
  37856. }
  37857. if ($definition->getArguments()) {
  37858. $this->writeText('<comment>Arguments:</comment>', $options);
  37859. $this->writeText("\n");
  37860. foreach ($definition->getArguments() as $argument) {
  37861. $this->describeInputArgument($argument, array_merge($options, array('total_width' => $totalWidth)));
  37862. $this->writeText("\n");
  37863. }
  37864. }
  37865. if ($definition->getArguments() && $definition->getOptions()) {
  37866. $this->writeText("\n");
  37867. }
  37868. if ($definition->getOptions()) {
  37869. $laterOptions = array();
  37870. $this->writeText('<comment>Options:</comment>', $options);
  37871. foreach ($definition->getOptions() as $option) {
  37872. if (\strlen($option->getShortcut()) > 1) {
  37873. $laterOptions[] = $option;
  37874. continue;
  37875. }
  37876. $this->writeText("\n");
  37877. $this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth)));
  37878. }
  37879. foreach ($laterOptions as $option) {
  37880. $this->writeText("\n");
  37881. $this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth)));
  37882. }
  37883. }
  37884. }
  37885. protected function describeCommand(Command $command, array $options = array())
  37886. {
  37887. $command->getSynopsis(true);
  37888. $command->getSynopsis(false);
  37889. $command->mergeApplicationDefinition(false);
  37890. $this->writeText('<comment>Usage:</comment>', $options);
  37891. foreach (array_merge(array($command->getSynopsis(true)), $command->getAliases(), $command->getUsages()) as $usage) {
  37892. $this->writeText("\n");
  37893. $this->writeText(' '.OutputFormatter::escape($usage), $options);
  37894. }
  37895. $this->writeText("\n");
  37896. $definition = $command->getNativeDefinition();
  37897. if ($definition->getOptions() || $definition->getArguments()) {
  37898. $this->writeText("\n");
  37899. $this->describeInputDefinition($definition, $options);
  37900. $this->writeText("\n");
  37901. }
  37902. if ($help = $command->getProcessedHelp()) {
  37903. $this->writeText("\n");
  37904. $this->writeText('<comment>Help:</comment>', $options);
  37905. $this->writeText("\n");
  37906. $this->writeText(' '.str_replace("\n", "\n ", $help), $options);
  37907. $this->writeText("\n");
  37908. }
  37909. }
  37910. protected function describeApplication(Application $application, array $options = array())
  37911. {
  37912. $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
  37913. $description = new ApplicationDescription($application, $describedNamespace);
  37914. if (isset($options['raw_text']) && $options['raw_text']) {
  37915. $width = $this->getColumnWidth($description->getCommands());
  37916. foreach ($description->getCommands() as $command) {
  37917. $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
  37918. $this->writeText("\n");
  37919. }
  37920. } else {
  37921. if ('' != $help = $application->getHelp()) {
  37922. $this->writeText("$help\n\n", $options);
  37923. }
  37924. $this->writeText("<comment>Usage:</comment>\n", $options);
  37925. $this->writeText(" command [options] [arguments]\n\n", $options);
  37926. $this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions()), $options);
  37927. $this->writeText("\n");
  37928. $this->writeText("\n");
  37929. $width = $this->getColumnWidth($description->getCommands());
  37930. if ($describedNamespace) {
  37931. $this->writeText(sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);
  37932. } else {
  37933. $this->writeText('<comment>Available commands:</comment>', $options);
  37934. }
  37935. foreach ($description->getNamespaces() as $namespace) {
  37936. if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
  37937. $this->writeText("\n");
  37938. $this->writeText(' <comment>'.$namespace['id'].'</comment>', $options);
  37939. }
  37940. foreach ($namespace['commands'] as $name) {
  37941. $this->writeText("\n");
  37942. $spacingWidth = $width - Helper::strlen($name);
  37943. $this->writeText(sprintf(' <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $description->getCommand($name)->getDescription()), $options);
  37944. }
  37945. }
  37946. $this->writeText("\n");
  37947. }
  37948. }
  37949. private function writeText($content, array $options = array())
  37950. {
  37951. $this->write(
  37952. isset($options['raw_text']) && $options['raw_text'] ? strip_tags($content) : $content,
  37953. isset($options['raw_output']) ? !$options['raw_output'] : true
  37954. );
  37955. }
  37956. private function formatDefaultValue($default)
  37957. {
  37958. if (INF === $default) {
  37959. return 'INF';
  37960. }
  37961. if (\is_string($default)) {
  37962. $default = OutputFormatter::escape($default);
  37963. } elseif (\is_array($default)) {
  37964. foreach ($default as $key => $value) {
  37965. if (\is_string($value)) {
  37966. $default[$key] = OutputFormatter::escape($value);
  37967. }
  37968. }
  37969. }
  37970. if (\PHP_VERSION_ID < 50400) {
  37971. return str_replace(array('\/', '\\\\'), array('/', '\\'), json_encode($default));
  37972. }
  37973. return str_replace('\\\\', '\\', json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
  37974. }
  37975. private function getColumnWidth(array $commands)
  37976. {
  37977. $widths = array();
  37978. foreach ($commands as $command) {
  37979. $widths[] = Helper::strlen($command->getName());
  37980. foreach ($command->getAliases() as $alias) {
  37981. $widths[] = Helper::strlen($alias);
  37982. }
  37983. }
  37984. return max($widths) + 2;
  37985. }
  37986. private function calculateTotalWidthForOptions(array $options)
  37987. {
  37988. $totalWidth = 0;
  37989. foreach ($options as $option) {
  37990. $nameLength = 1 + max(\strlen($option->getShortcut()), 1) + 4 + Helper::strlen($option->getName());
  37991. if ($option->acceptValue()) {
  37992. $valueLength = 1 + Helper::strlen($option->getName());
  37993. $valueLength += $option->isValueOptional() ? 2 : 0;
  37994. $nameLength += $valueLength;
  37995. }
  37996. $totalWidth = max($totalWidth, $nameLength);
  37997. }
  37998. return $totalWidth;
  37999. }
  38000. }
  38001. <?php
  38002. namespace Symfony\Component\Console\Descriptor;
  38003. use Symfony\Component\Console\Application;
  38004. use Symfony\Component\Console\Command\Command;
  38005. use Symfony\Component\Console\Input\InputArgument;
  38006. use Symfony\Component\Console\Input\InputDefinition;
  38007. use Symfony\Component\Console\Input\InputOption;
  38008. class XmlDescriptor extends Descriptor
  38009. {
  38010. public function getInputDefinitionDocument(InputDefinition $definition)
  38011. {
  38012. $dom = new \DOMDocument('1.0', 'UTF-8');
  38013. $dom->appendChild($definitionXML = $dom->createElement('definition'));
  38014. $definitionXML->appendChild($argumentsXML = $dom->createElement('arguments'));
  38015. foreach ($definition->getArguments() as $argument) {
  38016. $this->appendDocument($argumentsXML, $this->getInputArgumentDocument($argument));
  38017. }
  38018. $definitionXML->appendChild($optionsXML = $dom->createElement('options'));
  38019. foreach ($definition->getOptions() as $option) {
  38020. $this->appendDocument($optionsXML, $this->getInputOptionDocument($option));
  38021. }
  38022. return $dom;
  38023. }
  38024. public function getCommandDocument(Command $command)
  38025. {
  38026. $dom = new \DOMDocument('1.0', 'UTF-8');
  38027. $dom->appendChild($commandXML = $dom->createElement('command'));
  38028. $command->getSynopsis();
  38029. $command->mergeApplicationDefinition(false);
  38030. $commandXML->setAttribute('id', $command->getName());
  38031. $commandXML->setAttribute('name', $command->getName());
  38032. $commandXML->appendChild($usagesXML = $dom->createElement('usages'));
  38033. foreach (array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()) as $usage) {
  38034. $usagesXML->appendChild($dom->createElement('usage', $usage));
  38035. }
  38036. $commandXML->appendChild($descriptionXML = $dom->createElement('description'));
  38037. $descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getDescription())));
  38038. $commandXML->appendChild($helpXML = $dom->createElement('help'));
  38039. $helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getProcessedHelp())));
  38040. $definitionXML = $this->getInputDefinitionDocument($command->getNativeDefinition());
  38041. $this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0));
  38042. return $dom;
  38043. }
  38044. public function getApplicationDocument(Application $application, $namespace = null)
  38045. {
  38046. $dom = new \DOMDocument('1.0', 'UTF-8');
  38047. $dom->appendChild($rootXml = $dom->createElement('symfony'));
  38048. if ('UNKNOWN' !== $application->getName()) {
  38049. $rootXml->setAttribute('name', $application->getName());
  38050. if ('UNKNOWN' !== $application->getVersion()) {
  38051. $rootXml->setAttribute('version', $application->getVersion());
  38052. }
  38053. }
  38054. $rootXml->appendChild($commandsXML = $dom->createElement('commands'));
  38055. $description = new ApplicationDescription($application, $namespace);
  38056. if ($namespace) {
  38057. $commandsXML->setAttribute('namespace', $namespace);
  38058. }
  38059. foreach ($description->getCommands() as $command) {
  38060. $this->appendDocument($commandsXML, $this->getCommandDocument($command));
  38061. }
  38062. if (!$namespace) {
  38063. $rootXml->appendChild($namespacesXML = $dom->createElement('namespaces'));
  38064. foreach ($description->getNamespaces() as $namespaceDescription) {
  38065. $namespacesXML->appendChild($namespaceArrayXML = $dom->createElement('namespace'));
  38066. $namespaceArrayXML->setAttribute('id', $namespaceDescription['id']);
  38067. foreach ($namespaceDescription['commands'] as $name) {
  38068. $namespaceArrayXML->appendChild($commandXML = $dom->createElement('command'));
  38069. $commandXML->appendChild($dom->createTextNode($name));
  38070. }
  38071. }
  38072. }
  38073. return $dom;
  38074. }
  38075. protected function describeInputArgument(InputArgument $argument, array $options = array())
  38076. {
  38077. $this->writeDocument($this->getInputArgumentDocument($argument));
  38078. }
  38079. protected function describeInputOption(InputOption $option, array $options = array())
  38080. {
  38081. $this->writeDocument($this->getInputOptionDocument($option));
  38082. }
  38083. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  38084. {
  38085. $this->writeDocument($this->getInputDefinitionDocument($definition));
  38086. }
  38087. protected function describeCommand(Command $command, array $options = array())
  38088. {
  38089. $this->writeDocument($this->getCommandDocument($command));
  38090. }
  38091. protected function describeApplication(Application $application, array $options = array())
  38092. {
  38093. $this->writeDocument($this->getApplicationDocument($application, isset($options['namespace']) ? $options['namespace'] : null));
  38094. }
  38095. private function appendDocument(\DOMNode $parentNode, \DOMNode $importedParent)
  38096. {
  38097. foreach ($importedParent->childNodes as $childNode) {
  38098. $parentNode->appendChild($parentNode->ownerDocument->importNode($childNode, true));
  38099. }
  38100. }
  38101. private function writeDocument(\DOMDocument $dom)
  38102. {
  38103. $dom->formatOutput = true;
  38104. $this->write($dom->saveXML());
  38105. }
  38106. private function getInputArgumentDocument(InputArgument $argument)
  38107. {
  38108. $dom = new \DOMDocument('1.0', 'UTF-8');
  38109. $dom->appendChild($objectXML = $dom->createElement('argument'));
  38110. $objectXML->setAttribute('name', $argument->getName());
  38111. $objectXML->setAttribute('is_required', $argument->isRequired() ? 1 : 0);
  38112. $objectXML->setAttribute('is_array', $argument->isArray() ? 1 : 0);
  38113. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  38114. $descriptionXML->appendChild($dom->createTextNode($argument->getDescription()));
  38115. $objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
  38116. $defaults = \is_array($argument->getDefault()) ? $argument->getDefault() : (\is_bool($argument->getDefault()) ? array(var_export($argument->getDefault(), true)) : ($argument->getDefault() ? array($argument->getDefault()) : array()));
  38117. foreach ($defaults as $default) {
  38118. $defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
  38119. $defaultXML->appendChild($dom->createTextNode($default));
  38120. }
  38121. return $dom;
  38122. }
  38123. private function getInputOptionDocument(InputOption $option)
  38124. {
  38125. $dom = new \DOMDocument('1.0', 'UTF-8');
  38126. $dom->appendChild($objectXML = $dom->createElement('option'));
  38127. $objectXML->setAttribute('name', '--'.$option->getName());
  38128. $pos = strpos($option->getShortcut(), '|');
  38129. if (false !== $pos) {
  38130. $objectXML->setAttribute('shortcut', '-'.substr($option->getShortcut(), 0, $pos));
  38131. $objectXML->setAttribute('shortcuts', '-'.str_replace('|', '|-', $option->getShortcut()));
  38132. } else {
  38133. $objectXML->setAttribute('shortcut', $option->getShortcut() ? '-'.$option->getShortcut() : '');
  38134. }
  38135. $objectXML->setAttribute('accept_value', $option->acceptValue() ? 1 : 0);
  38136. $objectXML->setAttribute('is_value_required', $option->isValueRequired() ? 1 : 0);
  38137. $objectXML->setAttribute('is_multiple', $option->isArray() ? 1 : 0);
  38138. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  38139. $descriptionXML->appendChild($dom->createTextNode($option->getDescription()));
  38140. if ($option->acceptValue()) {
  38141. $defaults = \is_array($option->getDefault()) ? $option->getDefault() : (\is_bool($option->getDefault()) ? array(var_export($option->getDefault(), true)) : ($option->getDefault() ? array($option->getDefault()) : array()));
  38142. $objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
  38143. if (!empty($defaults)) {
  38144. foreach ($defaults as $default) {
  38145. $defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
  38146. $defaultXML->appendChild($dom->createTextNode($default));
  38147. }
  38148. }
  38149. }
  38150. return $dom;
  38151. }
  38152. }
  38153. <?php
  38154. namespace Symfony\Component\Console\Event;
  38155. class ConsoleCommandEvent extends ConsoleEvent
  38156. {
  38157. const RETURN_CODE_DISABLED = 113;
  38158. private $commandShouldRun = true;
  38159. public function disableCommand()
  38160. {
  38161. return $this->commandShouldRun = false;
  38162. }
  38163. public function enableCommand()
  38164. {
  38165. return $this->commandShouldRun = true;
  38166. }
  38167. public function commandShouldRun()
  38168. {
  38169. return $this->commandShouldRun;
  38170. }
  38171. }
  38172. <?php
  38173. namespace Symfony\Component\Console\Event;
  38174. use Symfony\Component\Console\Command\Command;
  38175. use Symfony\Component\Console\Input\InputInterface;
  38176. use Symfony\Component\Console\Output\OutputInterface;
  38177. use Symfony\Component\EventDispatcher\Event;
  38178. class ConsoleEvent extends Event
  38179. {
  38180. protected $command;
  38181. private $input;
  38182. private $output;
  38183. public function __construct(Command $command, InputInterface $input, OutputInterface $output)
  38184. {
  38185. $this->command = $command;
  38186. $this->input = $input;
  38187. $this->output = $output;
  38188. }
  38189. public function getCommand()
  38190. {
  38191. return $this->command;
  38192. }
  38193. public function getInput()
  38194. {
  38195. return $this->input;
  38196. }
  38197. public function getOutput()
  38198. {
  38199. return $this->output;
  38200. }
  38201. }
  38202. <?php
  38203. namespace Symfony\Component\Console\Event;
  38204. use Symfony\Component\Console\Command\Command;
  38205. use Symfony\Component\Console\Input\InputInterface;
  38206. use Symfony\Component\Console\Output\OutputInterface;
  38207. class ConsoleExceptionEvent extends ConsoleEvent
  38208. {
  38209. private $exception;
  38210. private $exitCode;
  38211. public function __construct(Command $command, InputInterface $input, OutputInterface $output, \Exception $exception, $exitCode)
  38212. {
  38213. parent::__construct($command, $input, $output);
  38214. $this->setException($exception);
  38215. $this->exitCode = (int) $exitCode;
  38216. }
  38217. public function getException()
  38218. {
  38219. return $this->exception;
  38220. }
  38221. public function setException(\Exception $exception)
  38222. {
  38223. $this->exception = $exception;
  38224. }
  38225. public function getExitCode()
  38226. {
  38227. return $this->exitCode;
  38228. }
  38229. }
  38230. <?php
  38231. namespace Symfony\Component\Console\Event;
  38232. use Symfony\Component\Console\Command\Command;
  38233. use Symfony\Component\Console\Input\InputInterface;
  38234. use Symfony\Component\Console\Output\OutputInterface;
  38235. class ConsoleTerminateEvent extends ConsoleEvent
  38236. {
  38237. private $exitCode;
  38238. public function __construct(Command $command, InputInterface $input, OutputInterface $output, $exitCode)
  38239. {
  38240. parent::__construct($command, $input, $output);
  38241. $this->setExitCode($exitCode);
  38242. }
  38243. public function setExitCode($exitCode)
  38244. {
  38245. $this->exitCode = (int) $exitCode;
  38246. }
  38247. public function getExitCode()
  38248. {
  38249. return $this->exitCode;
  38250. }
  38251. }
  38252. <?php
  38253. namespace Symfony\Component\Console\Exception;
  38254. class CommandNotFoundException extends \InvalidArgumentException implements ExceptionInterface
  38255. {
  38256. private $alternatives;
  38257. public function __construct($message, array $alternatives = array(), $code = 0, \Exception $previous = null)
  38258. {
  38259. parent::__construct($message, $code, $previous);
  38260. $this->alternatives = $alternatives;
  38261. }
  38262. public function getAlternatives()
  38263. {
  38264. return $this->alternatives;
  38265. }
  38266. }
  38267. <?php
  38268. namespace Symfony\Component\Console\Exception;
  38269. interface ExceptionInterface
  38270. {
  38271. }
  38272. <?php
  38273. namespace Symfony\Component\Console\Exception;
  38274. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  38275. {
  38276. }
  38277. <?php
  38278. namespace Symfony\Component\Console\Exception;
  38279. class InvalidOptionException extends \InvalidArgumentException implements ExceptionInterface
  38280. {
  38281. }
  38282. <?php
  38283. namespace Symfony\Component\Console\Exception;
  38284. class LogicException extends \LogicException implements ExceptionInterface
  38285. {
  38286. }
  38287. <?php
  38288. namespace Symfony\Component\Console\Exception;
  38289. class RuntimeException extends \RuntimeException implements ExceptionInterface
  38290. {
  38291. }
  38292. <?php
  38293. namespace Symfony\Component\Console\Formatter;
  38294. use Symfony\Component\Console\Exception\InvalidArgumentException;
  38295. class OutputFormatter implements OutputFormatterInterface
  38296. {
  38297. private $decorated;
  38298. private $styles = array();
  38299. private $styleStack;
  38300. public static function escape($text)
  38301. {
  38302. $text = preg_replace('/([^\\\\]?)</', '$1\\<', $text);
  38303. return self::escapeTrailingBackslash($text);
  38304. }
  38305. public static function escapeTrailingBackslash($text)
  38306. {
  38307. if ('\\' === substr($text, -1)) {
  38308. $len = \strlen($text);
  38309. $text = rtrim($text, '\\');
  38310. $text = str_replace("\0", '', $text);
  38311. $text .= str_repeat("\0", $len - \strlen($text));
  38312. }
  38313. return $text;
  38314. }
  38315. public function __construct($decorated = false, array $styles = array())
  38316. {
  38317. $this->decorated = (bool) $decorated;
  38318. $this->setStyle('error', new OutputFormatterStyle('white', 'red'));
  38319. $this->setStyle('info', new OutputFormatterStyle('green'));
  38320. $this->setStyle('comment', new OutputFormatterStyle('yellow'));
  38321. $this->setStyle('question', new OutputFormatterStyle('black', 'cyan'));
  38322. foreach ($styles as $name => $style) {
  38323. $this->setStyle($name, $style);
  38324. }
  38325. $this->styleStack = new OutputFormatterStyleStack();
  38326. }
  38327. public function setDecorated($decorated)
  38328. {
  38329. $this->decorated = (bool) $decorated;
  38330. }
  38331. public function isDecorated()
  38332. {
  38333. return $this->decorated;
  38334. }
  38335. public function setStyle($name, OutputFormatterStyleInterface $style)
  38336. {
  38337. $this->styles[strtolower($name)] = $style;
  38338. }
  38339. public function hasStyle($name)
  38340. {
  38341. return isset($this->styles[strtolower($name)]);
  38342. }
  38343. public function getStyle($name)
  38344. {
  38345. if (!$this->hasStyle($name)) {
  38346. throw new InvalidArgumentException(sprintf('Undefined style: %s', $name));
  38347. }
  38348. return $this->styles[strtolower($name)];
  38349. }
  38350. public function format($message)
  38351. {
  38352. $message = (string) $message;
  38353. $offset = 0;
  38354. $output = '';
  38355. $tagRegex = '[a-z][a-z0-9_=;-]*+';
  38356. preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#ix", $message, $matches, PREG_OFFSET_CAPTURE);
  38357. foreach ($matches[0] as $i => $match) {
  38358. $pos = $match[1];
  38359. $text = $match[0];
  38360. if (0 != $pos && '\\' == $message[$pos - 1]) {
  38361. continue;
  38362. }
  38363. $output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset));
  38364. $offset = $pos + \strlen($text);
  38365. if ($open = '/' != $text[1]) {
  38366. $tag = $matches[1][$i][0];
  38367. } else {
  38368. $tag = isset($matches[3][$i][0]) ? $matches[3][$i][0] : '';
  38369. }
  38370. if (!$open && !$tag) {
  38371. $this->styleStack->pop();
  38372. } elseif (false === $style = $this->createStyleFromString(strtolower($tag))) {
  38373. $output .= $this->applyCurrentStyle($text);
  38374. } elseif ($open) {
  38375. $this->styleStack->push($style);
  38376. } else {
  38377. $this->styleStack->pop($style);
  38378. }
  38379. }
  38380. $output .= $this->applyCurrentStyle(substr($message, $offset));
  38381. if (false !== strpos($output, "\0")) {
  38382. return strtr($output, array("\0" => '\\', '\\<' => '<'));
  38383. }
  38384. return str_replace('\\<', '<', $output);
  38385. }
  38386. public function getStyleStack()
  38387. {
  38388. return $this->styleStack;
  38389. }
  38390. private function createStyleFromString($string)
  38391. {
  38392. if (isset($this->styles[$string])) {
  38393. return $this->styles[$string];
  38394. }
  38395. if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', strtolower($string), $matches, PREG_SET_ORDER)) {
  38396. return false;
  38397. }
  38398. $style = new OutputFormatterStyle();
  38399. foreach ($matches as $match) {
  38400. array_shift($match);
  38401. if ('fg' == $match[0]) {
  38402. $style->setForeground($match[1]);
  38403. } elseif ('bg' == $match[0]) {
  38404. $style->setBackground($match[1]);
  38405. } else {
  38406. try {
  38407. $style->setOption($match[1]);
  38408. } catch (\InvalidArgumentException $e) {
  38409. return false;
  38410. }
  38411. }
  38412. }
  38413. return $style;
  38414. }
  38415. private function applyCurrentStyle($text)
  38416. {
  38417. return $this->isDecorated() && \strlen($text) > 0 ? $this->styleStack->getCurrent()->apply($text) : $text;
  38418. }
  38419. }
  38420. <?php
  38421. namespace Symfony\Component\Console\Formatter;
  38422. interface OutputFormatterInterface
  38423. {
  38424. public function setDecorated($decorated);
  38425. public function isDecorated();
  38426. public function setStyle($name, OutputFormatterStyleInterface $style);
  38427. public function hasStyle($name);
  38428. public function getStyle($name);
  38429. public function format($message);
  38430. }
  38431. <?php
  38432. namespace Symfony\Component\Console\Formatter;
  38433. use Symfony\Component\Console\Exception\InvalidArgumentException;
  38434. class OutputFormatterStyle implements OutputFormatterStyleInterface
  38435. {
  38436. private static $availableForegroundColors = array(
  38437. 'black' => array('set' => 30, 'unset' => 39),
  38438. 'red' => array('set' => 31, 'unset' => 39),
  38439. 'green' => array('set' => 32, 'unset' => 39),
  38440. 'yellow' => array('set' => 33, 'unset' => 39),
  38441. 'blue' => array('set' => 34, 'unset' => 39),
  38442. 'magenta' => array('set' => 35, 'unset' => 39),
  38443. 'cyan' => array('set' => 36, 'unset' => 39),
  38444. 'white' => array('set' => 37, 'unset' => 39),
  38445. 'default' => array('set' => 39, 'unset' => 39),
  38446. );
  38447. private static $availableBackgroundColors = array(
  38448. 'black' => array('set' => 40, 'unset' => 49),
  38449. 'red' => array('set' => 41, 'unset' => 49),
  38450. 'green' => array('set' => 42, 'unset' => 49),
  38451. 'yellow' => array('set' => 43, 'unset' => 49),
  38452. 'blue' => array('set' => 44, 'unset' => 49),
  38453. 'magenta' => array('set' => 45, 'unset' => 49),
  38454. 'cyan' => array('set' => 46, 'unset' => 49),
  38455. 'white' => array('set' => 47, 'unset' => 49),
  38456. 'default' => array('set' => 49, 'unset' => 49),
  38457. );
  38458. private static $availableOptions = array(
  38459. 'bold' => array('set' => 1, 'unset' => 22),
  38460. 'underscore' => array('set' => 4, 'unset' => 24),
  38461. 'blink' => array('set' => 5, 'unset' => 25),
  38462. 'reverse' => array('set' => 7, 'unset' => 27),
  38463. 'conceal' => array('set' => 8, 'unset' => 28),
  38464. );
  38465. private $foreground;
  38466. private $background;
  38467. private $options = array();
  38468. public function __construct($foreground = null, $background = null, array $options = array())
  38469. {
  38470. if (null !== $foreground) {
  38471. $this->setForeground($foreground);
  38472. }
  38473. if (null !== $background) {
  38474. $this->setBackground($background);
  38475. }
  38476. if (\count($options)) {
  38477. $this->setOptions($options);
  38478. }
  38479. }
  38480. public function setForeground($color = null)
  38481. {
  38482. if (null === $color) {
  38483. $this->foreground = null;
  38484. return;
  38485. }
  38486. if (!isset(static::$availableForegroundColors[$color])) {
  38487. throw new InvalidArgumentException(sprintf('Invalid foreground color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableForegroundColors))));
  38488. }
  38489. $this->foreground = static::$availableForegroundColors[$color];
  38490. }
  38491. public function setBackground($color = null)
  38492. {
  38493. if (null === $color) {
  38494. $this->background = null;
  38495. return;
  38496. }
  38497. if (!isset(static::$availableBackgroundColors[$color])) {
  38498. throw new InvalidArgumentException(sprintf('Invalid background color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableBackgroundColors))));
  38499. }
  38500. $this->background = static::$availableBackgroundColors[$color];
  38501. }
  38502. public function setOption($option)
  38503. {
  38504. if (!isset(static::$availableOptions[$option])) {
  38505. throw new InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s)', $option, implode(', ', array_keys(static::$availableOptions))));
  38506. }
  38507. if (!\in_array(static::$availableOptions[$option], $this->options)) {
  38508. $this->options[] = static::$availableOptions[$option];
  38509. }
  38510. }
  38511. public function unsetOption($option)
  38512. {
  38513. if (!isset(static::$availableOptions[$option])) {
  38514. throw new InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s)', $option, implode(', ', array_keys(static::$availableOptions))));
  38515. }
  38516. $pos = array_search(static::$availableOptions[$option], $this->options);
  38517. if (false !== $pos) {
  38518. unset($this->options[$pos]);
  38519. }
  38520. }
  38521. public function setOptions(array $options)
  38522. {
  38523. $this->options = array();
  38524. foreach ($options as $option) {
  38525. $this->setOption($option);
  38526. }
  38527. }
  38528. public function apply($text)
  38529. {
  38530. $setCodes = array();
  38531. $unsetCodes = array();
  38532. if (null !== $this->foreground) {
  38533. $setCodes[] = $this->foreground['set'];
  38534. $unsetCodes[] = $this->foreground['unset'];
  38535. }
  38536. if (null !== $this->background) {
  38537. $setCodes[] = $this->background['set'];
  38538. $unsetCodes[] = $this->background['unset'];
  38539. }
  38540. if (\count($this->options)) {
  38541. foreach ($this->options as $option) {
  38542. $setCodes[] = $option['set'];
  38543. $unsetCodes[] = $option['unset'];
  38544. }
  38545. }
  38546. if (0 === \count($setCodes)) {
  38547. return $text;
  38548. }
  38549. return sprintf("\033[%sm%s\033[%sm", implode(';', $setCodes), $text, implode(';', $unsetCodes));
  38550. }
  38551. }
  38552. <?php
  38553. namespace Symfony\Component\Console\Formatter;
  38554. interface OutputFormatterStyleInterface
  38555. {
  38556. public function setForeground($color = null);
  38557. public function setBackground($color = null);
  38558. public function setOption($option);
  38559. public function unsetOption($option);
  38560. public function setOptions(array $options);
  38561. public function apply($text);
  38562. }
  38563. <?php
  38564. namespace Symfony\Component\Console\Formatter;
  38565. use Symfony\Component\Console\Exception\InvalidArgumentException;
  38566. class OutputFormatterStyleStack
  38567. {
  38568. private $styles;
  38569. private $emptyStyle;
  38570. public function __construct(OutputFormatterStyleInterface $emptyStyle = null)
  38571. {
  38572. $this->emptyStyle = $emptyStyle ?: new OutputFormatterStyle();
  38573. $this->reset();
  38574. }
  38575. public function reset()
  38576. {
  38577. $this->styles = array();
  38578. }
  38579. public function push(OutputFormatterStyleInterface $style)
  38580. {
  38581. $this->styles[] = $style;
  38582. }
  38583. public function pop(OutputFormatterStyleInterface $style = null)
  38584. {
  38585. if (empty($this->styles)) {
  38586. return $this->emptyStyle;
  38587. }
  38588. if (null === $style) {
  38589. return array_pop($this->styles);
  38590. }
  38591. foreach (array_reverse($this->styles, true) as $index => $stackedStyle) {
  38592. if ($style->apply('') === $stackedStyle->apply('')) {
  38593. $this->styles = \array_slice($this->styles, 0, $index);
  38594. return $stackedStyle;
  38595. }
  38596. }
  38597. throw new InvalidArgumentException('Incorrectly nested style tag found.');
  38598. }
  38599. public function getCurrent()
  38600. {
  38601. if (empty($this->styles)) {
  38602. return $this->emptyStyle;
  38603. }
  38604. return $this->styles[\count($this->styles) - 1];
  38605. }
  38606. public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle)
  38607. {
  38608. $this->emptyStyle = $emptyStyle;
  38609. return $this;
  38610. }
  38611. public function getEmptyStyle()
  38612. {
  38613. return $this->emptyStyle;
  38614. }
  38615. }
  38616. <?php
  38617. namespace Symfony\Component\Console\Helper;
  38618. class DebugFormatterHelper extends Helper
  38619. {
  38620. private $colors = array('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default');
  38621. private $started = array();
  38622. private $count = -1;
  38623. public function start($id, $message, $prefix = 'RUN')
  38624. {
  38625. $this->started[$id] = array('border' => ++$this->count % \count($this->colors));
  38626. return sprintf("%s<bg=blue;fg=white> %s </> <fg=blue>%s</>\n", $this->getBorder($id), $prefix, $message);
  38627. }
  38628. public function progress($id, $buffer, $error = false, $prefix = 'OUT', $errorPrefix = 'ERR')
  38629. {
  38630. $message = '';
  38631. if ($error) {
  38632. if (isset($this->started[$id]['out'])) {
  38633. $message .= "\n";
  38634. unset($this->started[$id]['out']);
  38635. }
  38636. if (!isset($this->started[$id]['err'])) {
  38637. $message .= sprintf('%s<bg=red;fg=white> %s </> ', $this->getBorder($id), $errorPrefix);
  38638. $this->started[$id]['err'] = true;
  38639. }
  38640. $message .= str_replace("\n", sprintf("\n%s<bg=red;fg=white> %s </> ", $this->getBorder($id), $errorPrefix), $buffer);
  38641. } else {
  38642. if (isset($this->started[$id]['err'])) {
  38643. $message .= "\n";
  38644. unset($this->started[$id]['err']);
  38645. }
  38646. if (!isset($this->started[$id]['out'])) {
  38647. $message .= sprintf('%s<bg=green;fg=white> %s </> ', $this->getBorder($id), $prefix);
  38648. $this->started[$id]['out'] = true;
  38649. }
  38650. $message .= str_replace("\n", sprintf("\n%s<bg=green;fg=white> %s </> ", $this->getBorder($id), $prefix), $buffer);
  38651. }
  38652. return $message;
  38653. }
  38654. public function stop($id, $message, $successful, $prefix = 'RES')
  38655. {
  38656. $trailingEOL = isset($this->started[$id]['out']) || isset($this->started[$id]['err']) ? "\n" : '';
  38657. if ($successful) {
  38658. return sprintf("%s%s<bg=green;fg=white> %s </> <fg=green>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
  38659. }
  38660. $message = sprintf("%s%s<bg=red;fg=white> %s </> <fg=red>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
  38661. unset($this->started[$id]['out'], $this->started[$id]['err']);
  38662. return $message;
  38663. }
  38664. private function getBorder($id)
  38665. {
  38666. return sprintf('<bg=%s> </>', $this->colors[$this->started[$id]['border']]);
  38667. }
  38668. public function getName()
  38669. {
  38670. return 'debug_formatter';
  38671. }
  38672. }
  38673. <?php
  38674. namespace Symfony\Component\Console\Helper;
  38675. use Symfony\Component\Console\Descriptor\DescriptorInterface;
  38676. use Symfony\Component\Console\Descriptor\JsonDescriptor;
  38677. use Symfony\Component\Console\Descriptor\MarkdownDescriptor;
  38678. use Symfony\Component\Console\Descriptor\TextDescriptor;
  38679. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  38680. use Symfony\Component\Console\Exception\InvalidArgumentException;
  38681. use Symfony\Component\Console\Output\OutputInterface;
  38682. class DescriptorHelper extends Helper
  38683. {
  38684. private $descriptors = array();
  38685. public function __construct()
  38686. {
  38687. $this
  38688. ->register('txt', new TextDescriptor())
  38689. ->register('xml', new XmlDescriptor())
  38690. ->register('json', new JsonDescriptor())
  38691. ->register('md', new MarkdownDescriptor())
  38692. ;
  38693. }
  38694. public function describe(OutputInterface $output, $object, array $options = array())
  38695. {
  38696. $options = array_merge(array(
  38697. 'raw_text' => false,
  38698. 'format' => 'txt',
  38699. ), $options);
  38700. if (!isset($this->descriptors[$options['format']])) {
  38701. throw new InvalidArgumentException(sprintf('Unsupported format "%s".', $options['format']));
  38702. }
  38703. $descriptor = $this->descriptors[$options['format']];
  38704. $descriptor->describe($output, $object, $options);
  38705. }
  38706. public function register($format, DescriptorInterface $descriptor)
  38707. {
  38708. $this->descriptors[$format] = $descriptor;
  38709. return $this;
  38710. }
  38711. public function getName()
  38712. {
  38713. return 'descriptor';
  38714. }
  38715. }
  38716. <?php
  38717. namespace Symfony\Component\Console\Helper;
  38718. use Symfony\Component\Console\Exception\InvalidArgumentException;
  38719. use Symfony\Component\Console\Exception\RuntimeException;
  38720. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  38721. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  38722. use Symfony\Component\Console\Output\OutputInterface;
  38723. class DialogHelper extends InputAwareHelper
  38724. {
  38725. private $inputStream;
  38726. private static $shell;
  38727. private static $stty;
  38728. public function __construct($triggerDeprecationError = true)
  38729. {
  38730. if ($triggerDeprecationError) {
  38731. @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);
  38732. }
  38733. }
  38734. public function select(OutputInterface $output, $question, $choices, $default = null, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  38735. {
  38736. if ($output instanceof ConsoleOutputInterface) {
  38737. $output = $output->getErrorOutput();
  38738. }
  38739. $width = max(array_map('strlen', array_keys($choices)));
  38740. $messages = (array) $question;
  38741. foreach ($choices as $key => $value) {
  38742. $messages[] = sprintf(" [<info>%-{$width}s</info>] %s", $key, $value);
  38743. }
  38744. $output->writeln($messages);
  38745. $result = $this->askAndValidate($output, '> ', function ($picked) use ($choices, $errorMessage, $multiselect) {
  38746. $selectedChoices = str_replace(' ', '', $picked);
  38747. if ($multiselect) {
  38748. if (!preg_match('/^[a-zA-Z0-9_-]+(?:,[a-zA-Z0-9_-]+)*$/', $selectedChoices, $matches)) {
  38749. throw new InvalidArgumentException(sprintf($errorMessage, $picked));
  38750. }
  38751. $selectedChoices = explode(',', $selectedChoices);
  38752. } else {
  38753. $selectedChoices = array($picked);
  38754. }
  38755. $multiselectChoices = array();
  38756. foreach ($selectedChoices as $value) {
  38757. if (empty($choices[$value])) {
  38758. throw new InvalidArgumentException(sprintf($errorMessage, $value));
  38759. }
  38760. $multiselectChoices[] = $value;
  38761. }
  38762. if ($multiselect) {
  38763. return $multiselectChoices;
  38764. }
  38765. return $picked;
  38766. }, $attempts, $default);
  38767. return $result;
  38768. }
  38769. public function ask(OutputInterface $output, $question, $default = null, array $autocomplete = null)
  38770. {
  38771. if ($this->input && !$this->input->isInteractive()) {
  38772. return $default;
  38773. }
  38774. if ($output instanceof ConsoleOutputInterface) {
  38775. $output = $output->getErrorOutput();
  38776. }
  38777. $output->write($question);
  38778. $inputStream = $this->inputStream ?: STDIN;
  38779. if (null === $autocomplete || !$this->hasSttyAvailable()) {
  38780. $ret = fgets($inputStream, 4096);
  38781. if (false === $ret) {
  38782. throw new RuntimeException('Aborted');
  38783. }
  38784. $ret = trim($ret);
  38785. } else {
  38786. $ret = '';
  38787. $i = 0;
  38788. $ofs = -1;
  38789. $matches = $autocomplete;
  38790. $numMatches = \count($matches);
  38791. $sttyMode = shell_exec('stty -g');
  38792. shell_exec('stty -icanon -echo');
  38793. $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
  38794. while (!feof($inputStream)) {
  38795. $c = fread($inputStream, 1);
  38796. if ("\177" === $c) {
  38797. if (0 === $numMatches && 0 !== $i) {
  38798. --$i;
  38799. $output->write("\033[1D");
  38800. }
  38801. if (0 === $i) {
  38802. $ofs = -1;
  38803. $matches = $autocomplete;
  38804. $numMatches = \count($matches);
  38805. } else {
  38806. $numMatches = 0;
  38807. }
  38808. $ret = substr($ret, 0, $i);
  38809. } elseif ("\033" === $c) {
  38810. $c .= fread($inputStream, 2);
  38811. if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) {
  38812. if ('A' === $c[2] && -1 === $ofs) {
  38813. $ofs = 0;
  38814. }
  38815. if (0 === $numMatches) {
  38816. continue;
  38817. }
  38818. $ofs += ('A' === $c[2]) ? -1 : 1;
  38819. $ofs = ($numMatches + $ofs) % $numMatches;
  38820. }
  38821. } elseif (\ord($c) < 32) {
  38822. if ("\t" === $c || "\n" === $c) {
  38823. if ($numMatches > 0 && -1 !== $ofs) {
  38824. $ret = $matches[$ofs];
  38825. $output->write(substr($ret, $i));
  38826. $i = \strlen($ret);
  38827. }
  38828. if ("\n" === $c) {
  38829. $output->write($c);
  38830. break;
  38831. }
  38832. $numMatches = 0;
  38833. }
  38834. continue;
  38835. } else {
  38836. $output->write($c);
  38837. $ret .= $c;
  38838. ++$i;
  38839. $numMatches = 0;
  38840. $ofs = 0;
  38841. foreach ($autocomplete as $value) {
  38842. if (0 === strpos($value, $ret) && $i !== \strlen($value)) {
  38843. $matches[$numMatches++] = $value;
  38844. }
  38845. }
  38846. }
  38847. $output->write("\033[K");
  38848. if ($numMatches > 0 && -1 !== $ofs) {
  38849. $output->write("\0337");
  38850. $output->write('<hl>'.substr($matches[$ofs], $i).'</hl>');
  38851. $output->write("\0338");
  38852. }
  38853. }
  38854. shell_exec(sprintf('stty %s', $sttyMode));
  38855. }
  38856. return \strlen($ret) > 0 ? $ret : $default;
  38857. }
  38858. public function askConfirmation(OutputInterface $output, $question, $default = true)
  38859. {
  38860. $answer = 'z';
  38861. while ($answer && !\in_array(strtolower($answer[0]), array('y', 'n'))) {
  38862. $answer = $this->ask($output, $question);
  38863. }
  38864. if (false === $default) {
  38865. return $answer && 'y' == strtolower($answer[0]);
  38866. }
  38867. return !$answer || 'y' == strtolower($answer[0]);
  38868. }
  38869. public function askHiddenResponse(OutputInterface $output, $question, $fallback = true)
  38870. {
  38871. if ($output instanceof ConsoleOutputInterface) {
  38872. $output = $output->getErrorOutput();
  38873. }
  38874. if ('\\' === \DIRECTORY_SEPARATOR) {
  38875. $exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
  38876. if ('phar:' === substr(__FILE__, 0, 5)) {
  38877. $tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
  38878. copy($exe, $tmpExe);
  38879. $exe = $tmpExe;
  38880. }
  38881. $output->write($question);
  38882. $value = rtrim(shell_exec($exe));
  38883. $output->writeln('');
  38884. if (isset($tmpExe)) {
  38885. unlink($tmpExe);
  38886. }
  38887. return $value;
  38888. }
  38889. if ($this->hasSttyAvailable()) {
  38890. $output->write($question);
  38891. $sttyMode = shell_exec('stty -g');
  38892. shell_exec('stty -echo');
  38893. $value = fgets($this->inputStream ?: STDIN, 4096);
  38894. shell_exec(sprintf('stty %s', $sttyMode));
  38895. if (false === $value) {
  38896. throw new RuntimeException('Aborted');
  38897. }
  38898. $value = trim($value);
  38899. $output->writeln('');
  38900. return $value;
  38901. }
  38902. if (false !== $shell = $this->getShell()) {
  38903. $output->write($question);
  38904. $readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword';
  38905. $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
  38906. $value = rtrim(shell_exec($command));
  38907. $output->writeln('');
  38908. return $value;
  38909. }
  38910. if ($fallback) {
  38911. return $this->ask($output, $question);
  38912. }
  38913. throw new RuntimeException('Unable to hide the response');
  38914. }
  38915. public function askAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $default = null, array $autocomplete = null)
  38916. {
  38917. $that = $this;
  38918. $interviewer = function () use ($output, $question, $default, $autocomplete, $that) {
  38919. return $that->ask($output, $question, $default, $autocomplete);
  38920. };
  38921. return $this->validateAttempts($interviewer, $output, $validator, $attempts);
  38922. }
  38923. public function askHiddenResponseAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $fallback = true)
  38924. {
  38925. $that = $this;
  38926. $interviewer = function () use ($output, $question, $fallback, $that) {
  38927. return $that->askHiddenResponse($output, $question, $fallback);
  38928. };
  38929. return $this->validateAttempts($interviewer, $output, $validator, $attempts);
  38930. }
  38931. public function setInputStream($stream)
  38932. {
  38933. $this->inputStream = $stream;
  38934. }
  38935. public function getInputStream()
  38936. {
  38937. return $this->inputStream;
  38938. }
  38939. public function getName()
  38940. {
  38941. return 'dialog';
  38942. }
  38943. private function getShell()
  38944. {
  38945. if (null !== self::$shell) {
  38946. return self::$shell;
  38947. }
  38948. self::$shell = false;
  38949. if (file_exists('/usr/bin/env')) {
  38950. $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null";
  38951. foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) {
  38952. if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) {
  38953. self::$shell = $sh;
  38954. break;
  38955. }
  38956. }
  38957. }
  38958. return self::$shell;
  38959. }
  38960. private function hasSttyAvailable()
  38961. {
  38962. if (null !== self::$stty) {
  38963. return self::$stty;
  38964. }
  38965. exec('stty 2>&1', $output, $exitcode);
  38966. return self::$stty = 0 === $exitcode;
  38967. }
  38968. private function validateAttempts($interviewer, OutputInterface $output, $validator, $attempts)
  38969. {
  38970. if ($output instanceof ConsoleOutputInterface) {
  38971. $output = $output->getErrorOutput();
  38972. }
  38973. $e = null;
  38974. while (false === $attempts || $attempts--) {
  38975. if (null !== $e) {
  38976. $output->writeln($this->getHelperSet()->get('formatter')->formatBlock($e->getMessage(), 'error'));
  38977. }
  38978. try {
  38979. return \call_user_func($validator, $interviewer());
  38980. } catch (\Exception $e) {
  38981. }
  38982. }
  38983. throw $e;
  38984. }
  38985. }
  38986. <?php
  38987. namespace Symfony\Component\Console\Helper;
  38988. use Symfony\Component\Console\Formatter\OutputFormatter;
  38989. class FormatterHelper extends Helper
  38990. {
  38991. public function formatSection($section, $message, $style = 'info')
  38992. {
  38993. return sprintf('<%s>[%s]</%s> %s', $style, $section, $style, $message);
  38994. }
  38995. public function formatBlock($messages, $style, $large = false)
  38996. {
  38997. if (!\is_array($messages)) {
  38998. $messages = array($messages);
  38999. }
  39000. $len = 0;
  39001. $lines = array();
  39002. foreach ($messages as $message) {
  39003. $message = OutputFormatter::escape($message);
  39004. $lines[] = sprintf($large ? ' %s ' : ' %s ', $message);
  39005. $len = max($this->strlen($message) + ($large ? 4 : 2), $len);
  39006. }
  39007. $messages = $large ? array(str_repeat(' ', $len)) : array();
  39008. for ($i = 0; isset($lines[$i]); ++$i) {
  39009. $messages[] = $lines[$i].str_repeat(' ', $len - $this->strlen($lines[$i]));
  39010. }
  39011. if ($large) {
  39012. $messages[] = str_repeat(' ', $len);
  39013. }
  39014. for ($i = 0; isset($messages[$i]); ++$i) {
  39015. $messages[$i] = sprintf('<%s>%s</%s>', $style, $messages[$i], $style);
  39016. }
  39017. return implode("\n", $messages);
  39018. }
  39019. public function getName()
  39020. {
  39021. return 'formatter';
  39022. }
  39023. }
  39024. <?php
  39025. namespace Symfony\Component\Console\Helper;
  39026. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  39027. abstract class Helper implements HelperInterface
  39028. {
  39029. protected $helperSet = null;
  39030. public function setHelperSet(HelperSet $helperSet = null)
  39031. {
  39032. $this->helperSet = $helperSet;
  39033. }
  39034. public function getHelperSet()
  39035. {
  39036. return $this->helperSet;
  39037. }
  39038. public static function strlen($string)
  39039. {
  39040. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  39041. return \strlen($string);
  39042. }
  39043. return mb_strwidth($string, $encoding);
  39044. }
  39045. public static function formatTime($secs)
  39046. {
  39047. static $timeFormats = array(
  39048. array(0, '< 1 sec'),
  39049. array(1, '1 sec'),
  39050. array(2, 'secs', 1),
  39051. array(60, '1 min'),
  39052. array(120, 'mins', 60),
  39053. array(3600, '1 hr'),
  39054. array(7200, 'hrs', 3600),
  39055. array(86400, '1 day'),
  39056. array(172800, 'days', 86400),
  39057. );
  39058. foreach ($timeFormats as $index => $format) {
  39059. if ($secs >= $format[0]) {
  39060. if ((isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0])
  39061. || $index == \count($timeFormats) - 1
  39062. ) {
  39063. if (2 == \count($format)) {
  39064. return $format[1];
  39065. }
  39066. return floor($secs / $format[2]).' '.$format[1];
  39067. }
  39068. }
  39069. }
  39070. }
  39071. public static function formatMemory($memory)
  39072. {
  39073. if ($memory >= 1024 * 1024 * 1024) {
  39074. return sprintf('%.1f GiB', $memory / 1024 / 1024 / 1024);
  39075. }
  39076. if ($memory >= 1024 * 1024) {
  39077. return sprintf('%.1f MiB', $memory / 1024 / 1024);
  39078. }
  39079. if ($memory >= 1024) {
  39080. return sprintf('%d KiB', $memory / 1024);
  39081. }
  39082. return sprintf('%d B', $memory);
  39083. }
  39084. public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, $string)
  39085. {
  39086. return self::strlen(self::removeDecoration($formatter, $string));
  39087. }
  39088. public static function removeDecoration(OutputFormatterInterface $formatter, $string)
  39089. {
  39090. $isDecorated = $formatter->isDecorated();
  39091. $formatter->setDecorated(false);
  39092. $string = $formatter->format($string);
  39093. $string = preg_replace("/\033\[[^m]*m/", '', $string);
  39094. $formatter->setDecorated($isDecorated);
  39095. return $string;
  39096. }
  39097. }
  39098. <?php
  39099. namespace Symfony\Component\Console\Helper;
  39100. interface HelperInterface
  39101. {
  39102. public function setHelperSet(HelperSet $helperSet = null);
  39103. public function getHelperSet();
  39104. public function getName();
  39105. }
  39106. <?php
  39107. namespace Symfony\Component\Console\Helper;
  39108. use Symfony\Component\Console\Command\Command;
  39109. use Symfony\Component\Console\Exception\InvalidArgumentException;
  39110. class HelperSet implements \IteratorAggregate
  39111. {
  39112. private $helpers = array();
  39113. private $command;
  39114. public function __construct(array $helpers = array())
  39115. {
  39116. foreach ($helpers as $alias => $helper) {
  39117. $this->set($helper, \is_int($alias) ? null : $alias);
  39118. }
  39119. }
  39120. public function set(HelperInterface $helper, $alias = null)
  39121. {
  39122. $this->helpers[$helper->getName()] = $helper;
  39123. if (null !== $alias) {
  39124. $this->helpers[$alias] = $helper;
  39125. }
  39126. $helper->setHelperSet($this);
  39127. }
  39128. public function has($name)
  39129. {
  39130. return isset($this->helpers[$name]);
  39131. }
  39132. public function get($name)
  39133. {
  39134. if (!$this->has($name)) {
  39135. throw new InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
  39136. }
  39137. if ('dialog' === $name && $this->helpers[$name] instanceof DialogHelper) {
  39138. @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);
  39139. } elseif ('progress' === $name && $this->helpers[$name] instanceof ProgressHelper) {
  39140. @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);
  39141. } elseif ('table' === $name && $this->helpers[$name] instanceof TableHelper) {
  39142. @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);
  39143. }
  39144. return $this->helpers[$name];
  39145. }
  39146. public function setCommand(Command $command = null)
  39147. {
  39148. $this->command = $command;
  39149. }
  39150. public function getCommand()
  39151. {
  39152. return $this->command;
  39153. }
  39154. public function getIterator()
  39155. {
  39156. return new \ArrayIterator($this->helpers);
  39157. }
  39158. }
  39159. <?php
  39160. namespace Symfony\Component\Console\Helper;
  39161. use Symfony\Component\Console\Input\InputAwareInterface;
  39162. use Symfony\Component\Console\Input\InputInterface;
  39163. abstract class InputAwareHelper extends Helper implements InputAwareInterface
  39164. {
  39165. protected $input;
  39166. public function setInput(InputInterface $input)
  39167. {
  39168. $this->input = $input;
  39169. }
  39170. }
  39171. <?php
  39172. namespace Symfony\Component\Console\Helper;
  39173. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  39174. use Symfony\Component\Console\Output\OutputInterface;
  39175. use Symfony\Component\Process\Exception\ProcessFailedException;
  39176. use Symfony\Component\Process\Process;
  39177. use Symfony\Component\Process\ProcessBuilder;
  39178. class ProcessHelper extends Helper
  39179. {
  39180. public function run(OutputInterface $output, $cmd, $error = null, $callback = null, $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE)
  39181. {
  39182. if ($output instanceof ConsoleOutputInterface) {
  39183. $output = $output->getErrorOutput();
  39184. }
  39185. $formatter = $this->getHelperSet()->get('debug_formatter');
  39186. if (\is_array($cmd)) {
  39187. $process = ProcessBuilder::create($cmd)->getProcess();
  39188. } elseif ($cmd instanceof Process) {
  39189. $process = $cmd;
  39190. } else {
  39191. $process = new Process($cmd);
  39192. }
  39193. if ($verbosity <= $output->getVerbosity()) {
  39194. $output->write($formatter->start(spl_object_hash($process), $this->escapeString($process->getCommandLine())));
  39195. }
  39196. if ($output->isDebug()) {
  39197. $callback = $this->wrapCallback($output, $process, $callback);
  39198. }
  39199. $process->run($callback);
  39200. if ($verbosity <= $output->getVerbosity()) {
  39201. $message = $process->isSuccessful() ? 'Command ran successfully' : sprintf('%s Command did not run successfully', $process->getExitCode());
  39202. $output->write($formatter->stop(spl_object_hash($process), $message, $process->isSuccessful()));
  39203. }
  39204. if (!$process->isSuccessful() && null !== $error) {
  39205. $output->writeln(sprintf('<error>%s</error>', $this->escapeString($error)));
  39206. }
  39207. return $process;
  39208. }
  39209. public function mustRun(OutputInterface $output, $cmd, $error = null, $callback = null)
  39210. {
  39211. $process = $this->run($output, $cmd, $error, $callback);
  39212. if (!$process->isSuccessful()) {
  39213. throw new ProcessFailedException($process);
  39214. }
  39215. return $process;
  39216. }
  39217. public function wrapCallback(OutputInterface $output, Process $process, $callback = null)
  39218. {
  39219. if ($output instanceof ConsoleOutputInterface) {
  39220. $output = $output->getErrorOutput();
  39221. }
  39222. $formatter = $this->getHelperSet()->get('debug_formatter');
  39223. $that = $this;
  39224. return function ($type, $buffer) use ($output, $process, $callback, $formatter, $that) {
  39225. $output->write($formatter->progress(spl_object_hash($process), $that->escapeString($buffer), Process::ERR === $type));
  39226. if (null !== $callback) {
  39227. \call_user_func($callback, $type, $buffer);
  39228. }
  39229. };
  39230. }
  39231. public function escapeString($str)
  39232. {
  39233. return str_replace('<', '\\<', $str);
  39234. }
  39235. public function getName()
  39236. {
  39237. return 'process';
  39238. }
  39239. }
  39240. <?php
  39241. namespace Symfony\Component\Console\Helper;
  39242. use Symfony\Component\Console\Exception\LogicException;
  39243. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  39244. use Symfony\Component\Console\Output\OutputInterface;
  39245. class ProgressBar
  39246. {
  39247. private $barWidth = 28;
  39248. private $barChar;
  39249. private $emptyBarChar = '-';
  39250. private $progressChar = '>';
  39251. private $format;
  39252. private $internalFormat;
  39253. private $redrawFreq = 1;
  39254. private $output;
  39255. private $step = 0;
  39256. private $max;
  39257. private $startTime;
  39258. private $stepWidth;
  39259. private $percent = 0.0;
  39260. private $formatLineCount;
  39261. private $messages = array();
  39262. private $overwrite = true;
  39263. private $firstRun = true;
  39264. private static $formatters;
  39265. private static $formats;
  39266. public function __construct(OutputInterface $output, $max = 0)
  39267. {
  39268. if ($output instanceof ConsoleOutputInterface) {
  39269. $output = $output->getErrorOutput();
  39270. }
  39271. $this->output = $output;
  39272. $this->setMaxSteps($max);
  39273. if (!$this->output->isDecorated()) {
  39274. $this->overwrite = false;
  39275. $this->setRedrawFrequency($max / 10);
  39276. }
  39277. $this->startTime = time();
  39278. }
  39279. public static function setPlaceholderFormatterDefinition($name, $callable)
  39280. {
  39281. if (!self::$formatters) {
  39282. self::$formatters = self::initPlaceholderFormatters();
  39283. }
  39284. self::$formatters[$name] = $callable;
  39285. }
  39286. public static function getPlaceholderFormatterDefinition($name)
  39287. {
  39288. if (!self::$formatters) {
  39289. self::$formatters = self::initPlaceholderFormatters();
  39290. }
  39291. return isset(self::$formatters[$name]) ? self::$formatters[$name] : null;
  39292. }
  39293. public static function setFormatDefinition($name, $format)
  39294. {
  39295. if (!self::$formats) {
  39296. self::$formats = self::initFormats();
  39297. }
  39298. self::$formats[$name] = $format;
  39299. }
  39300. public static function getFormatDefinition($name)
  39301. {
  39302. if (!self::$formats) {
  39303. self::$formats = self::initFormats();
  39304. }
  39305. return isset(self::$formats[$name]) ? self::$formats[$name] : null;
  39306. }
  39307. public function setMessage($message, $name = 'message')
  39308. {
  39309. $this->messages[$name] = $message;
  39310. }
  39311. public function getMessage($name = 'message')
  39312. {
  39313. return $this->messages[$name];
  39314. }
  39315. public function getStartTime()
  39316. {
  39317. return $this->startTime;
  39318. }
  39319. public function getMaxSteps()
  39320. {
  39321. return $this->max;
  39322. }
  39323. public function getStep()
  39324. {
  39325. @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);
  39326. return $this->getProgress();
  39327. }
  39328. public function getProgress()
  39329. {
  39330. return $this->step;
  39331. }
  39332. public function getStepWidth()
  39333. {
  39334. return $this->stepWidth;
  39335. }
  39336. public function getProgressPercent()
  39337. {
  39338. return $this->percent;
  39339. }
  39340. public function setBarWidth($size)
  39341. {
  39342. $this->barWidth = (int) $size;
  39343. }
  39344. public function getBarWidth()
  39345. {
  39346. return $this->barWidth;
  39347. }
  39348. public function setBarCharacter($char)
  39349. {
  39350. $this->barChar = $char;
  39351. }
  39352. public function getBarCharacter()
  39353. {
  39354. if (null === $this->barChar) {
  39355. return $this->max ? '=' : $this->emptyBarChar;
  39356. }
  39357. return $this->barChar;
  39358. }
  39359. public function setEmptyBarCharacter($char)
  39360. {
  39361. $this->emptyBarChar = $char;
  39362. }
  39363. public function getEmptyBarCharacter()
  39364. {
  39365. return $this->emptyBarChar;
  39366. }
  39367. public function setProgressCharacter($char)
  39368. {
  39369. $this->progressChar = $char;
  39370. }
  39371. public function getProgressCharacter()
  39372. {
  39373. return $this->progressChar;
  39374. }
  39375. public function setFormat($format)
  39376. {
  39377. $this->format = null;
  39378. $this->internalFormat = $format;
  39379. }
  39380. public function setRedrawFrequency($freq)
  39381. {
  39382. $this->redrawFreq = max((int) $freq, 1);
  39383. }
  39384. public function start($max = null)
  39385. {
  39386. $this->startTime = time();
  39387. $this->step = 0;
  39388. $this->percent = 0.0;
  39389. if (null !== $max) {
  39390. $this->setMaxSteps($max);
  39391. }
  39392. $this->display();
  39393. }
  39394. public function advance($step = 1)
  39395. {
  39396. $this->setProgress($this->step + $step);
  39397. }
  39398. public function setCurrent($step)
  39399. {
  39400. @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);
  39401. $this->setProgress($step);
  39402. }
  39403. public function setOverwrite($overwrite)
  39404. {
  39405. $this->overwrite = (bool) $overwrite;
  39406. }
  39407. public function setProgress($step)
  39408. {
  39409. $step = (int) $step;
  39410. if ($step < $this->step) {
  39411. throw new LogicException('You can\'t regress the progress bar.');
  39412. }
  39413. if ($this->max && $step > $this->max) {
  39414. $this->max = $step;
  39415. }
  39416. $prevPeriod = (int) ($this->step / $this->redrawFreq);
  39417. $currPeriod = (int) ($step / $this->redrawFreq);
  39418. $this->step = $step;
  39419. $this->percent = $this->max ? (float) $this->step / $this->max : 0;
  39420. if ($prevPeriod !== $currPeriod || $this->max === $step) {
  39421. $this->display();
  39422. }
  39423. }
  39424. public function finish()
  39425. {
  39426. if (!$this->max) {
  39427. $this->max = $this->step;
  39428. }
  39429. if ($this->step === $this->max && !$this->overwrite) {
  39430. return;
  39431. }
  39432. $this->setProgress($this->max);
  39433. }
  39434. public function display()
  39435. {
  39436. if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
  39437. return;
  39438. }
  39439. if (null === $this->format) {
  39440. $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
  39441. }
  39442. $self = $this;
  39443. $output = $this->output;
  39444. $messages = $this->messages;
  39445. $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self, $output, $messages) {
  39446. if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) {
  39447. $text = \call_user_func($formatter, $self, $output);
  39448. } elseif (isset($messages[$matches[1]])) {
  39449. $text = $messages[$matches[1]];
  39450. } else {
  39451. return $matches[0];
  39452. }
  39453. if (isset($matches[2])) {
  39454. $text = sprintf('%'.$matches[2], $text);
  39455. }
  39456. return $text;
  39457. }, $this->format));
  39458. }
  39459. public function clear()
  39460. {
  39461. if (!$this->overwrite) {
  39462. return;
  39463. }
  39464. if (null === $this->format) {
  39465. $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
  39466. }
  39467. $this->overwrite('');
  39468. }
  39469. private function setRealFormat($format)
  39470. {
  39471. if (!$this->max && null !== self::getFormatDefinition($format.'_nomax')) {
  39472. $this->format = self::getFormatDefinition($format.'_nomax');
  39473. } elseif (null !== self::getFormatDefinition($format)) {
  39474. $this->format = self::getFormatDefinition($format);
  39475. } else {
  39476. $this->format = $format;
  39477. }
  39478. $this->formatLineCount = substr_count($this->format, "\n");
  39479. }
  39480. private function setMaxSteps($max)
  39481. {
  39482. $this->max = max(0, (int) $max);
  39483. $this->stepWidth = $this->max ? Helper::strlen($this->max) : 4;
  39484. }
  39485. private function overwrite($message)
  39486. {
  39487. if ($this->overwrite) {
  39488. if (!$this->firstRun) {
  39489. $this->output->write("\x0D");
  39490. $this->output->write("\x1B[2K");
  39491. if ($this->formatLineCount > 0) {
  39492. $this->output->write(str_repeat("\x1B[1A\x1B[2K", $this->formatLineCount));
  39493. }
  39494. }
  39495. } elseif ($this->step > 0) {
  39496. $this->output->writeln('');
  39497. }
  39498. $this->firstRun = false;
  39499. $this->output->write($message);
  39500. }
  39501. private function determineBestFormat()
  39502. {
  39503. switch ($this->output->getVerbosity()) {
  39504. case OutputInterface::VERBOSITY_VERBOSE:
  39505. return $this->max ? 'verbose' : 'verbose_nomax';
  39506. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  39507. return $this->max ? 'very_verbose' : 'very_verbose_nomax';
  39508. case OutputInterface::VERBOSITY_DEBUG:
  39509. return $this->max ? 'debug' : 'debug_nomax';
  39510. default:
  39511. return $this->max ? 'normal' : 'normal_nomax';
  39512. }
  39513. }
  39514. private static function initPlaceholderFormatters()
  39515. {
  39516. return array(
  39517. 'bar' => function (ProgressBar $bar, OutputInterface $output) {
  39518. $completeBars = floor($bar->getMaxSteps() > 0 ? $bar->getProgressPercent() * $bar->getBarWidth() : $bar->getProgress() % $bar->getBarWidth());
  39519. $display = str_repeat($bar->getBarCharacter(), $completeBars);
  39520. if ($completeBars < $bar->getBarWidth()) {
  39521. $emptyBars = $bar->getBarWidth() - $completeBars - Helper::strlenWithoutDecoration($output->getFormatter(), $bar->getProgressCharacter());
  39522. $display .= $bar->getProgressCharacter().str_repeat($bar->getEmptyBarCharacter(), $emptyBars);
  39523. }
  39524. return $display;
  39525. },
  39526. 'elapsed' => function (ProgressBar $bar) {
  39527. return Helper::formatTime(time() - $bar->getStartTime());
  39528. },
  39529. 'remaining' => function (ProgressBar $bar) {
  39530. if (!$bar->getMaxSteps()) {
  39531. throw new LogicException('Unable to display the remaining time if the maximum number of steps is not set.');
  39532. }
  39533. if (!$bar->getProgress()) {
  39534. $remaining = 0;
  39535. } else {
  39536. $remaining = round((time() - $bar->getStartTime()) / $bar->getProgress() * ($bar->getMaxSteps() - $bar->getProgress()));
  39537. }
  39538. return Helper::formatTime($remaining);
  39539. },
  39540. 'estimated' => function (ProgressBar $bar) {
  39541. if (!$bar->getMaxSteps()) {
  39542. throw new LogicException('Unable to display the estimated time if the maximum number of steps is not set.');
  39543. }
  39544. if (!$bar->getProgress()) {
  39545. $estimated = 0;
  39546. } else {
  39547. $estimated = round((time() - $bar->getStartTime()) / $bar->getProgress() * $bar->getMaxSteps());
  39548. }
  39549. return Helper::formatTime($estimated);
  39550. },
  39551. 'memory' => function (ProgressBar $bar) {
  39552. return Helper::formatMemory(memory_get_usage(true));
  39553. },
  39554. 'current' => function (ProgressBar $bar) {
  39555. return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', STR_PAD_LEFT);
  39556. },
  39557. 'max' => function (ProgressBar $bar) {
  39558. return $bar->getMaxSteps();
  39559. },
  39560. 'percent' => function (ProgressBar $bar) {
  39561. return floor($bar->getProgressPercent() * 100);
  39562. },
  39563. );
  39564. }
  39565. private static function initFormats()
  39566. {
  39567. return array(
  39568. 'normal' => ' %current%/%max% [%bar%] %percent:3s%%',
  39569. 'normal_nomax' => ' %current% [%bar%]',
  39570. 'verbose' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%',
  39571. 'verbose_nomax' => ' %current% [%bar%] %elapsed:6s%',
  39572. 'very_verbose' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%',
  39573. 'very_verbose_nomax' => ' %current% [%bar%] %elapsed:6s%',
  39574. 'debug' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%',
  39575. 'debug_nomax' => ' %current% [%bar%] %elapsed:6s% %memory:6s%',
  39576. );
  39577. }
  39578. }
  39579. <?php
  39580. namespace Symfony\Component\Console\Helper;
  39581. use Symfony\Component\Console\Exception\LogicException;
  39582. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  39583. use Symfony\Component\Console\Output\NullOutput;
  39584. use Symfony\Component\Console\Output\OutputInterface;
  39585. class ProgressHelper extends Helper
  39586. {
  39587. const FORMAT_QUIET = ' %percent%%';
  39588. const FORMAT_NORMAL = ' %current%/%max% [%bar%] %percent%%';
  39589. const FORMAT_VERBOSE = ' %current%/%max% [%bar%] %percent%% Elapsed: %elapsed%';
  39590. const FORMAT_QUIET_NOMAX = ' %current%';
  39591. const FORMAT_NORMAL_NOMAX = ' %current% [%bar%]';
  39592. const FORMAT_VERBOSE_NOMAX = ' %current% [%bar%] Elapsed: %elapsed%';
  39593. private $barWidth = 28;
  39594. private $barChar = '=';
  39595. private $emptyBarChar = '-';
  39596. private $progressChar = '>';
  39597. private $format = null;
  39598. private $redrawFreq = 1;
  39599. private $lastMessagesLength;
  39600. private $barCharOriginal;
  39601. private $output;
  39602. private $current;
  39603. private $max;
  39604. private $startTime;
  39605. private $defaultFormatVars = array(
  39606. 'current',
  39607. 'max',
  39608. 'bar',
  39609. 'percent',
  39610. 'elapsed',
  39611. );
  39612. private $formatVars;
  39613. private $widths = array(
  39614. 'current' => 4,
  39615. 'max' => 4,
  39616. 'percent' => 3,
  39617. 'elapsed' => 6,
  39618. );
  39619. private $timeFormats = array(
  39620. array(0, '???'),
  39621. array(2, '1 sec'),
  39622. array(59, 'secs', 1),
  39623. array(60, '1 min'),
  39624. array(3600, 'mins', 60),
  39625. array(5400, '1 hr'),
  39626. array(86400, 'hrs', 3600),
  39627. array(129600, '1 day'),
  39628. array(604800, 'days', 86400),
  39629. );
  39630. public function __construct($triggerDeprecationError = true)
  39631. {
  39632. if ($triggerDeprecationError) {
  39633. @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);
  39634. }
  39635. }
  39636. public function setBarWidth($size)
  39637. {
  39638. $this->barWidth = (int) $size;
  39639. }
  39640. public function setBarCharacter($char)
  39641. {
  39642. $this->barChar = $char;
  39643. }
  39644. public function setEmptyBarCharacter($char)
  39645. {
  39646. $this->emptyBarChar = $char;
  39647. }
  39648. public function setProgressCharacter($char)
  39649. {
  39650. $this->progressChar = $char;
  39651. }
  39652. public function setFormat($format)
  39653. {
  39654. $this->format = $format;
  39655. }
  39656. public function setRedrawFrequency($freq)
  39657. {
  39658. $this->redrawFreq = (int) $freq;
  39659. }
  39660. public function start(OutputInterface $output, $max = null)
  39661. {
  39662. if ($output instanceof ConsoleOutputInterface) {
  39663. $output = $output->getErrorOutput();
  39664. }
  39665. $this->startTime = time();
  39666. $this->current = 0;
  39667. $this->max = (int) $max;
  39668. $this->output = $output->isDecorated() ? $output : new NullOutput();
  39669. $this->lastMessagesLength = 0;
  39670. $this->barCharOriginal = '';
  39671. if (null === $this->format) {
  39672. switch ($output->getVerbosity()) {
  39673. case OutputInterface::VERBOSITY_QUIET:
  39674. $this->format = self::FORMAT_QUIET_NOMAX;
  39675. if ($this->max > 0) {
  39676. $this->format = self::FORMAT_QUIET;
  39677. }
  39678. break;
  39679. case OutputInterface::VERBOSITY_VERBOSE:
  39680. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  39681. case OutputInterface::VERBOSITY_DEBUG:
  39682. $this->format = self::FORMAT_VERBOSE_NOMAX;
  39683. if ($this->max > 0) {
  39684. $this->format = self::FORMAT_VERBOSE;
  39685. }
  39686. break;
  39687. default:
  39688. $this->format = self::FORMAT_NORMAL_NOMAX;
  39689. if ($this->max > 0) {
  39690. $this->format = self::FORMAT_NORMAL;
  39691. }
  39692. break;
  39693. }
  39694. }
  39695. $this->initialize();
  39696. }
  39697. public function advance($step = 1, $redraw = false)
  39698. {
  39699. $this->setCurrent($this->current + $step, $redraw);
  39700. }
  39701. public function setCurrent($current, $redraw = false)
  39702. {
  39703. if (null === $this->startTime) {
  39704. throw new LogicException('You must start the progress bar before calling setCurrent().');
  39705. }
  39706. $current = (int) $current;
  39707. if ($current < $this->current) {
  39708. throw new LogicException('You can\'t regress the progress bar');
  39709. }
  39710. if (0 === $this->current) {
  39711. $redraw = true;
  39712. }
  39713. $prevPeriod = (int) ($this->current / $this->redrawFreq);
  39714. $this->current = $current;
  39715. $currPeriod = (int) ($this->current / $this->redrawFreq);
  39716. if ($redraw || $prevPeriod !== $currPeriod || $this->max === $this->current) {
  39717. $this->display();
  39718. }
  39719. }
  39720. public function display($finish = false)
  39721. {
  39722. if (null === $this->startTime) {
  39723. throw new LogicException('You must start the progress bar before calling display().');
  39724. }
  39725. $message = $this->format;
  39726. foreach ($this->generate($finish) as $name => $value) {
  39727. $message = str_replace("%{$name}%", $value, $message);
  39728. }
  39729. $this->overwrite($this->output, $message);
  39730. }
  39731. public function clear()
  39732. {
  39733. $this->overwrite($this->output, '');
  39734. }
  39735. public function finish()
  39736. {
  39737. if (null === $this->startTime) {
  39738. throw new LogicException('You must start the progress bar before calling finish().');
  39739. }
  39740. if (null !== $this->startTime) {
  39741. if (!$this->max) {
  39742. $this->barChar = $this->barCharOriginal;
  39743. $this->display(true);
  39744. }
  39745. $this->startTime = null;
  39746. $this->output->writeln('');
  39747. $this->output = null;
  39748. }
  39749. }
  39750. private function initialize()
  39751. {
  39752. $this->formatVars = array();
  39753. foreach ($this->defaultFormatVars as $var) {
  39754. if (false !== strpos($this->format, "%{$var}%")) {
  39755. $this->formatVars[$var] = true;
  39756. }
  39757. }
  39758. if ($this->max > 0) {
  39759. $this->widths['max'] = $this->strlen($this->max);
  39760. $this->widths['current'] = $this->widths['max'];
  39761. } else {
  39762. $this->barCharOriginal = $this->barChar;
  39763. $this->barChar = $this->emptyBarChar;
  39764. }
  39765. }
  39766. private function generate($finish = false)
  39767. {
  39768. $vars = array();
  39769. $percent = 0;
  39770. if ($this->max > 0) {
  39771. $percent = (float) $this->current / $this->max;
  39772. }
  39773. if (isset($this->formatVars['bar'])) {
  39774. if ($this->max > 0) {
  39775. $completeBars = floor($percent * $this->barWidth);
  39776. } else {
  39777. if (!$finish) {
  39778. $completeBars = floor($this->current % $this->barWidth);
  39779. } else {
  39780. $completeBars = $this->barWidth;
  39781. }
  39782. }
  39783. $emptyBars = $this->barWidth - $completeBars - $this->strlen($this->progressChar);
  39784. $bar = str_repeat($this->barChar, $completeBars);
  39785. if ($completeBars < $this->barWidth) {
  39786. $bar .= $this->progressChar;
  39787. $bar .= str_repeat($this->emptyBarChar, $emptyBars);
  39788. }
  39789. $vars['bar'] = $bar;
  39790. }
  39791. if (isset($this->formatVars['elapsed'])) {
  39792. $elapsed = time() - $this->startTime;
  39793. $vars['elapsed'] = str_pad($this->humaneTime($elapsed), $this->widths['elapsed'], ' ', STR_PAD_LEFT);
  39794. }
  39795. if (isset($this->formatVars['current'])) {
  39796. $vars['current'] = str_pad($this->current, $this->widths['current'], ' ', STR_PAD_LEFT);
  39797. }
  39798. if (isset($this->formatVars['max'])) {
  39799. $vars['max'] = $this->max;
  39800. }
  39801. if (isset($this->formatVars['percent'])) {
  39802. $vars['percent'] = str_pad(floor($percent * 100), $this->widths['percent'], ' ', STR_PAD_LEFT);
  39803. }
  39804. return $vars;
  39805. }
  39806. private function humaneTime($secs)
  39807. {
  39808. $text = '';
  39809. foreach ($this->timeFormats as $format) {
  39810. if ($secs < $format[0]) {
  39811. if (2 == \count($format)) {
  39812. $text = $format[1];
  39813. break;
  39814. } else {
  39815. $text = ceil($secs / $format[2]).' '.$format[1];
  39816. break;
  39817. }
  39818. }
  39819. }
  39820. return $text;
  39821. }
  39822. private function overwrite(OutputInterface $output, $message)
  39823. {
  39824. $length = $this->strlen($message);
  39825. if (null !== $this->lastMessagesLength && $this->lastMessagesLength > $length) {
  39826. $message = str_pad($message, $this->lastMessagesLength, "\x20", STR_PAD_RIGHT);
  39827. }
  39828. $output->write("\x0D");
  39829. $output->write($message);
  39830. $this->lastMessagesLength = $this->strlen($message);
  39831. }
  39832. public function getName()
  39833. {
  39834. return 'progress';
  39835. }
  39836. }
  39837. <?php
  39838. namespace Symfony\Component\Console\Helper;
  39839. use Symfony\Component\Console\Exception\InvalidArgumentException;
  39840. use Symfony\Component\Console\Exception\LogicException;
  39841. use Symfony\Component\Console\Output\OutputInterface;
  39842. class ProgressIndicator
  39843. {
  39844. private $output;
  39845. private $startTime;
  39846. private $format;
  39847. private $message;
  39848. private $indicatorValues;
  39849. private $indicatorCurrent;
  39850. private $indicatorChangeInterval;
  39851. private $indicatorUpdateTime;
  39852. private $started = false;
  39853. private static $formatters;
  39854. private static $formats;
  39855. public function __construct(OutputInterface $output, $format = null, $indicatorChangeInterval = 100, $indicatorValues = null)
  39856. {
  39857. $this->output = $output;
  39858. if (null === $format) {
  39859. $format = $this->determineBestFormat();
  39860. }
  39861. if (null === $indicatorValues) {
  39862. $indicatorValues = array('-', '\\', '|', '/');
  39863. }
  39864. $indicatorValues = array_values($indicatorValues);
  39865. if (2 > \count($indicatorValues)) {
  39866. throw new InvalidArgumentException('Must have at least 2 indicator value characters.');
  39867. }
  39868. $this->format = self::getFormatDefinition($format);
  39869. $this->indicatorChangeInterval = $indicatorChangeInterval;
  39870. $this->indicatorValues = $indicatorValues;
  39871. $this->startTime = time();
  39872. }
  39873. public function setMessage($message)
  39874. {
  39875. $this->message = $message;
  39876. $this->display();
  39877. }
  39878. public function getMessage()
  39879. {
  39880. return $this->message;
  39881. }
  39882. public function getStartTime()
  39883. {
  39884. return $this->startTime;
  39885. }
  39886. public function getCurrentValue()
  39887. {
  39888. return $this->indicatorValues[$this->indicatorCurrent % \count($this->indicatorValues)];
  39889. }
  39890. public function start($message)
  39891. {
  39892. if ($this->started) {
  39893. throw new LogicException('Progress indicator already started.');
  39894. }
  39895. $this->message = $message;
  39896. $this->started = true;
  39897. $this->startTime = time();
  39898. $this->indicatorUpdateTime = $this->getCurrentTimeInMilliseconds() + $this->indicatorChangeInterval;
  39899. $this->indicatorCurrent = 0;
  39900. $this->display();
  39901. }
  39902. public function advance()
  39903. {
  39904. if (!$this->started) {
  39905. throw new LogicException('Progress indicator has not yet been started.');
  39906. }
  39907. if (!$this->output->isDecorated()) {
  39908. return;
  39909. }
  39910. $currentTime = $this->getCurrentTimeInMilliseconds();
  39911. if ($currentTime < $this->indicatorUpdateTime) {
  39912. return;
  39913. }
  39914. $this->indicatorUpdateTime = $currentTime + $this->indicatorChangeInterval;
  39915. ++$this->indicatorCurrent;
  39916. $this->display();
  39917. }
  39918. public function finish($message)
  39919. {
  39920. if (!$this->started) {
  39921. throw new LogicException('Progress indicator has not yet been started.');
  39922. }
  39923. $this->message = $message;
  39924. $this->display();
  39925. $this->output->writeln('');
  39926. $this->started = false;
  39927. }
  39928. public static function getFormatDefinition($name)
  39929. {
  39930. if (!self::$formats) {
  39931. self::$formats = self::initFormats();
  39932. }
  39933. return isset(self::$formats[$name]) ? self::$formats[$name] : null;
  39934. }
  39935. public static function setPlaceholderFormatterDefinition($name, $callable)
  39936. {
  39937. if (!self::$formatters) {
  39938. self::$formatters = self::initPlaceholderFormatters();
  39939. }
  39940. self::$formatters[$name] = $callable;
  39941. }
  39942. public static function getPlaceholderFormatterDefinition($name)
  39943. {
  39944. if (!self::$formatters) {
  39945. self::$formatters = self::initPlaceholderFormatters();
  39946. }
  39947. return isset(self::$formatters[$name]) ? self::$formatters[$name] : null;
  39948. }
  39949. private function display()
  39950. {
  39951. if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
  39952. return;
  39953. }
  39954. $self = $this;
  39955. $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self) {
  39956. if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) {
  39957. return \call_user_func($formatter, $self);
  39958. }
  39959. return $matches[0];
  39960. }, $this->format));
  39961. }
  39962. private function determineBestFormat()
  39963. {
  39964. switch ($this->output->getVerbosity()) {
  39965. case OutputInterface::VERBOSITY_VERBOSE:
  39966. return $this->output->isDecorated() ? 'verbose' : 'verbose_no_ansi';
  39967. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  39968. case OutputInterface::VERBOSITY_DEBUG:
  39969. return $this->output->isDecorated() ? 'very_verbose' : 'very_verbose_no_ansi';
  39970. default:
  39971. return $this->output->isDecorated() ? 'normal' : 'normal_no_ansi';
  39972. }
  39973. }
  39974. private function overwrite($message)
  39975. {
  39976. if ($this->output->isDecorated()) {
  39977. $this->output->write("\x0D\x1B[2K");
  39978. $this->output->write($message);
  39979. } else {
  39980. $this->output->writeln($message);
  39981. }
  39982. }
  39983. private function getCurrentTimeInMilliseconds()
  39984. {
  39985. return round(microtime(true) * 1000);
  39986. }
  39987. private static function initPlaceholderFormatters()
  39988. {
  39989. return array(
  39990. 'indicator' => function (ProgressIndicator $indicator) {
  39991. return $indicator->getCurrentValue();
  39992. },
  39993. 'message' => function (ProgressIndicator $indicator) {
  39994. return $indicator->getMessage();
  39995. },
  39996. 'elapsed' => function (ProgressIndicator $indicator) {
  39997. return Helper::formatTime(time() - $indicator->getStartTime());
  39998. },
  39999. 'memory' => function () {
  40000. return Helper::formatMemory(memory_get_usage(true));
  40001. },
  40002. );
  40003. }
  40004. private static function initFormats()
  40005. {
  40006. return array(
  40007. 'normal' => ' %indicator% %message%',
  40008. 'normal_no_ansi' => ' %message%',
  40009. 'verbose' => ' %indicator% %message% (%elapsed:6s%)',
  40010. 'verbose_no_ansi' => ' %message% (%elapsed:6s%)',
  40011. 'very_verbose' => ' %indicator% %message% (%elapsed:6s%, %memory:6s%)',
  40012. 'very_verbose_no_ansi' => ' %message% (%elapsed:6s%, %memory:6s%)',
  40013. );
  40014. }
  40015. }
  40016. <?php
  40017. namespace Symfony\Component\Console\Helper;
  40018. use Symfony\Component\Console\Exception\InvalidArgumentException;
  40019. use Symfony\Component\Console\Exception\RuntimeException;
  40020. use Symfony\Component\Console\Formatter\OutputFormatter;
  40021. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  40022. use Symfony\Component\Console\Input\InputInterface;
  40023. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  40024. use Symfony\Component\Console\Output\OutputInterface;
  40025. use Symfony\Component\Console\Question\ChoiceQuestion;
  40026. use Symfony\Component\Console\Question\Question;
  40027. class QuestionHelper extends Helper
  40028. {
  40029. private $inputStream;
  40030. private static $shell;
  40031. private static $stty;
  40032. public function ask(InputInterface $input, OutputInterface $output, Question $question)
  40033. {
  40034. if ($output instanceof ConsoleOutputInterface) {
  40035. $output = $output->getErrorOutput();
  40036. }
  40037. if (!$input->isInteractive()) {
  40038. $default = $question->getDefault();
  40039. if (null !== $default && $question instanceof ChoiceQuestion) {
  40040. $choices = $question->getChoices();
  40041. if (!$question->isMultiselect()) {
  40042. return isset($choices[$default]) ? $choices[$default] : $default;
  40043. }
  40044. $default = explode(',', $default);
  40045. foreach ($default as $k => $v) {
  40046. $v = trim($v);
  40047. $default[$k] = isset($choices[$v]) ? $choices[$v] : $v;
  40048. }
  40049. }
  40050. return $default;
  40051. }
  40052. if (!$question->getValidator()) {
  40053. return $this->doAsk($output, $question);
  40054. }
  40055. $that = $this;
  40056. $interviewer = function () use ($output, $question, $that) {
  40057. return $that->doAsk($output, $question);
  40058. };
  40059. return $this->validateAttempts($interviewer, $output, $question);
  40060. }
  40061. public function setInputStream($stream)
  40062. {
  40063. if (!\is_resource($stream)) {
  40064. throw new InvalidArgumentException('Input stream must be a valid resource.');
  40065. }
  40066. $this->inputStream = $stream;
  40067. }
  40068. public function getInputStream()
  40069. {
  40070. return $this->inputStream;
  40071. }
  40072. public function getName()
  40073. {
  40074. return 'question';
  40075. }
  40076. public function doAsk(OutputInterface $output, Question $question)
  40077. {
  40078. $this->writePrompt($output, $question);
  40079. $inputStream = $this->inputStream ?: STDIN;
  40080. $autocomplete = $question->getAutocompleterValues();
  40081. if (null === $autocomplete || !$this->hasSttyAvailable()) {
  40082. $ret = false;
  40083. if ($question->isHidden()) {
  40084. try {
  40085. $ret = trim($this->getHiddenResponse($output, $inputStream));
  40086. } catch (RuntimeException $e) {
  40087. if (!$question->isHiddenFallback()) {
  40088. throw $e;
  40089. }
  40090. }
  40091. }
  40092. if (false === $ret) {
  40093. $ret = fgets($inputStream, 4096);
  40094. if (false === $ret) {
  40095. throw new RuntimeException('Aborted');
  40096. }
  40097. $ret = trim($ret);
  40098. }
  40099. } else {
  40100. $ret = trim($this->autocomplete($output, $question, $inputStream, \is_array($autocomplete) ? $autocomplete : iterator_to_array($autocomplete, false)));
  40101. }
  40102. $ret = \strlen($ret) > 0 ? $ret : $question->getDefault();
  40103. if ($normalizer = $question->getNormalizer()) {
  40104. return $normalizer($ret);
  40105. }
  40106. return $ret;
  40107. }
  40108. protected function writePrompt(OutputInterface $output, Question $question)
  40109. {
  40110. $message = $question->getQuestion();
  40111. if ($question instanceof ChoiceQuestion) {
  40112. $maxWidth = max(array_map(array($this, 'strlen'), array_keys($question->getChoices())));
  40113. $messages = (array) $question->getQuestion();
  40114. foreach ($question->getChoices() as $key => $value) {
  40115. $width = $maxWidth - $this->strlen($key);
  40116. $messages[] = ' [<info>'.$key.str_repeat(' ', $width).'</info>] '.$value;
  40117. }
  40118. $output->writeln($messages);
  40119. $message = $question->getPrompt();
  40120. }
  40121. $output->write($message);
  40122. }
  40123. protected function writeError(OutputInterface $output, \Exception $error)
  40124. {
  40125. if (null !== $this->getHelperSet() && $this->getHelperSet()->has('formatter')) {
  40126. $message = $this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error');
  40127. } else {
  40128. $message = '<error>'.$error->getMessage().'</error>';
  40129. }
  40130. $output->writeln($message);
  40131. }
  40132. private function autocomplete(OutputInterface $output, Question $question, $inputStream, array $autocomplete)
  40133. {
  40134. $ret = '';
  40135. $i = 0;
  40136. $ofs = -1;
  40137. $matches = $autocomplete;
  40138. $numMatches = \count($matches);
  40139. $sttyMode = shell_exec('stty -g');
  40140. shell_exec('stty -icanon -echo');
  40141. $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
  40142. while (!feof($inputStream)) {
  40143. $c = fread($inputStream, 1);
  40144. if ("\177" === $c) {
  40145. if (0 === $numMatches && 0 !== $i) {
  40146. --$i;
  40147. $output->write("\033[1D");
  40148. }
  40149. if (0 === $i) {
  40150. $ofs = -1;
  40151. $matches = $autocomplete;
  40152. $numMatches = \count($matches);
  40153. } else {
  40154. $numMatches = 0;
  40155. }
  40156. $ret = substr($ret, 0, $i);
  40157. } elseif ("\033" === $c) {
  40158. $c .= fread($inputStream, 2);
  40159. if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) {
  40160. if ('A' === $c[2] && -1 === $ofs) {
  40161. $ofs = 0;
  40162. }
  40163. if (0 === $numMatches) {
  40164. continue;
  40165. }
  40166. $ofs += ('A' === $c[2]) ? -1 : 1;
  40167. $ofs = ($numMatches + $ofs) % $numMatches;
  40168. }
  40169. } elseif (\ord($c) < 32) {
  40170. if ("\t" === $c || "\n" === $c) {
  40171. if ($numMatches > 0 && -1 !== $ofs) {
  40172. $ret = $matches[$ofs];
  40173. $output->write(substr($ret, $i));
  40174. $i = \strlen($ret);
  40175. }
  40176. if ("\n" === $c) {
  40177. $output->write($c);
  40178. break;
  40179. }
  40180. $numMatches = 0;
  40181. }
  40182. continue;
  40183. } else {
  40184. $output->write($c);
  40185. $ret .= $c;
  40186. ++$i;
  40187. $numMatches = 0;
  40188. $ofs = 0;
  40189. foreach ($autocomplete as $value) {
  40190. if (0 === strpos($value, $ret)) {
  40191. $matches[$numMatches++] = $value;
  40192. }
  40193. }
  40194. }
  40195. $output->write("\033[K");
  40196. if ($numMatches > 0 && -1 !== $ofs) {
  40197. $output->write("\0337");
  40198. $output->write('<hl>'.OutputFormatter::escapeTrailingBackslash(substr($matches[$ofs], $i)).'</hl>');
  40199. $output->write("\0338");
  40200. }
  40201. }
  40202. shell_exec(sprintf('stty %s', $sttyMode));
  40203. return $ret;
  40204. }
  40205. private function getHiddenResponse(OutputInterface $output, $inputStream)
  40206. {
  40207. if ('\\' === \DIRECTORY_SEPARATOR) {
  40208. $exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
  40209. if ('phar:' === substr(__FILE__, 0, 5)) {
  40210. $tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
  40211. copy($exe, $tmpExe);
  40212. $exe = $tmpExe;
  40213. }
  40214. $value = rtrim(shell_exec($exe));
  40215. $output->writeln('');
  40216. if (isset($tmpExe)) {
  40217. unlink($tmpExe);
  40218. }
  40219. return $value;
  40220. }
  40221. if ($this->hasSttyAvailable()) {
  40222. $sttyMode = shell_exec('stty -g');
  40223. shell_exec('stty -echo');
  40224. $value = fgets($inputStream, 4096);
  40225. shell_exec(sprintf('stty %s', $sttyMode));
  40226. if (false === $value) {
  40227. throw new RuntimeException('Aborted');
  40228. }
  40229. $value = trim($value);
  40230. $output->writeln('');
  40231. return $value;
  40232. }
  40233. if (false !== $shell = $this->getShell()) {
  40234. $readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword';
  40235. $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
  40236. $value = rtrim(shell_exec($command));
  40237. $output->writeln('');
  40238. return $value;
  40239. }
  40240. throw new RuntimeException('Unable to hide the response.');
  40241. }
  40242. private function validateAttempts($interviewer, OutputInterface $output, Question $question)
  40243. {
  40244. $error = null;
  40245. $attempts = $question->getMaxAttempts();
  40246. while (null === $attempts || $attempts--) {
  40247. if (null !== $error) {
  40248. $this->writeError($output, $error);
  40249. }
  40250. try {
  40251. return \call_user_func($question->getValidator(), $interviewer());
  40252. } catch (RuntimeException $e) {
  40253. throw $e;
  40254. } catch (\Exception $error) {
  40255. }
  40256. }
  40257. throw $error;
  40258. }
  40259. private function getShell()
  40260. {
  40261. if (null !== self::$shell) {
  40262. return self::$shell;
  40263. }
  40264. self::$shell = false;
  40265. if (file_exists('/usr/bin/env')) {
  40266. $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null";
  40267. foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) {
  40268. if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) {
  40269. self::$shell = $sh;
  40270. break;
  40271. }
  40272. }
  40273. }
  40274. return self::$shell;
  40275. }
  40276. private function hasSttyAvailable()
  40277. {
  40278. if (null !== self::$stty) {
  40279. return self::$stty;
  40280. }
  40281. exec('stty 2>&1', $output, $exitcode);
  40282. return self::$stty = 0 === $exitcode;
  40283. }
  40284. }
  40285. <?php
  40286. namespace Symfony\Component\Console\Helper;
  40287. use Symfony\Component\Console\Exception\LogicException;
  40288. use Symfony\Component\Console\Formatter\OutputFormatter;
  40289. use Symfony\Component\Console\Input\InputInterface;
  40290. use Symfony\Component\Console\Output\OutputInterface;
  40291. use Symfony\Component\Console\Question\ChoiceQuestion;
  40292. use Symfony\Component\Console\Question\ConfirmationQuestion;
  40293. use Symfony\Component\Console\Question\Question;
  40294. use Symfony\Component\Console\Style\SymfonyStyle;
  40295. class SymfonyQuestionHelper extends QuestionHelper
  40296. {
  40297. public function ask(InputInterface $input, OutputInterface $output, Question $question)
  40298. {
  40299. $validator = $question->getValidator();
  40300. $question->setValidator(function ($value) use ($validator) {
  40301. if (null !== $validator) {
  40302. $value = $validator($value);
  40303. } else {
  40304. if (!\is_array($value) && !\is_bool($value) && 0 === \strlen($value)) {
  40305. throw new LogicException('A value is required.');
  40306. }
  40307. }
  40308. return $value;
  40309. });
  40310. return parent::ask($input, $output, $question);
  40311. }
  40312. protected function writePrompt(OutputInterface $output, Question $question)
  40313. {
  40314. $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion());
  40315. $default = $question->getDefault();
  40316. switch (true) {
  40317. case null === $default:
  40318. $text = sprintf(' <info>%s</info>:', $text);
  40319. break;
  40320. case $question instanceof ConfirmationQuestion:
  40321. $text = sprintf(' <info>%s (yes/no)</info> [<comment>%s</comment>]:', $text, $default ? 'yes' : 'no');
  40322. break;
  40323. case $question instanceof ChoiceQuestion && $question->isMultiselect():
  40324. $choices = $question->getChoices();
  40325. $default = explode(',', $default);
  40326. foreach ($default as $key => $value) {
  40327. $default[$key] = $choices[trim($value)];
  40328. }
  40329. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(implode(', ', $default)));
  40330. break;
  40331. case $question instanceof ChoiceQuestion:
  40332. $choices = $question->getChoices();
  40333. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(isset($choices[$default]) ? $choices[$default] : $default));
  40334. break;
  40335. default:
  40336. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($default));
  40337. }
  40338. $output->writeln($text);
  40339. if ($question instanceof ChoiceQuestion) {
  40340. $width = max(array_map('strlen', array_keys($question->getChoices())));
  40341. foreach ($question->getChoices() as $key => $value) {
  40342. $output->writeln(sprintf(" [<comment>%-${width}s</comment>] %s", $key, $value));
  40343. }
  40344. }
  40345. $output->write(' > ');
  40346. }
  40347. protected function writeError(OutputInterface $output, \Exception $error)
  40348. {
  40349. if ($output instanceof SymfonyStyle) {
  40350. $output->newLine();
  40351. $output->error($error->getMessage());
  40352. return;
  40353. }
  40354. parent::writeError($output, $error);
  40355. }
  40356. }
  40357. <?php
  40358. namespace Symfony\Component\Console\Helper;
  40359. use Symfony\Component\Console\Exception\InvalidArgumentException;
  40360. use Symfony\Component\Console\Output\OutputInterface;
  40361. class Table
  40362. {
  40363. private $headers = array();
  40364. private $rows = array();
  40365. private $columnWidths = array();
  40366. private $numberOfColumns;
  40367. private $output;
  40368. private $style;
  40369. private $columnStyles = array();
  40370. private static $styles;
  40371. public function __construct(OutputInterface $output)
  40372. {
  40373. $this->output = $output;
  40374. if (!self::$styles) {
  40375. self::$styles = self::initStyles();
  40376. }
  40377. $this->setStyle('default');
  40378. }
  40379. public static function setStyleDefinition($name, TableStyle $style)
  40380. {
  40381. if (!self::$styles) {
  40382. self::$styles = self::initStyles();
  40383. }
  40384. self::$styles[$name] = $style;
  40385. }
  40386. public static function getStyleDefinition($name)
  40387. {
  40388. if (!self::$styles) {
  40389. self::$styles = self::initStyles();
  40390. }
  40391. if (isset(self::$styles[$name])) {
  40392. return self::$styles[$name];
  40393. }
  40394. throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
  40395. }
  40396. public function setStyle($name)
  40397. {
  40398. $this->style = $this->resolveStyle($name);
  40399. return $this;
  40400. }
  40401. public function getStyle()
  40402. {
  40403. return $this->style;
  40404. }
  40405. public function setColumnStyle($columnIndex, $name)
  40406. {
  40407. $columnIndex = (int) $columnIndex;
  40408. $this->columnStyles[$columnIndex] = $this->resolveStyle($name);
  40409. return $this;
  40410. }
  40411. public function getColumnStyle($columnIndex)
  40412. {
  40413. if (isset($this->columnStyles[$columnIndex])) {
  40414. return $this->columnStyles[$columnIndex];
  40415. }
  40416. return $this->getStyle();
  40417. }
  40418. public function setHeaders(array $headers)
  40419. {
  40420. $headers = array_values($headers);
  40421. if (!empty($headers) && !\is_array($headers[0])) {
  40422. $headers = array($headers);
  40423. }
  40424. $this->headers = $headers;
  40425. return $this;
  40426. }
  40427. public function setRows(array $rows)
  40428. {
  40429. $this->rows = array();
  40430. return $this->addRows($rows);
  40431. }
  40432. public function addRows(array $rows)
  40433. {
  40434. foreach ($rows as $row) {
  40435. $this->addRow($row);
  40436. }
  40437. return $this;
  40438. }
  40439. public function addRow($row)
  40440. {
  40441. if ($row instanceof TableSeparator) {
  40442. $this->rows[] = $row;
  40443. return $this;
  40444. }
  40445. if (!\is_array($row)) {
  40446. throw new InvalidArgumentException('A row must be an array or a TableSeparator instance.');
  40447. }
  40448. $this->rows[] = array_values($row);
  40449. return $this;
  40450. }
  40451. public function setRow($column, array $row)
  40452. {
  40453. $this->rows[$column] = $row;
  40454. return $this;
  40455. }
  40456. public function render()
  40457. {
  40458. $this->calculateNumberOfColumns();
  40459. $rows = $this->buildTableRows($this->rows);
  40460. $headers = $this->buildTableRows($this->headers);
  40461. $this->calculateColumnsWidth(array_merge($headers, $rows));
  40462. $this->renderRowSeparator();
  40463. if (!empty($headers)) {
  40464. foreach ($headers as $header) {
  40465. $this->renderRow($header, $this->style->getCellHeaderFormat());
  40466. $this->renderRowSeparator();
  40467. }
  40468. }
  40469. foreach ($rows as $row) {
  40470. if ($row instanceof TableSeparator) {
  40471. $this->renderRowSeparator();
  40472. } else {
  40473. $this->renderRow($row, $this->style->getCellRowFormat());
  40474. }
  40475. }
  40476. if (!empty($rows)) {
  40477. $this->renderRowSeparator();
  40478. }
  40479. $this->cleanup();
  40480. }
  40481. private function renderRowSeparator()
  40482. {
  40483. if (0 === $count = $this->numberOfColumns) {
  40484. return;
  40485. }
  40486. if (!$this->style->getHorizontalBorderChar() && !$this->style->getCrossingChar()) {
  40487. return;
  40488. }
  40489. $markup = $this->style->getCrossingChar();
  40490. for ($column = 0; $column < $count; ++$column) {
  40491. $markup .= str_repeat($this->style->getHorizontalBorderChar(), $this->columnWidths[$column]).$this->style->getCrossingChar();
  40492. }
  40493. $this->output->writeln(sprintf($this->style->getBorderFormat(), $markup));
  40494. }
  40495. private function renderColumnSeparator()
  40496. {
  40497. return sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar());
  40498. }
  40499. private function renderRow(array $row, $cellFormat)
  40500. {
  40501. if (empty($row)) {
  40502. return;
  40503. }
  40504. $rowContent = $this->renderColumnSeparator();
  40505. foreach ($this->getRowColumns($row) as $column) {
  40506. $rowContent .= $this->renderCell($row, $column, $cellFormat);
  40507. $rowContent .= $this->renderColumnSeparator();
  40508. }
  40509. $this->output->writeln($rowContent);
  40510. }
  40511. private function renderCell(array $row, $column, $cellFormat)
  40512. {
  40513. $cell = isset($row[$column]) ? $row[$column] : '';
  40514. $width = $this->columnWidths[$column];
  40515. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  40516. foreach (range($column + 1, $column + $cell->getColspan() - 1) as $nextColumn) {
  40517. $width += $this->getColumnSeparatorWidth() + $this->columnWidths[$nextColumn];
  40518. }
  40519. }
  40520. if (false !== $encoding = mb_detect_encoding($cell, null, true)) {
  40521. $width += \strlen($cell) - mb_strwidth($cell, $encoding);
  40522. }
  40523. $style = $this->getColumnStyle($column);
  40524. if ($cell instanceof TableSeparator) {
  40525. return sprintf($style->getBorderFormat(), str_repeat($style->getHorizontalBorderChar(), $width));
  40526. }
  40527. $width += Helper::strlen($cell) - Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
  40528. $content = sprintf($style->getCellRowContentFormat(), $cell);
  40529. return sprintf($cellFormat, str_pad($content, $width, $style->getPaddingChar(), $style->getPadType()));
  40530. }
  40531. private function calculateNumberOfColumns()
  40532. {
  40533. if (null !== $this->numberOfColumns) {
  40534. return;
  40535. }
  40536. $columns = array(0);
  40537. foreach (array_merge($this->headers, $this->rows) as $row) {
  40538. if ($row instanceof TableSeparator) {
  40539. continue;
  40540. }
  40541. $columns[] = $this->getNumberOfColumns($row);
  40542. }
  40543. $this->numberOfColumns = max($columns);
  40544. }
  40545. private function buildTableRows($rows)
  40546. {
  40547. $unmergedRows = array();
  40548. for ($rowKey = 0; $rowKey < \count($rows); ++$rowKey) {
  40549. $rows = $this->fillNextRows($rows, $rowKey);
  40550. foreach ($rows[$rowKey] as $column => $cell) {
  40551. if (!strstr($cell, "\n")) {
  40552. continue;
  40553. }
  40554. $lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
  40555. foreach ($lines as $lineKey => $line) {
  40556. if ($cell instanceof TableCell) {
  40557. $line = new TableCell($line, array('colspan' => $cell->getColspan()));
  40558. }
  40559. if (0 === $lineKey) {
  40560. $rows[$rowKey][$column] = $line;
  40561. } else {
  40562. $unmergedRows[$rowKey][$lineKey][$column] = $line;
  40563. }
  40564. }
  40565. }
  40566. }
  40567. $tableRows = array();
  40568. foreach ($rows as $rowKey => $row) {
  40569. $tableRows[] = $this->fillCells($row);
  40570. if (isset($unmergedRows[$rowKey])) {
  40571. $tableRows = array_merge($tableRows, $unmergedRows[$rowKey]);
  40572. }
  40573. }
  40574. return $tableRows;
  40575. }
  40576. private function fillNextRows(array $rows, $line)
  40577. {
  40578. $unmergedRows = array();
  40579. foreach ($rows[$line] as $column => $cell) {
  40580. if ($cell instanceof TableCell && $cell->getRowspan() > 1) {
  40581. $nbLines = $cell->getRowspan() - 1;
  40582. $lines = array($cell);
  40583. if (strstr($cell, "\n")) {
  40584. $lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
  40585. $nbLines = \count($lines) > $nbLines ? substr_count($cell, "\n") : $nbLines;
  40586. $rows[$line][$column] = new TableCell($lines[0], array('colspan' => $cell->getColspan()));
  40587. unset($lines[0]);
  40588. }
  40589. $unmergedRows = array_replace_recursive(array_fill($line + 1, $nbLines, array()), $unmergedRows);
  40590. foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
  40591. $value = isset($lines[$unmergedRowKey - $line]) ? $lines[$unmergedRowKey - $line] : '';
  40592. $unmergedRows[$unmergedRowKey][$column] = new TableCell($value, array('colspan' => $cell->getColspan()));
  40593. if ($nbLines === $unmergedRowKey - $line) {
  40594. break;
  40595. }
  40596. }
  40597. }
  40598. }
  40599. foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
  40600. if (isset($rows[$unmergedRowKey]) && \is_array($rows[$unmergedRowKey]) && ($this->getNumberOfColumns($rows[$unmergedRowKey]) + $this->getNumberOfColumns($unmergedRows[$unmergedRowKey]) <= $this->numberOfColumns)) {
  40601. foreach ($unmergedRow as $cellKey => $cell) {
  40602. array_splice($rows[$unmergedRowKey], $cellKey, 0, array($cell));
  40603. }
  40604. } else {
  40605. $row = $this->copyRow($rows, $unmergedRowKey - 1);
  40606. foreach ($unmergedRow as $column => $cell) {
  40607. if (!empty($cell)) {
  40608. $row[$column] = $unmergedRow[$column];
  40609. }
  40610. }
  40611. array_splice($rows, $unmergedRowKey, 0, array($row));
  40612. }
  40613. }
  40614. return $rows;
  40615. }
  40616. private function fillCells($row)
  40617. {
  40618. $newRow = array();
  40619. foreach ($row as $column => $cell) {
  40620. $newRow[] = $cell;
  40621. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  40622. foreach (range($column + 1, $column + $cell->getColspan() - 1) as $position) {
  40623. $newRow[] = '';
  40624. }
  40625. }
  40626. }
  40627. return $newRow ?: $row;
  40628. }
  40629. private function copyRow(array $rows, $line)
  40630. {
  40631. $row = $rows[$line];
  40632. foreach ($row as $cellKey => $cellValue) {
  40633. $row[$cellKey] = '';
  40634. if ($cellValue instanceof TableCell) {
  40635. $row[$cellKey] = new TableCell('', array('colspan' => $cellValue->getColspan()));
  40636. }
  40637. }
  40638. return $row;
  40639. }
  40640. private function getNumberOfColumns(array $row)
  40641. {
  40642. $columns = \count($row);
  40643. foreach ($row as $column) {
  40644. $columns += $column instanceof TableCell ? ($column->getColspan() - 1) : 0;
  40645. }
  40646. return $columns;
  40647. }
  40648. private function getRowColumns(array $row)
  40649. {
  40650. $columns = range(0, $this->numberOfColumns - 1);
  40651. foreach ($row as $cellKey => $cell) {
  40652. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  40653. $columns = array_diff($columns, range($cellKey + 1, $cellKey + $cell->getColspan() - 1));
  40654. }
  40655. }
  40656. return $columns;
  40657. }
  40658. private function calculateColumnsWidth($rows)
  40659. {
  40660. for ($column = 0; $column < $this->numberOfColumns; ++$column) {
  40661. $lengths = array();
  40662. foreach ($rows as $row) {
  40663. if ($row instanceof TableSeparator) {
  40664. continue;
  40665. }
  40666. foreach ($row as $i => $cell) {
  40667. if ($cell instanceof TableCell) {
  40668. $textContent = Helper::removeDecoration($this->output->getFormatter(), $cell);
  40669. $textLength = Helper::strlen($textContent);
  40670. if ($textLength > 0) {
  40671. $contentColumns = str_split($textContent, ceil($textLength / $cell->getColspan()));
  40672. foreach ($contentColumns as $position => $content) {
  40673. $row[$i + $position] = $content;
  40674. }
  40675. }
  40676. }
  40677. }
  40678. $lengths[] = $this->getCellWidth($row, $column);
  40679. }
  40680. $this->columnWidths[$column] = max($lengths) + Helper::strlen($this->style->getCellRowContentFormat()) - 2;
  40681. }
  40682. }
  40683. private function getColumnSeparatorWidth()
  40684. {
  40685. return Helper::strlen(sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar()));
  40686. }
  40687. private function getCellWidth(array $row, $column)
  40688. {
  40689. if (isset($row[$column])) {
  40690. $cell = $row[$column];
  40691. $cellWidth = Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
  40692. return $cellWidth;
  40693. }
  40694. return 0;
  40695. }
  40696. private function cleanup()
  40697. {
  40698. $this->columnWidths = array();
  40699. $this->numberOfColumns = null;
  40700. }
  40701. private static function initStyles()
  40702. {
  40703. $borderless = new TableStyle();
  40704. $borderless
  40705. ->setHorizontalBorderChar('=')
  40706. ->setVerticalBorderChar(' ')
  40707. ->setCrossingChar(' ')
  40708. ;
  40709. $compact = new TableStyle();
  40710. $compact
  40711. ->setHorizontalBorderChar('')
  40712. ->setVerticalBorderChar(' ')
  40713. ->setCrossingChar('')
  40714. ->setCellRowContentFormat('%s')
  40715. ;
  40716. $styleGuide = new TableStyle();
  40717. $styleGuide
  40718. ->setHorizontalBorderChar('-')
  40719. ->setVerticalBorderChar(' ')
  40720. ->setCrossingChar(' ')
  40721. ->setCellHeaderFormat('%s')
  40722. ;
  40723. return array(
  40724. 'default' => new TableStyle(),
  40725. 'borderless' => $borderless,
  40726. 'compact' => $compact,
  40727. 'symfony-style-guide' => $styleGuide,
  40728. );
  40729. }
  40730. private function resolveStyle($name)
  40731. {
  40732. if ($name instanceof TableStyle) {
  40733. return $name;
  40734. }
  40735. if (isset(self::$styles[$name])) {
  40736. return self::$styles[$name];
  40737. }
  40738. throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
  40739. }
  40740. }
  40741. <?php
  40742. namespace Symfony\Component\Console\Helper;
  40743. use Symfony\Component\Console\Exception\InvalidArgumentException;
  40744. class TableCell
  40745. {
  40746. private $value;
  40747. private $options = array(
  40748. 'rowspan' => 1,
  40749. 'colspan' => 1,
  40750. );
  40751. public function __construct($value = '', array $options = array())
  40752. {
  40753. if (is_numeric($value) && !\is_string($value)) {
  40754. $value = (string) $value;
  40755. }
  40756. $this->value = $value;
  40757. if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
  40758. throw new InvalidArgumentException(sprintf('The TableCell does not support the following options: \'%s\'.', implode('\', \'', $diff)));
  40759. }
  40760. $this->options = array_merge($this->options, $options);
  40761. }
  40762. public function __toString()
  40763. {
  40764. return $this->value;
  40765. }
  40766. public function getColspan()
  40767. {
  40768. return (int) $this->options['colspan'];
  40769. }
  40770. public function getRowspan()
  40771. {
  40772. return (int) $this->options['rowspan'];
  40773. }
  40774. }
  40775. <?php
  40776. namespace Symfony\Component\Console\Helper;
  40777. use Symfony\Component\Console\Exception\InvalidArgumentException;
  40778. use Symfony\Component\Console\Output\NullOutput;
  40779. use Symfony\Component\Console\Output\OutputInterface;
  40780. class TableHelper extends Helper
  40781. {
  40782. const LAYOUT_DEFAULT = 0;
  40783. const LAYOUT_BORDERLESS = 1;
  40784. const LAYOUT_COMPACT = 2;
  40785. private $table;
  40786. public function __construct($triggerDeprecationError = true)
  40787. {
  40788. if ($triggerDeprecationError) {
  40789. @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);
  40790. }
  40791. $this->table = new Table(new NullOutput());
  40792. }
  40793. public function setLayout($layout)
  40794. {
  40795. switch ($layout) {
  40796. case self::LAYOUT_BORDERLESS:
  40797. $this->table->setStyle('borderless');
  40798. break;
  40799. case self::LAYOUT_COMPACT:
  40800. $this->table->setStyle('compact');
  40801. break;
  40802. case self::LAYOUT_DEFAULT:
  40803. $this->table->setStyle('default');
  40804. break;
  40805. default:
  40806. throw new InvalidArgumentException(sprintf('Invalid table layout "%s".', $layout));
  40807. }
  40808. return $this;
  40809. }
  40810. public function setHeaders(array $headers)
  40811. {
  40812. $this->table->setHeaders($headers);
  40813. return $this;
  40814. }
  40815. public function setRows(array $rows)
  40816. {
  40817. $this->table->setRows($rows);
  40818. return $this;
  40819. }
  40820. public function addRows(array $rows)
  40821. {
  40822. $this->table->addRows($rows);
  40823. return $this;
  40824. }
  40825. public function addRow(array $row)
  40826. {
  40827. $this->table->addRow($row);
  40828. return $this;
  40829. }
  40830. public function setRow($column, array $row)
  40831. {
  40832. $this->table->setRow($column, $row);
  40833. return $this;
  40834. }
  40835. public function setPaddingChar($paddingChar)
  40836. {
  40837. $this->table->getStyle()->setPaddingChar($paddingChar);
  40838. return $this;
  40839. }
  40840. public function setHorizontalBorderChar($horizontalBorderChar)
  40841. {
  40842. $this->table->getStyle()->setHorizontalBorderChar($horizontalBorderChar);
  40843. return $this;
  40844. }
  40845. public function setVerticalBorderChar($verticalBorderChar)
  40846. {
  40847. $this->table->getStyle()->setVerticalBorderChar($verticalBorderChar);
  40848. return $this;
  40849. }
  40850. public function setCrossingChar($crossingChar)
  40851. {
  40852. $this->table->getStyle()->setCrossingChar($crossingChar);
  40853. return $this;
  40854. }
  40855. public function setCellHeaderFormat($cellHeaderFormat)
  40856. {
  40857. $this->table->getStyle()->setCellHeaderFormat($cellHeaderFormat);
  40858. return $this;
  40859. }
  40860. public function setCellRowFormat($cellRowFormat)
  40861. {
  40862. $this->table->getStyle()->setCellHeaderFormat($cellRowFormat);
  40863. return $this;
  40864. }
  40865. public function setCellRowContentFormat($cellRowContentFormat)
  40866. {
  40867. $this->table->getStyle()->setCellRowContentFormat($cellRowContentFormat);
  40868. return $this;
  40869. }
  40870. public function setBorderFormat($borderFormat)
  40871. {
  40872. $this->table->getStyle()->setBorderFormat($borderFormat);
  40873. return $this;
  40874. }
  40875. public function setPadType($padType)
  40876. {
  40877. $this->table->getStyle()->setPadType($padType);
  40878. return $this;
  40879. }
  40880. public function render(OutputInterface $output)
  40881. {
  40882. $p = new \ReflectionProperty($this->table, 'output');
  40883. $p->setAccessible(true);
  40884. $p->setValue($this->table, $output);
  40885. $this->table->render();
  40886. }
  40887. public function getName()
  40888. {
  40889. return 'table';
  40890. }
  40891. }
  40892. <?php
  40893. namespace Symfony\Component\Console\Helper;
  40894. class TableSeparator extends TableCell
  40895. {
  40896. public function __construct(array $options = array())
  40897. {
  40898. parent::__construct('', $options);
  40899. }
  40900. }
  40901. <?php
  40902. namespace Symfony\Component\Console\Helper;
  40903. use Symfony\Component\Console\Exception\InvalidArgumentException;
  40904. use Symfony\Component\Console\Exception\LogicException;
  40905. class TableStyle
  40906. {
  40907. private $paddingChar = ' ';
  40908. private $horizontalBorderChar = '-';
  40909. private $verticalBorderChar = '|';
  40910. private $crossingChar = '+';
  40911. private $cellHeaderFormat = '<info>%s</info>';
  40912. private $cellRowFormat = '%s';
  40913. private $cellRowContentFormat = ' %s ';
  40914. private $borderFormat = '%s';
  40915. private $padType = STR_PAD_RIGHT;
  40916. public function setPaddingChar($paddingChar)
  40917. {
  40918. if (!$paddingChar) {
  40919. throw new LogicException('The padding char must not be empty');
  40920. }
  40921. $this->paddingChar = $paddingChar;
  40922. return $this;
  40923. }
  40924. public function getPaddingChar()
  40925. {
  40926. return $this->paddingChar;
  40927. }
  40928. public function setHorizontalBorderChar($horizontalBorderChar)
  40929. {
  40930. $this->horizontalBorderChar = $horizontalBorderChar;
  40931. return $this;
  40932. }
  40933. public function getHorizontalBorderChar()
  40934. {
  40935. return $this->horizontalBorderChar;
  40936. }
  40937. public function setVerticalBorderChar($verticalBorderChar)
  40938. {
  40939. $this->verticalBorderChar = $verticalBorderChar;
  40940. return $this;
  40941. }
  40942. public function getVerticalBorderChar()
  40943. {
  40944. return $this->verticalBorderChar;
  40945. }
  40946. public function setCrossingChar($crossingChar)
  40947. {
  40948. $this->crossingChar = $crossingChar;
  40949. return $this;
  40950. }
  40951. public function getCrossingChar()
  40952. {
  40953. return $this->crossingChar;
  40954. }
  40955. public function setCellHeaderFormat($cellHeaderFormat)
  40956. {
  40957. $this->cellHeaderFormat = $cellHeaderFormat;
  40958. return $this;
  40959. }
  40960. public function getCellHeaderFormat()
  40961. {
  40962. return $this->cellHeaderFormat;
  40963. }
  40964. public function setCellRowFormat($cellRowFormat)
  40965. {
  40966. $this->cellRowFormat = $cellRowFormat;
  40967. return $this;
  40968. }
  40969. public function getCellRowFormat()
  40970. {
  40971. return $this->cellRowFormat;
  40972. }
  40973. public function setCellRowContentFormat($cellRowContentFormat)
  40974. {
  40975. $this->cellRowContentFormat = $cellRowContentFormat;
  40976. return $this;
  40977. }
  40978. public function getCellRowContentFormat()
  40979. {
  40980. return $this->cellRowContentFormat;
  40981. }
  40982. public function setBorderFormat($borderFormat)
  40983. {
  40984. $this->borderFormat = $borderFormat;
  40985. return $this;
  40986. }
  40987. public function getBorderFormat()
  40988. {
  40989. return $this->borderFormat;
  40990. }
  40991. public function setPadType($padType)
  40992. {
  40993. if (!\in_array($padType, array(STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH), true)) {
  40994. throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).');
  40995. }
  40996. $this->padType = $padType;
  40997. return $this;
  40998. }
  40999. public function getPadType()
  41000. {
  41001. return $this->padType;
  41002. }
  41003. }
  41004. <?php
  41005. namespace Symfony\Component\Console\Input;
  41006. use Symfony\Component\Console\Exception\RuntimeException;
  41007. class ArgvInput extends Input
  41008. {
  41009. private $tokens;
  41010. private $parsed;
  41011. public function __construct(array $argv = null, InputDefinition $definition = null)
  41012. {
  41013. if (null === $argv) {
  41014. $argv = $_SERVER['argv'];
  41015. }
  41016. array_shift($argv);
  41017. $this->tokens = $argv;
  41018. parent::__construct($definition);
  41019. }
  41020. protected function setTokens(array $tokens)
  41021. {
  41022. $this->tokens = $tokens;
  41023. }
  41024. protected function parse()
  41025. {
  41026. $parseOptions = true;
  41027. $this->parsed = $this->tokens;
  41028. while (null !== $token = array_shift($this->parsed)) {
  41029. if ($parseOptions && '' == $token) {
  41030. $this->parseArgument($token);
  41031. } elseif ($parseOptions && '--' == $token) {
  41032. $parseOptions = false;
  41033. } elseif ($parseOptions && 0 === strpos($token, '--')) {
  41034. $this->parseLongOption($token);
  41035. } elseif ($parseOptions && '-' === $token[0] && '-' !== $token) {
  41036. $this->parseShortOption($token);
  41037. } else {
  41038. $this->parseArgument($token);
  41039. }
  41040. }
  41041. }
  41042. private function parseShortOption($token)
  41043. {
  41044. $name = substr($token, 1);
  41045. if (\strlen($name) > 1) {
  41046. if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptValue()) {
  41047. $this->addShortOption($name[0], substr($name, 1));
  41048. } else {
  41049. $this->parseShortOptionSet($name);
  41050. }
  41051. } else {
  41052. $this->addShortOption($name, null);
  41053. }
  41054. }
  41055. private function parseShortOptionSet($name)
  41056. {
  41057. $len = \strlen($name);
  41058. for ($i = 0; $i < $len; ++$i) {
  41059. if (!$this->definition->hasShortcut($name[$i])) {
  41060. $encoding = mb_detect_encoding($name, null, true);
  41061. throw new RuntimeException(sprintf('The "-%s" option does not exist.', false === $encoding ? $name[$i] : mb_substr($name, $i, 1, $encoding)));
  41062. }
  41063. $option = $this->definition->getOptionForShortcut($name[$i]);
  41064. if ($option->acceptValue()) {
  41065. $this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1));
  41066. break;
  41067. } else {
  41068. $this->addLongOption($option->getName(), null);
  41069. }
  41070. }
  41071. }
  41072. private function parseLongOption($token)
  41073. {
  41074. $name = substr($token, 2);
  41075. if (false !== $pos = strpos($name, '=')) {
  41076. if (0 === \strlen($value = substr($name, $pos + 1))) {
  41077. array_unshift($this->parsed, null);
  41078. }
  41079. $this->addLongOption(substr($name, 0, $pos), $value);
  41080. } else {
  41081. $this->addLongOption($name, null);
  41082. }
  41083. }
  41084. private function parseArgument($token)
  41085. {
  41086. $c = \count($this->arguments);
  41087. if ($this->definition->hasArgument($c)) {
  41088. $arg = $this->definition->getArgument($c);
  41089. $this->arguments[$arg->getName()] = $arg->isArray() ? array($token) : $token;
  41090. } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) {
  41091. $arg = $this->definition->getArgument($c - 1);
  41092. $this->arguments[$arg->getName()][] = $token;
  41093. } else {
  41094. $all = $this->definition->getArguments();
  41095. if (\count($all)) {
  41096. throw new RuntimeException(sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all))));
  41097. }
  41098. throw new RuntimeException(sprintf('No arguments expected, got "%s".', $token));
  41099. }
  41100. }
  41101. private function addShortOption($shortcut, $value)
  41102. {
  41103. if (!$this->definition->hasShortcut($shortcut)) {
  41104. throw new RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut));
  41105. }
  41106. $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
  41107. }
  41108. private function addLongOption($name, $value)
  41109. {
  41110. if (!$this->definition->hasOption($name)) {
  41111. throw new RuntimeException(sprintf('The "--%s" option does not exist.', $name));
  41112. }
  41113. $option = $this->definition->getOption($name);
  41114. if (!isset($value[0])) {
  41115. $value = null;
  41116. }
  41117. if (null !== $value && !$option->acceptValue()) {
  41118. throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
  41119. }
  41120. if (null === $value && $option->acceptValue() && \count($this->parsed)) {
  41121. $next = array_shift($this->parsed);
  41122. if (isset($next[0]) && '-' !== $next[0]) {
  41123. $value = $next;
  41124. } elseif (empty($next)) {
  41125. $value = null;
  41126. } else {
  41127. array_unshift($this->parsed, $next);
  41128. }
  41129. }
  41130. if (null === $value) {
  41131. if ($option->isValueRequired()) {
  41132. throw new RuntimeException(sprintf('The "--%s" option requires a value.', $name));
  41133. }
  41134. if (!$option->isArray()) {
  41135. $value = $option->isValueOptional() ? $option->getDefault() : true;
  41136. }
  41137. }
  41138. if ($option->isArray()) {
  41139. $this->options[$name][] = $value;
  41140. } else {
  41141. $this->options[$name] = $value;
  41142. }
  41143. }
  41144. public function getFirstArgument()
  41145. {
  41146. foreach ($this->tokens as $token) {
  41147. if ($token && '-' === $token[0]) {
  41148. continue;
  41149. }
  41150. return $token;
  41151. }
  41152. }
  41153. public function hasParameterOption($values)
  41154. {
  41155. $values = (array) $values;
  41156. foreach ($this->tokens as $token) {
  41157. foreach ($values as $value) {
  41158. $leading = 0 === strpos($value, '--') ? $value.'=' : $value;
  41159. if ($token === $value || '' !== $leading && 0 === strpos($token, $leading)) {
  41160. return true;
  41161. }
  41162. }
  41163. }
  41164. return false;
  41165. }
  41166. public function getParameterOption($values, $default = false)
  41167. {
  41168. $values = (array) $values;
  41169. $tokens = $this->tokens;
  41170. while (0 < \count($tokens)) {
  41171. $token = array_shift($tokens);
  41172. foreach ($values as $value) {
  41173. if ($token === $value) {
  41174. return array_shift($tokens);
  41175. }
  41176. $leading = 0 === strpos($value, '--') ? $value.'=' : $value;
  41177. if ('' !== $leading && 0 === strpos($token, $leading)) {
  41178. return substr($token, \strlen($leading));
  41179. }
  41180. }
  41181. }
  41182. return $default;
  41183. }
  41184. public function __toString()
  41185. {
  41186. $self = $this;
  41187. $tokens = array_map(function ($token) use ($self) {
  41188. if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) {
  41189. return $match[1].$self->escapeToken($match[2]);
  41190. }
  41191. if ($token && '-' !== $token[0]) {
  41192. return $self->escapeToken($token);
  41193. }
  41194. return $token;
  41195. }, $this->tokens);
  41196. return implode(' ', $tokens);
  41197. }
  41198. }
  41199. <?php
  41200. namespace Symfony\Component\Console\Input;
  41201. use Symfony\Component\Console\Exception\InvalidArgumentException;
  41202. use Symfony\Component\Console\Exception\InvalidOptionException;
  41203. class ArrayInput extends Input
  41204. {
  41205. private $parameters;
  41206. public function __construct(array $parameters, InputDefinition $definition = null)
  41207. {
  41208. $this->parameters = $parameters;
  41209. parent::__construct($definition);
  41210. }
  41211. public function getFirstArgument()
  41212. {
  41213. foreach ($this->parameters as $key => $value) {
  41214. if ($key && '-' === $key[0]) {
  41215. continue;
  41216. }
  41217. return $value;
  41218. }
  41219. }
  41220. public function hasParameterOption($values)
  41221. {
  41222. $values = (array) $values;
  41223. foreach ($this->parameters as $k => $v) {
  41224. if (!\is_int($k)) {
  41225. $v = $k;
  41226. }
  41227. if (\in_array($v, $values)) {
  41228. return true;
  41229. }
  41230. }
  41231. return false;
  41232. }
  41233. public function getParameterOption($values, $default = false)
  41234. {
  41235. $values = (array) $values;
  41236. foreach ($this->parameters as $k => $v) {
  41237. if (\is_int($k)) {
  41238. if (\in_array($v, $values)) {
  41239. return true;
  41240. }
  41241. } elseif (\in_array($k, $values)) {
  41242. return $v;
  41243. }
  41244. }
  41245. return $default;
  41246. }
  41247. public function __toString()
  41248. {
  41249. $params = array();
  41250. foreach ($this->parameters as $param => $val) {
  41251. if ($param && '-' === $param[0]) {
  41252. if (\is_array($val)) {
  41253. foreach ($val as $v) {
  41254. $params[] = $param.('' != $v ? '='.$this->escapeToken($v) : '');
  41255. }
  41256. } else {
  41257. $params[] = $param.('' != $val ? '='.$this->escapeToken($val) : '');
  41258. }
  41259. } else {
  41260. $params[] = \is_array($val) ? implode(' ', array_map(array($this, 'escapeToken'), $val)) : $this->escapeToken($val);
  41261. }
  41262. }
  41263. return implode(' ', $params);
  41264. }
  41265. protected function parse()
  41266. {
  41267. foreach ($this->parameters as $key => $value) {
  41268. if (0 === strpos($key, '--')) {
  41269. $this->addLongOption(substr($key, 2), $value);
  41270. } elseif ('-' === $key[0]) {
  41271. $this->addShortOption(substr($key, 1), $value);
  41272. } else {
  41273. $this->addArgument($key, $value);
  41274. }
  41275. }
  41276. }
  41277. private function addShortOption($shortcut, $value)
  41278. {
  41279. if (!$this->definition->hasShortcut($shortcut)) {
  41280. throw new InvalidOptionException(sprintf('The "-%s" option does not exist.', $shortcut));
  41281. }
  41282. $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
  41283. }
  41284. private function addLongOption($name, $value)
  41285. {
  41286. if (!$this->definition->hasOption($name)) {
  41287. throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name));
  41288. }
  41289. $option = $this->definition->getOption($name);
  41290. if (null === $value) {
  41291. if ($option->isValueRequired()) {
  41292. throw new InvalidOptionException(sprintf('The "--%s" option requires a value.', $name));
  41293. }
  41294. $value = $option->isValueOptional() ? $option->getDefault() : true;
  41295. }
  41296. $this->options[$name] = $value;
  41297. }
  41298. private function addArgument($name, $value)
  41299. {
  41300. if (!$this->definition->hasArgument($name)) {
  41301. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  41302. }
  41303. $this->arguments[$name] = $value;
  41304. }
  41305. }
  41306. <?php
  41307. namespace Symfony\Component\Console\Input;
  41308. use Symfony\Component\Console\Exception\InvalidArgumentException;
  41309. use Symfony\Component\Console\Exception\RuntimeException;
  41310. abstract class Input implements InputInterface
  41311. {
  41312. protected $definition;
  41313. protected $options = array();
  41314. protected $arguments = array();
  41315. protected $interactive = true;
  41316. public function __construct(InputDefinition $definition = null)
  41317. {
  41318. if (null === $definition) {
  41319. $this->definition = new InputDefinition();
  41320. } else {
  41321. $this->bind($definition);
  41322. $this->validate();
  41323. }
  41324. }
  41325. public function bind(InputDefinition $definition)
  41326. {
  41327. $this->arguments = array();
  41328. $this->options = array();
  41329. $this->definition = $definition;
  41330. $this->parse();
  41331. }
  41332. abstract protected function parse();
  41333. public function validate()
  41334. {
  41335. $definition = $this->definition;
  41336. $givenArguments = $this->arguments;
  41337. $missingArguments = array_filter(array_keys($definition->getArguments()), function ($argument) use ($definition, $givenArguments) {
  41338. return !array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired();
  41339. });
  41340. if (\count($missingArguments) > 0) {
  41341. throw new RuntimeException(sprintf('Not enough arguments (missing: "%s").', implode(', ', $missingArguments)));
  41342. }
  41343. }
  41344. public function isInteractive()
  41345. {
  41346. return $this->interactive;
  41347. }
  41348. public function setInteractive($interactive)
  41349. {
  41350. $this->interactive = (bool) $interactive;
  41351. }
  41352. public function getArguments()
  41353. {
  41354. return array_merge($this->definition->getArgumentDefaults(), $this->arguments);
  41355. }
  41356. public function getArgument($name)
  41357. {
  41358. if (!$this->definition->hasArgument($name)) {
  41359. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  41360. }
  41361. return isset($this->arguments[$name]) ? $this->arguments[$name] : $this->definition->getArgument($name)->getDefault();
  41362. }
  41363. public function setArgument($name, $value)
  41364. {
  41365. if (!$this->definition->hasArgument($name)) {
  41366. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  41367. }
  41368. $this->arguments[$name] = $value;
  41369. }
  41370. public function hasArgument($name)
  41371. {
  41372. return $this->definition->hasArgument($name);
  41373. }
  41374. public function getOptions()
  41375. {
  41376. return array_merge($this->definition->getOptionDefaults(), $this->options);
  41377. }
  41378. public function getOption($name)
  41379. {
  41380. if (!$this->definition->hasOption($name)) {
  41381. throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
  41382. }
  41383. return isset($this->options[$name]) ? $this->options[$name] : $this->definition->getOption($name)->getDefault();
  41384. }
  41385. public function setOption($name, $value)
  41386. {
  41387. if (!$this->definition->hasOption($name)) {
  41388. throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
  41389. }
  41390. $this->options[$name] = $value;
  41391. }
  41392. public function hasOption($name)
  41393. {
  41394. return $this->definition->hasOption($name);
  41395. }
  41396. public function escapeToken($token)
  41397. {
  41398. return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token);
  41399. }
  41400. }
  41401. <?php
  41402. namespace Symfony\Component\Console\Input;
  41403. use Symfony\Component\Console\Exception\InvalidArgumentException;
  41404. use Symfony\Component\Console\Exception\LogicException;
  41405. class InputArgument
  41406. {
  41407. const REQUIRED = 1;
  41408. const OPTIONAL = 2;
  41409. const IS_ARRAY = 4;
  41410. private $name;
  41411. private $mode;
  41412. private $default;
  41413. private $description;
  41414. public function __construct($name, $mode = null, $description = '', $default = null)
  41415. {
  41416. if (null === $mode) {
  41417. $mode = self::OPTIONAL;
  41418. } elseif (!\is_int($mode) || $mode > 7 || $mode < 1) {
  41419. throw new InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode));
  41420. }
  41421. $this->name = $name;
  41422. $this->mode = $mode;
  41423. $this->description = $description;
  41424. $this->setDefault($default);
  41425. }
  41426. public function getName()
  41427. {
  41428. return $this->name;
  41429. }
  41430. public function isRequired()
  41431. {
  41432. return self::REQUIRED === (self::REQUIRED & $this->mode);
  41433. }
  41434. public function isArray()
  41435. {
  41436. return self::IS_ARRAY === (self::IS_ARRAY & $this->mode);
  41437. }
  41438. public function setDefault($default = null)
  41439. {
  41440. if (self::REQUIRED === $this->mode && null !== $default) {
  41441. throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.');
  41442. }
  41443. if ($this->isArray()) {
  41444. if (null === $default) {
  41445. $default = array();
  41446. } elseif (!\is_array($default)) {
  41447. throw new LogicException('A default value for an array argument must be an array.');
  41448. }
  41449. }
  41450. $this->default = $default;
  41451. }
  41452. public function getDefault()
  41453. {
  41454. return $this->default;
  41455. }
  41456. public function getDescription()
  41457. {
  41458. return $this->description;
  41459. }
  41460. }
  41461. <?php
  41462. namespace Symfony\Component\Console\Input;
  41463. interface InputAwareInterface
  41464. {
  41465. public function setInput(InputInterface $input);
  41466. }
  41467. <?php
  41468. namespace Symfony\Component\Console\Input;
  41469. use Symfony\Component\Console\Descriptor\TextDescriptor;
  41470. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  41471. use Symfony\Component\Console\Exception\InvalidArgumentException;
  41472. use Symfony\Component\Console\Exception\LogicException;
  41473. use Symfony\Component\Console\Output\BufferedOutput;
  41474. class InputDefinition
  41475. {
  41476. private $arguments;
  41477. private $requiredCount;
  41478. private $hasAnArrayArgument = false;
  41479. private $hasOptional;
  41480. private $options;
  41481. private $shortcuts;
  41482. public function __construct(array $definition = array())
  41483. {
  41484. $this->setDefinition($definition);
  41485. }
  41486. public function setDefinition(array $definition)
  41487. {
  41488. $arguments = array();
  41489. $options = array();
  41490. foreach ($definition as $item) {
  41491. if ($item instanceof InputOption) {
  41492. $options[] = $item;
  41493. } else {
  41494. $arguments[] = $item;
  41495. }
  41496. }
  41497. $this->setArguments($arguments);
  41498. $this->setOptions($options);
  41499. }
  41500. public function setArguments($arguments = array())
  41501. {
  41502. $this->arguments = array();
  41503. $this->requiredCount = 0;
  41504. $this->hasOptional = false;
  41505. $this->hasAnArrayArgument = false;
  41506. $this->addArguments($arguments);
  41507. }
  41508. public function addArguments($arguments = array())
  41509. {
  41510. if (null !== $arguments) {
  41511. foreach ($arguments as $argument) {
  41512. $this->addArgument($argument);
  41513. }
  41514. }
  41515. }
  41516. public function addArgument(InputArgument $argument)
  41517. {
  41518. if (isset($this->arguments[$argument->getName()])) {
  41519. throw new LogicException(sprintf('An argument with name "%s" already exists.', $argument->getName()));
  41520. }
  41521. if ($this->hasAnArrayArgument) {
  41522. throw new LogicException('Cannot add an argument after an array argument.');
  41523. }
  41524. if ($argument->isRequired() && $this->hasOptional) {
  41525. throw new LogicException('Cannot add a required argument after an optional one.');
  41526. }
  41527. if ($argument->isArray()) {
  41528. $this->hasAnArrayArgument = true;
  41529. }
  41530. if ($argument->isRequired()) {
  41531. ++$this->requiredCount;
  41532. } else {
  41533. $this->hasOptional = true;
  41534. }
  41535. $this->arguments[$argument->getName()] = $argument;
  41536. }
  41537. public function getArgument($name)
  41538. {
  41539. if (!$this->hasArgument($name)) {
  41540. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  41541. }
  41542. $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
  41543. return $arguments[$name];
  41544. }
  41545. public function hasArgument($name)
  41546. {
  41547. $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
  41548. return isset($arguments[$name]);
  41549. }
  41550. public function getArguments()
  41551. {
  41552. return $this->arguments;
  41553. }
  41554. public function getArgumentCount()
  41555. {
  41556. return $this->hasAnArrayArgument ? PHP_INT_MAX : \count($this->arguments);
  41557. }
  41558. public function getArgumentRequiredCount()
  41559. {
  41560. return $this->requiredCount;
  41561. }
  41562. public function getArgumentDefaults()
  41563. {
  41564. $values = array();
  41565. foreach ($this->arguments as $argument) {
  41566. $values[$argument->getName()] = $argument->getDefault();
  41567. }
  41568. return $values;
  41569. }
  41570. public function setOptions($options = array())
  41571. {
  41572. $this->options = array();
  41573. $this->shortcuts = array();
  41574. $this->addOptions($options);
  41575. }
  41576. public function addOptions($options = array())
  41577. {
  41578. foreach ($options as $option) {
  41579. $this->addOption($option);
  41580. }
  41581. }
  41582. public function addOption(InputOption $option)
  41583. {
  41584. if (isset($this->options[$option->getName()]) && !$option->equals($this->options[$option->getName()])) {
  41585. throw new LogicException(sprintf('An option named "%s" already exists.', $option->getName()));
  41586. }
  41587. if ($option->getShortcut()) {
  41588. foreach (explode('|', $option->getShortcut()) as $shortcut) {
  41589. if (isset($this->shortcuts[$shortcut]) && !$option->equals($this->options[$this->shortcuts[$shortcut]])) {
  41590. throw new LogicException(sprintf('An option with shortcut "%s" already exists.', $shortcut));
  41591. }
  41592. }
  41593. }
  41594. $this->options[$option->getName()] = $option;
  41595. if ($option->getShortcut()) {
  41596. foreach (explode('|', $option->getShortcut()) as $shortcut) {
  41597. $this->shortcuts[$shortcut] = $option->getName();
  41598. }
  41599. }
  41600. }
  41601. public function getOption($name)
  41602. {
  41603. if (!$this->hasOption($name)) {
  41604. throw new InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name));
  41605. }
  41606. return $this->options[$name];
  41607. }
  41608. public function hasOption($name)
  41609. {
  41610. return isset($this->options[$name]);
  41611. }
  41612. public function getOptions()
  41613. {
  41614. return $this->options;
  41615. }
  41616. public function hasShortcut($name)
  41617. {
  41618. return isset($this->shortcuts[$name]);
  41619. }
  41620. public function getOptionForShortcut($shortcut)
  41621. {
  41622. return $this->getOption($this->shortcutToName($shortcut));
  41623. }
  41624. public function getOptionDefaults()
  41625. {
  41626. $values = array();
  41627. foreach ($this->options as $option) {
  41628. $values[$option->getName()] = $option->getDefault();
  41629. }
  41630. return $values;
  41631. }
  41632. private function shortcutToName($shortcut)
  41633. {
  41634. if (!isset($this->shortcuts[$shortcut])) {
  41635. throw new InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut));
  41636. }
  41637. return $this->shortcuts[$shortcut];
  41638. }
  41639. public function getSynopsis($short = false)
  41640. {
  41641. $elements = array();
  41642. if ($short && $this->getOptions()) {
  41643. $elements[] = '[options]';
  41644. } elseif (!$short) {
  41645. foreach ($this->getOptions() as $option) {
  41646. $value = '';
  41647. if ($option->acceptValue()) {
  41648. $value = sprintf(
  41649. ' %s%s%s',
  41650. $option->isValueOptional() ? '[' : '',
  41651. strtoupper($option->getName()),
  41652. $option->isValueOptional() ? ']' : ''
  41653. );
  41654. }
  41655. $shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : '';
  41656. $elements[] = sprintf('[%s--%s%s]', $shortcut, $option->getName(), $value);
  41657. }
  41658. }
  41659. if (\count($elements) && $this->getArguments()) {
  41660. $elements[] = '[--]';
  41661. }
  41662. foreach ($this->getArguments() as $argument) {
  41663. $element = '<'.$argument->getName().'>';
  41664. if (!$argument->isRequired()) {
  41665. $element = '['.$element.']';
  41666. } elseif ($argument->isArray()) {
  41667. $element .= ' ('.$element.')';
  41668. }
  41669. if ($argument->isArray()) {
  41670. $element .= '...';
  41671. }
  41672. $elements[] = $element;
  41673. }
  41674. return implode(' ', $elements);
  41675. }
  41676. public function asText()
  41677. {
  41678. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  41679. $descriptor = new TextDescriptor();
  41680. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
  41681. $descriptor->describe($output, $this, array('raw_output' => true));
  41682. return $output->fetch();
  41683. }
  41684. public function asXml($asDom = false)
  41685. {
  41686. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  41687. $descriptor = new XmlDescriptor();
  41688. if ($asDom) {
  41689. return $descriptor->getInputDefinitionDocument($this);
  41690. }
  41691. $output = new BufferedOutput();
  41692. $descriptor->describe($output, $this);
  41693. return $output->fetch();
  41694. }
  41695. }
  41696. <?php
  41697. namespace Symfony\Component\Console\Input;
  41698. use Symfony\Component\Console\Exception\InvalidArgumentException;
  41699. use Symfony\Component\Console\Exception\RuntimeException;
  41700. interface InputInterface
  41701. {
  41702. public function getFirstArgument();
  41703. public function hasParameterOption($values);
  41704. public function getParameterOption($values, $default = false);
  41705. public function bind(InputDefinition $definition);
  41706. public function validate();
  41707. public function getArguments();
  41708. public function getArgument($name);
  41709. public function setArgument($name, $value);
  41710. public function hasArgument($name);
  41711. public function getOptions();
  41712. public function getOption($name);
  41713. public function setOption($name, $value);
  41714. public function hasOption($name);
  41715. public function isInteractive();
  41716. public function setInteractive($interactive);
  41717. }
  41718. <?php
  41719. namespace Symfony\Component\Console\Input;
  41720. use Symfony\Component\Console\Exception\InvalidArgumentException;
  41721. use Symfony\Component\Console\Exception\LogicException;
  41722. class InputOption
  41723. {
  41724. const VALUE_NONE = 1;
  41725. const VALUE_REQUIRED = 2;
  41726. const VALUE_OPTIONAL = 4;
  41727. const VALUE_IS_ARRAY = 8;
  41728. private $name;
  41729. private $shortcut;
  41730. private $mode;
  41731. private $default;
  41732. private $description;
  41733. public function __construct($name, $shortcut = null, $mode = null, $description = '', $default = null)
  41734. {
  41735. if (0 === strpos($name, '--')) {
  41736. $name = substr($name, 2);
  41737. }
  41738. if (empty($name)) {
  41739. throw new InvalidArgumentException('An option name cannot be empty.');
  41740. }
  41741. if (empty($shortcut)) {
  41742. $shortcut = null;
  41743. }
  41744. if (null !== $shortcut) {
  41745. if (\is_array($shortcut)) {
  41746. $shortcut = implode('|', $shortcut);
  41747. }
  41748. $shortcuts = preg_split('{(\|)-?}', ltrim($shortcut, '-'));
  41749. $shortcuts = array_filter($shortcuts);
  41750. $shortcut = implode('|', $shortcuts);
  41751. if (empty($shortcut)) {
  41752. throw new InvalidArgumentException('An option shortcut cannot be empty.');
  41753. }
  41754. }
  41755. if (null === $mode) {
  41756. $mode = self::VALUE_NONE;
  41757. } elseif (!\is_int($mode) || $mode > 15 || $mode < 1) {
  41758. throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode));
  41759. }
  41760. $this->name = $name;
  41761. $this->shortcut = $shortcut;
  41762. $this->mode = $mode;
  41763. $this->description = $description;
  41764. if ($this->isArray() && !$this->acceptValue()) {
  41765. throw new InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.');
  41766. }
  41767. $this->setDefault($default);
  41768. }
  41769. public function getShortcut()
  41770. {
  41771. return $this->shortcut;
  41772. }
  41773. public function getName()
  41774. {
  41775. return $this->name;
  41776. }
  41777. public function acceptValue()
  41778. {
  41779. return $this->isValueRequired() || $this->isValueOptional();
  41780. }
  41781. public function isValueRequired()
  41782. {
  41783. return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode);
  41784. }
  41785. public function isValueOptional()
  41786. {
  41787. return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode);
  41788. }
  41789. public function isArray()
  41790. {
  41791. return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode);
  41792. }
  41793. public function setDefault($default = null)
  41794. {
  41795. if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) {
  41796. throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.');
  41797. }
  41798. if ($this->isArray()) {
  41799. if (null === $default) {
  41800. $default = array();
  41801. } elseif (!\is_array($default)) {
  41802. throw new LogicException('A default value for an array option must be an array.');
  41803. }
  41804. }
  41805. $this->default = $this->acceptValue() ? $default : false;
  41806. }
  41807. public function getDefault()
  41808. {
  41809. return $this->default;
  41810. }
  41811. public function getDescription()
  41812. {
  41813. return $this->description;
  41814. }
  41815. public function equals(self $option)
  41816. {
  41817. return $option->getName() === $this->getName()
  41818. && $option->getShortcut() === $this->getShortcut()
  41819. && $option->getDefault() === $this->getDefault()
  41820. && $option->isArray() === $this->isArray()
  41821. && $option->isValueRequired() === $this->isValueRequired()
  41822. && $option->isValueOptional() === $this->isValueOptional()
  41823. ;
  41824. }
  41825. }
  41826. <?php
  41827. namespace Symfony\Component\Console\Input;
  41828. use Symfony\Component\Console\Exception\InvalidArgumentException;
  41829. class StringInput extends ArgvInput
  41830. {
  41831. const REGEX_STRING = '([^\s]+?)(?:\s|(?<!\\\\)"|(?<!\\\\)\'|$)';
  41832. const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')';
  41833. public function __construct($input, InputDefinition $definition = null)
  41834. {
  41835. if ($definition) {
  41836. @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);
  41837. }
  41838. parent::__construct(array(), null);
  41839. $this->setTokens($this->tokenize($input));
  41840. if (null !== $definition) {
  41841. $this->bind($definition);
  41842. }
  41843. }
  41844. private function tokenize($input)
  41845. {
  41846. $tokens = array();
  41847. $length = \strlen($input);
  41848. $cursor = 0;
  41849. while ($cursor < $length) {
  41850. if (preg_match('/\s+/A', $input, $match, null, $cursor)) {
  41851. } elseif (preg_match('/([^="\'\s]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, null, $cursor)) {
  41852. $tokens[] = $match[1].$match[2].stripcslashes(str_replace(array('"\'', '\'"', '\'\'', '""'), '', substr($match[3], 1, \strlen($match[3]) - 2)));
  41853. } elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, null, $cursor)) {
  41854. $tokens[] = stripcslashes(substr($match[0], 1, \strlen($match[0]) - 2));
  41855. } elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, null, $cursor)) {
  41856. $tokens[] = stripcslashes($match[1]);
  41857. } else {
  41858. throw new InvalidArgumentException(sprintf('Unable to parse input near "... %s ..."', substr($input, $cursor, 10)));
  41859. }
  41860. $cursor += \strlen($match[0]);
  41861. }
  41862. return $tokens;
  41863. }
  41864. }
  41865. Copyright (c) 2004-2018 Fabien Potencier
  41866. Permission is hereby granted, free of charge, to any person obtaining a copy
  41867. of this software and associated documentation files (the "Software"), to deal
  41868. in the Software without restriction, including without limitation the rights
  41869. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  41870. copies of the Software, and to permit persons to whom the Software is furnished
  41871. to do so, subject to the following conditions:
  41872. The above copyright notice and this permission notice shall be included in all
  41873. copies or substantial portions of the Software.
  41874. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  41875. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  41876. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  41877. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  41878. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  41879. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  41880. THE SOFTWARE.
  41881. <?php
  41882. namespace Symfony\Component\Console\Logger;
  41883. use Psr\Log\AbstractLogger;
  41884. use Psr\Log\InvalidArgumentException;
  41885. use Psr\Log\LogLevel;
  41886. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  41887. use Symfony\Component\Console\Output\OutputInterface;
  41888. class ConsoleLogger extends AbstractLogger
  41889. {
  41890. const INFO = 'info';
  41891. const ERROR = 'error';
  41892. private $output;
  41893. private $verbosityLevelMap = array(
  41894. LogLevel::EMERGENCY => OutputInterface::VERBOSITY_NORMAL,
  41895. LogLevel::ALERT => OutputInterface::VERBOSITY_NORMAL,
  41896. LogLevel::CRITICAL => OutputInterface::VERBOSITY_NORMAL,
  41897. LogLevel::ERROR => OutputInterface::VERBOSITY_NORMAL,
  41898. LogLevel::WARNING => OutputInterface::VERBOSITY_NORMAL,
  41899. LogLevel::NOTICE => OutputInterface::VERBOSITY_VERBOSE,
  41900. LogLevel::INFO => OutputInterface::VERBOSITY_VERY_VERBOSE,
  41901. LogLevel::DEBUG => OutputInterface::VERBOSITY_DEBUG,
  41902. );
  41903. private $formatLevelMap = array(
  41904. LogLevel::EMERGENCY => self::ERROR,
  41905. LogLevel::ALERT => self::ERROR,
  41906. LogLevel::CRITICAL => self::ERROR,
  41907. LogLevel::ERROR => self::ERROR,
  41908. LogLevel::WARNING => self::INFO,
  41909. LogLevel::NOTICE => self::INFO,
  41910. LogLevel::INFO => self::INFO,
  41911. LogLevel::DEBUG => self::INFO,
  41912. );
  41913. public function __construct(OutputInterface $output, array $verbosityLevelMap = array(), array $formatLevelMap = array())
  41914. {
  41915. $this->output = $output;
  41916. $this->verbosityLevelMap = $verbosityLevelMap + $this->verbosityLevelMap;
  41917. $this->formatLevelMap = $formatLevelMap + $this->formatLevelMap;
  41918. }
  41919. public function log($level, $message, array $context = array())
  41920. {
  41921. if (!isset($this->verbosityLevelMap[$level])) {
  41922. throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
  41923. }
  41924. if (self::ERROR === $this->formatLevelMap[$level] && $this->output instanceof ConsoleOutputInterface) {
  41925. $output = $this->output->getErrorOutput();
  41926. } else {
  41927. $output = $this->output;
  41928. }
  41929. if ($output->getVerbosity() >= $this->verbosityLevelMap[$level]) {
  41930. $output->writeln(sprintf('<%1$s>[%2$s] %3$s</%1$s>', $this->formatLevelMap[$level], $level, $this->interpolate($message, $context)));
  41931. }
  41932. }
  41933. private function interpolate($message, array $context)
  41934. {
  41935. $replace = array();
  41936. foreach ($context as $key => $val) {
  41937. if (!\is_array($val) && (!\is_object($val) || method_exists($val, '__toString'))) {
  41938. $replace[sprintf('{%s}', $key)] = $val;
  41939. }
  41940. }
  41941. return strtr($message, $replace);
  41942. }
  41943. }
  41944. <?php
  41945. namespace Symfony\Component\Console\Output;
  41946. class BufferedOutput extends Output
  41947. {
  41948. private $buffer = '';
  41949. public function fetch()
  41950. {
  41951. $content = $this->buffer;
  41952. $this->buffer = '';
  41953. return $content;
  41954. }
  41955. protected function doWrite($message, $newline)
  41956. {
  41957. $this->buffer .= $message;
  41958. if ($newline) {
  41959. $this->buffer .= PHP_EOL;
  41960. }
  41961. }
  41962. }
  41963. <?php
  41964. namespace Symfony\Component\Console\Output;
  41965. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  41966. class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
  41967. {
  41968. private $stderr;
  41969. public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
  41970. {
  41971. parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter);
  41972. $actualDecorated = $this->isDecorated();
  41973. $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated, $this->getFormatter());
  41974. if (null === $decorated) {
  41975. $this->setDecorated($actualDecorated && $this->stderr->isDecorated());
  41976. }
  41977. }
  41978. public function setDecorated($decorated)
  41979. {
  41980. parent::setDecorated($decorated);
  41981. $this->stderr->setDecorated($decorated);
  41982. }
  41983. public function setFormatter(OutputFormatterInterface $formatter)
  41984. {
  41985. parent::setFormatter($formatter);
  41986. $this->stderr->setFormatter($formatter);
  41987. }
  41988. public function setVerbosity($level)
  41989. {
  41990. parent::setVerbosity($level);
  41991. $this->stderr->setVerbosity($level);
  41992. }
  41993. public function getErrorOutput()
  41994. {
  41995. return $this->stderr;
  41996. }
  41997. public function setErrorOutput(OutputInterface $error)
  41998. {
  41999. $this->stderr = $error;
  42000. }
  42001. protected function hasStdoutSupport()
  42002. {
  42003. return false === $this->isRunningOS400();
  42004. }
  42005. protected function hasStderrSupport()
  42006. {
  42007. return false === $this->isRunningOS400();
  42008. }
  42009. private function isRunningOS400()
  42010. {
  42011. $checks = array(
  42012. \function_exists('php_uname') ? php_uname('s') : '',
  42013. getenv('OSTYPE'),
  42014. PHP_OS,
  42015. );
  42016. return false !== stripos(implode(';', $checks), 'OS400');
  42017. }
  42018. private function openOutputStream()
  42019. {
  42020. $outputStream = $this->hasStdoutSupport() ? 'php://stdout' : 'php://output';
  42021. return @fopen($outputStream, 'w') ?: fopen('php://output', 'w');
  42022. }
  42023. private function openErrorStream()
  42024. {
  42025. $errorStream = $this->hasStderrSupport() ? 'php://stderr' : 'php://output';
  42026. return fopen($errorStream, 'w');
  42027. }
  42028. }
  42029. <?php
  42030. namespace Symfony\Component\Console\Output;
  42031. interface ConsoleOutputInterface extends OutputInterface
  42032. {
  42033. public function getErrorOutput();
  42034. public function setErrorOutput(OutputInterface $error);
  42035. }
  42036. <?php
  42037. namespace Symfony\Component\Console\Output;
  42038. use Symfony\Component\Console\Formatter\OutputFormatter;
  42039. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  42040. class NullOutput implements OutputInterface
  42041. {
  42042. public function setFormatter(OutputFormatterInterface $formatter)
  42043. {
  42044. }
  42045. public function getFormatter()
  42046. {
  42047. return new OutputFormatter();
  42048. }
  42049. public function setDecorated($decorated)
  42050. {
  42051. }
  42052. public function isDecorated()
  42053. {
  42054. return false;
  42055. }
  42056. public function setVerbosity($level)
  42057. {
  42058. }
  42059. public function getVerbosity()
  42060. {
  42061. return self::VERBOSITY_QUIET;
  42062. }
  42063. public function isQuiet()
  42064. {
  42065. return true;
  42066. }
  42067. public function isVerbose()
  42068. {
  42069. return false;
  42070. }
  42071. public function isVeryVerbose()
  42072. {
  42073. return false;
  42074. }
  42075. public function isDebug()
  42076. {
  42077. return false;
  42078. }
  42079. public function writeln($messages, $options = self::OUTPUT_NORMAL)
  42080. {
  42081. }
  42082. public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL)
  42083. {
  42084. }
  42085. }
  42086. <?php
  42087. namespace Symfony\Component\Console\Output;
  42088. use Symfony\Component\Console\Formatter\OutputFormatter;
  42089. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  42090. abstract class Output implements OutputInterface
  42091. {
  42092. private $verbosity;
  42093. private $formatter;
  42094. public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = false, OutputFormatterInterface $formatter = null)
  42095. {
  42096. $this->verbosity = null === $verbosity ? self::VERBOSITY_NORMAL : $verbosity;
  42097. $this->formatter = $formatter ?: new OutputFormatter();
  42098. $this->formatter->setDecorated($decorated);
  42099. }
  42100. public function setFormatter(OutputFormatterInterface $formatter)
  42101. {
  42102. $this->formatter = $formatter;
  42103. }
  42104. public function getFormatter()
  42105. {
  42106. return $this->formatter;
  42107. }
  42108. public function setDecorated($decorated)
  42109. {
  42110. $this->formatter->setDecorated($decorated);
  42111. }
  42112. public function isDecorated()
  42113. {
  42114. return $this->formatter->isDecorated();
  42115. }
  42116. public function setVerbosity($level)
  42117. {
  42118. $this->verbosity = (int) $level;
  42119. }
  42120. public function getVerbosity()
  42121. {
  42122. return $this->verbosity;
  42123. }
  42124. public function isQuiet()
  42125. {
  42126. return self::VERBOSITY_QUIET === $this->verbosity;
  42127. }
  42128. public function isVerbose()
  42129. {
  42130. return self::VERBOSITY_VERBOSE <= $this->verbosity;
  42131. }
  42132. public function isVeryVerbose()
  42133. {
  42134. return self::VERBOSITY_VERY_VERBOSE <= $this->verbosity;
  42135. }
  42136. public function isDebug()
  42137. {
  42138. return self::VERBOSITY_DEBUG <= $this->verbosity;
  42139. }
  42140. public function writeln($messages, $options = self::OUTPUT_NORMAL)
  42141. {
  42142. $this->write($messages, true, $options);
  42143. }
  42144. public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL)
  42145. {
  42146. $messages = (array) $messages;
  42147. $types = self::OUTPUT_NORMAL | self::OUTPUT_RAW | self::OUTPUT_PLAIN;
  42148. $type = $types & $options ?: self::OUTPUT_NORMAL;
  42149. $verbosities = self::VERBOSITY_QUIET | self::VERBOSITY_NORMAL | self::VERBOSITY_VERBOSE | self::VERBOSITY_VERY_VERBOSE | self::VERBOSITY_DEBUG;
  42150. $verbosity = $verbosities & $options ?: self::VERBOSITY_NORMAL;
  42151. if ($verbosity > $this->getVerbosity()) {
  42152. return;
  42153. }
  42154. foreach ($messages as $message) {
  42155. switch ($type) {
  42156. case OutputInterface::OUTPUT_NORMAL:
  42157. $message = $this->formatter->format($message);
  42158. break;
  42159. case OutputInterface::OUTPUT_RAW:
  42160. break;
  42161. case OutputInterface::OUTPUT_PLAIN:
  42162. $message = strip_tags($this->formatter->format($message));
  42163. break;
  42164. }
  42165. $this->doWrite($message, $newline);
  42166. }
  42167. }
  42168. abstract protected function doWrite($message, $newline);
  42169. }
  42170. <?php
  42171. namespace Symfony\Component\Console\Output;
  42172. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  42173. interface OutputInterface
  42174. {
  42175. const VERBOSITY_QUIET = 16;
  42176. const VERBOSITY_NORMAL = 32;
  42177. const VERBOSITY_VERBOSE = 64;
  42178. const VERBOSITY_VERY_VERBOSE = 128;
  42179. const VERBOSITY_DEBUG = 256;
  42180. const OUTPUT_NORMAL = 1;
  42181. const OUTPUT_RAW = 2;
  42182. const OUTPUT_PLAIN = 4;
  42183. public function write($messages, $newline = false, $options = 0);
  42184. public function writeln($messages, $options = 0);
  42185. public function setVerbosity($level);
  42186. public function getVerbosity();
  42187. public function setDecorated($decorated);
  42188. public function isDecorated();
  42189. public function setFormatter(OutputFormatterInterface $formatter);
  42190. public function getFormatter();
  42191. }
  42192. <?php
  42193. namespace Symfony\Component\Console\Output;
  42194. use Symfony\Component\Console\Exception\InvalidArgumentException;
  42195. use Symfony\Component\Console\Exception\RuntimeException;
  42196. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  42197. class StreamOutput extends Output
  42198. {
  42199. private $stream;
  42200. public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
  42201. {
  42202. if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) {
  42203. throw new InvalidArgumentException('The StreamOutput class needs a stream as its first argument.');
  42204. }
  42205. $this->stream = $stream;
  42206. if (null === $decorated) {
  42207. $decorated = $this->hasColorSupport();
  42208. }
  42209. parent::__construct($verbosity, $decorated, $formatter);
  42210. }
  42211. public function getStream()
  42212. {
  42213. return $this->stream;
  42214. }
  42215. protected function doWrite($message, $newline)
  42216. {
  42217. if ($newline) {
  42218. $message .= PHP_EOL;
  42219. }
  42220. if (false === @fwrite($this->stream, $message)) {
  42221. throw new RuntimeException('Unable to write output.');
  42222. }
  42223. fflush($this->stream);
  42224. }
  42225. protected function hasColorSupport()
  42226. {
  42227. if ('Hyper' === getenv('TERM_PROGRAM')) {
  42228. return true;
  42229. }
  42230. if (\DIRECTORY_SEPARATOR === '\\') {
  42231. return (\function_exists('sapi_windows_vt100_support')
  42232. && @sapi_windows_vt100_support($this->stream))
  42233. || false !== getenv('ANSICON')
  42234. || 'ON' === getenv('ConEmuANSI')
  42235. || 'xterm' === getenv('TERM');
  42236. }
  42237. if (\function_exists('stream_isatty')) {
  42238. return @stream_isatty($this->stream);
  42239. }
  42240. if (\function_exists('posix_isatty')) {
  42241. return @posix_isatty($this->stream);
  42242. }
  42243. $stat = @fstat($this->stream);
  42244. return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
  42245. }
  42246. }
  42247. <?php
  42248. namespace Symfony\Component\Console\Question;
  42249. use Symfony\Component\Console\Exception\InvalidArgumentException;
  42250. class ChoiceQuestion extends Question
  42251. {
  42252. private $choices;
  42253. private $multiselect = false;
  42254. private $prompt = ' > ';
  42255. private $errorMessage = 'Value "%s" is invalid';
  42256. public function __construct($question, array $choices, $default = null)
  42257. {
  42258. if (!$choices) {
  42259. throw new \LogicException('Choice question must have at least 1 choice available.');
  42260. }
  42261. parent::__construct($question, $default);
  42262. $this->choices = $choices;
  42263. $this->setValidator($this->getDefaultValidator());
  42264. $this->setAutocompleterValues($choices);
  42265. }
  42266. public function getChoices()
  42267. {
  42268. return $this->choices;
  42269. }
  42270. public function setMultiselect($multiselect)
  42271. {
  42272. $this->multiselect = $multiselect;
  42273. $this->setValidator($this->getDefaultValidator());
  42274. return $this;
  42275. }
  42276. public function isMultiselect()
  42277. {
  42278. return $this->multiselect;
  42279. }
  42280. public function getPrompt()
  42281. {
  42282. return $this->prompt;
  42283. }
  42284. public function setPrompt($prompt)
  42285. {
  42286. $this->prompt = $prompt;
  42287. return $this;
  42288. }
  42289. public function setErrorMessage($errorMessage)
  42290. {
  42291. $this->errorMessage = $errorMessage;
  42292. $this->setValidator($this->getDefaultValidator());
  42293. return $this;
  42294. }
  42295. private function getDefaultValidator()
  42296. {
  42297. $choices = $this->choices;
  42298. $errorMessage = $this->errorMessage;
  42299. $multiselect = $this->multiselect;
  42300. $isAssoc = $this->isAssoc($choices);
  42301. return function ($selected) use ($choices, $errorMessage, $multiselect, $isAssoc) {
  42302. $selectedChoices = str_replace(' ', '', $selected);
  42303. if ($multiselect) {
  42304. if (!preg_match('/^[^,]+(?:,[^,]+)*$/', $selectedChoices, $matches)) {
  42305. throw new InvalidArgumentException(sprintf($errorMessage, $selected));
  42306. }
  42307. $selectedChoices = explode(',', $selectedChoices);
  42308. } else {
  42309. $selectedChoices = array($selected);
  42310. }
  42311. $multiselectChoices = array();
  42312. foreach ($selectedChoices as $value) {
  42313. $results = array();
  42314. foreach ($choices as $key => $choice) {
  42315. if ($choice === $value) {
  42316. $results[] = $key;
  42317. }
  42318. }
  42319. if (\count($results) > 1) {
  42320. throw new InvalidArgumentException(sprintf('The provided answer is ambiguous. Value should be one of %s.', implode(' or ', $results)));
  42321. }
  42322. $result = array_search($value, $choices);
  42323. if (!$isAssoc) {
  42324. if (false !== $result) {
  42325. $result = $choices[$result];
  42326. } elseif (isset($choices[$value])) {
  42327. $result = $choices[$value];
  42328. }
  42329. } elseif (false === $result && isset($choices[$value])) {
  42330. $result = $value;
  42331. }
  42332. if (false === $result) {
  42333. throw new InvalidArgumentException(sprintf($errorMessage, $value));
  42334. }
  42335. $multiselectChoices[] = (string) $result;
  42336. }
  42337. if ($multiselect) {
  42338. return $multiselectChoices;
  42339. }
  42340. return current($multiselectChoices);
  42341. };
  42342. }
  42343. }
  42344. <?php
  42345. namespace Symfony\Component\Console\Question;
  42346. class ConfirmationQuestion extends Question
  42347. {
  42348. private $trueAnswerRegex;
  42349. public function __construct($question, $default = true, $trueAnswerRegex = '/^y/i')
  42350. {
  42351. parent::__construct($question, (bool) $default);
  42352. $this->trueAnswerRegex = $trueAnswerRegex;
  42353. $this->setNormalizer($this->getDefaultNormalizer());
  42354. }
  42355. private function getDefaultNormalizer()
  42356. {
  42357. $default = $this->getDefault();
  42358. $regex = $this->trueAnswerRegex;
  42359. return function ($answer) use ($default, $regex) {
  42360. if (\is_bool($answer)) {
  42361. return $answer;
  42362. }
  42363. $answerIsTrue = (bool) preg_match($regex, $answer);
  42364. if (false === $default) {
  42365. return $answer && $answerIsTrue;
  42366. }
  42367. return !$answer || $answerIsTrue;
  42368. };
  42369. }
  42370. }
  42371. <?php
  42372. namespace Symfony\Component\Console\Question;
  42373. use Symfony\Component\Console\Exception\InvalidArgumentException;
  42374. use Symfony\Component\Console\Exception\LogicException;
  42375. class Question
  42376. {
  42377. private $question;
  42378. private $attempts;
  42379. private $hidden = false;
  42380. private $hiddenFallback = true;
  42381. private $autocompleterValues;
  42382. private $validator;
  42383. private $default;
  42384. private $normalizer;
  42385. public function __construct($question, $default = null)
  42386. {
  42387. $this->question = $question;
  42388. $this->default = $default;
  42389. }
  42390. public function getQuestion()
  42391. {
  42392. return $this->question;
  42393. }
  42394. public function getDefault()
  42395. {
  42396. return $this->default;
  42397. }
  42398. public function isHidden()
  42399. {
  42400. return $this->hidden;
  42401. }
  42402. public function setHidden($hidden)
  42403. {
  42404. if ($this->autocompleterValues) {
  42405. throw new LogicException('A hidden question cannot use the autocompleter.');
  42406. }
  42407. $this->hidden = (bool) $hidden;
  42408. return $this;
  42409. }
  42410. public function isHiddenFallback()
  42411. {
  42412. return $this->hiddenFallback;
  42413. }
  42414. public function setHiddenFallback($fallback)
  42415. {
  42416. $this->hiddenFallback = (bool) $fallback;
  42417. return $this;
  42418. }
  42419. public function getAutocompleterValues()
  42420. {
  42421. return $this->autocompleterValues;
  42422. }
  42423. public function setAutocompleterValues($values)
  42424. {
  42425. if (\is_array($values)) {
  42426. $values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values);
  42427. }
  42428. if (null !== $values && !\is_array($values) && !$values instanceof \Traversable) {
  42429. throw new InvalidArgumentException('Autocompleter values can be either an array, `null` or a `Traversable` object.');
  42430. }
  42431. if ($this->hidden) {
  42432. throw new LogicException('A hidden question cannot use the autocompleter.');
  42433. }
  42434. $this->autocompleterValues = $values;
  42435. return $this;
  42436. }
  42437. public function setValidator($validator)
  42438. {
  42439. $this->validator = $validator;
  42440. return $this;
  42441. }
  42442. public function getValidator()
  42443. {
  42444. return $this->validator;
  42445. }
  42446. public function setMaxAttempts($attempts)
  42447. {
  42448. if (null !== $attempts && $attempts < 1) {
  42449. throw new InvalidArgumentException('Maximum number of attempts must be a positive value.');
  42450. }
  42451. $this->attempts = $attempts;
  42452. return $this;
  42453. }
  42454. public function getMaxAttempts()
  42455. {
  42456. return $this->attempts;
  42457. }
  42458. public function setNormalizer($normalizer)
  42459. {
  42460. $this->normalizer = $normalizer;
  42461. return $this;
  42462. }
  42463. public function getNormalizer()
  42464. {
  42465. return $this->normalizer;
  42466. }
  42467. protected function isAssoc($array)
  42468. {
  42469. return (bool) \count(array_filter(array_keys($array), 'is_string'));
  42470. }
  42471. }
  42472. <?php
  42473. namespace Symfony\Component\Console;
  42474. use Symfony\Component\Console\Exception\RuntimeException;
  42475. use Symfony\Component\Console\Input\StringInput;
  42476. use Symfony\Component\Console\Output\ConsoleOutput;
  42477. use Symfony\Component\Process\PhpExecutableFinder;
  42478. use Symfony\Component\Process\ProcessBuilder;
  42479. class Shell
  42480. {
  42481. private $application;
  42482. private $history;
  42483. private $output;
  42484. private $hasReadline;
  42485. private $processIsolation = false;
  42486. public function __construct(Application $application)
  42487. {
  42488. @trigger_error('The '.__CLASS__.' class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  42489. $this->hasReadline = \function_exists('readline');
  42490. $this->application = $application;
  42491. $this->history = getenv('HOME').'/.history_'.$application->getName();
  42492. $this->output = new ConsoleOutput();
  42493. }
  42494. public function run()
  42495. {
  42496. $this->application->setAutoExit(false);
  42497. $this->application->setCatchExceptions(true);
  42498. if ($this->hasReadline) {
  42499. readline_read_history($this->history);
  42500. readline_completion_function(array($this, 'autocompleter'));
  42501. }
  42502. $this->output->writeln($this->getHeader());
  42503. $php = null;
  42504. if ($this->processIsolation) {
  42505. $finder = new PhpExecutableFinder();
  42506. $php = $finder->find();
  42507. $this->output->writeln(<<<'EOF'
  42508. <info>Running with process isolation, you should consider this:</info>
  42509. * each command is executed as separate process,
  42510. * commands don't support interactivity, all params must be passed explicitly,
  42511. * commands output is not colorized.
  42512. EOF
  42513. );
  42514. }
  42515. while (true) {
  42516. $command = $this->readline();
  42517. if (false === $command) {
  42518. $this->output->writeln("\n");
  42519. break;
  42520. }
  42521. if ($this->hasReadline) {
  42522. readline_add_history($command);
  42523. readline_write_history($this->history);
  42524. }
  42525. if ($this->processIsolation) {
  42526. $pb = new ProcessBuilder();
  42527. $process = $pb
  42528. ->add($php)
  42529. ->add($_SERVER['argv'][0])
  42530. ->add($command)
  42531. ->inheritEnvironmentVariables(true)
  42532. ->getProcess()
  42533. ;
  42534. $output = $this->output;
  42535. $process->run(function ($type, $data) use ($output) {
  42536. $output->writeln($data);
  42537. });
  42538. $ret = $process->getExitCode();
  42539. } else {
  42540. $ret = $this->application->run(new StringInput($command), $this->output);
  42541. }
  42542. if (0 !== $ret) {
  42543. $this->output->writeln(sprintf('<error>The command terminated with an error status (%s)</error>', $ret));
  42544. }
  42545. }
  42546. }
  42547. protected function getHeader()
  42548. {
  42549. return <<<EOF
  42550. Welcome to the <info>{$this->application->getName()}</info> shell (<comment>{$this->application->getVersion()}</comment>).
  42551. At the prompt, type <comment>help</comment> for some help,
  42552. or <comment>list</comment> to get a list of available commands.
  42553. To exit the shell, type <comment>^D</comment>.
  42554. EOF;
  42555. }
  42556. protected function getPrompt()
  42557. {
  42558. return $this->output->getFormatter()->format($this->application->getName().' > ');
  42559. }
  42560. protected function getOutput()
  42561. {
  42562. return $this->output;
  42563. }
  42564. protected function getApplication()
  42565. {
  42566. return $this->application;
  42567. }
  42568. private function autocompleter($text)
  42569. {
  42570. $info = readline_info();
  42571. $text = substr($info['line_buffer'], 0, $info['end']);
  42572. if ($info['point'] !== $info['end']) {
  42573. return true;
  42574. }
  42575. if (false === strpos($text, ' ') || !$text) {
  42576. return array_keys($this->application->all());
  42577. }
  42578. try {
  42579. $command = $this->application->find(substr($text, 0, strpos($text, ' ')));
  42580. } catch (\Exception $e) {
  42581. return true;
  42582. }
  42583. $list = array('--help');
  42584. foreach ($command->getDefinition()->getOptions() as $option) {
  42585. $list[] = '--'.$option->getName();
  42586. }
  42587. return $list;
  42588. }
  42589. private function readline()
  42590. {
  42591. if ($this->hasReadline) {
  42592. $line = readline($this->getPrompt());
  42593. } else {
  42594. $this->output->write($this->getPrompt());
  42595. $line = fgets(STDIN, 1024);
  42596. $line = (false === $line || '' === $line) ? false : rtrim($line);
  42597. }
  42598. return $line;
  42599. }
  42600. public function getProcessIsolation()
  42601. {
  42602. return $this->processIsolation;
  42603. }
  42604. public function setProcessIsolation($processIsolation)
  42605. {
  42606. $this->processIsolation = (bool) $processIsolation;
  42607. if ($this->processIsolation && !class_exists('Symfony\\Component\\Process\\Process')) {
  42608. throw new RuntimeException('Unable to isolate processes as the Symfony Process Component is not installed.');
  42609. }
  42610. }
  42611. }
  42612. <?php
  42613. namespace Symfony\Component\Console\Style;
  42614. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  42615. use Symfony\Component\Console\Helper\ProgressBar;
  42616. use Symfony\Component\Console\Output\OutputInterface;
  42617. abstract class OutputStyle implements OutputInterface, StyleInterface
  42618. {
  42619. private $output;
  42620. public function __construct(OutputInterface $output)
  42621. {
  42622. $this->output = $output;
  42623. }
  42624. public function newLine($count = 1)
  42625. {
  42626. $this->output->write(str_repeat(PHP_EOL, $count));
  42627. }
  42628. public function createProgressBar($max = 0)
  42629. {
  42630. return new ProgressBar($this->output, $max);
  42631. }
  42632. public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL)
  42633. {
  42634. $this->output->write($messages, $newline, $type);
  42635. }
  42636. public function writeln($messages, $type = self::OUTPUT_NORMAL)
  42637. {
  42638. $this->output->writeln($messages, $type);
  42639. }
  42640. public function setVerbosity($level)
  42641. {
  42642. $this->output->setVerbosity($level);
  42643. }
  42644. public function getVerbosity()
  42645. {
  42646. return $this->output->getVerbosity();
  42647. }
  42648. public function setDecorated($decorated)
  42649. {
  42650. $this->output->setDecorated($decorated);
  42651. }
  42652. public function isDecorated()
  42653. {
  42654. return $this->output->isDecorated();
  42655. }
  42656. public function setFormatter(OutputFormatterInterface $formatter)
  42657. {
  42658. $this->output->setFormatter($formatter);
  42659. }
  42660. public function getFormatter()
  42661. {
  42662. return $this->output->getFormatter();
  42663. }
  42664. }
  42665. <?php
  42666. namespace Symfony\Component\Console\Style;
  42667. interface StyleInterface
  42668. {
  42669. public function title($message);
  42670. public function section($message);
  42671. public function listing(array $elements);
  42672. public function text($message);
  42673. public function success($message);
  42674. public function error($message);
  42675. public function warning($message);
  42676. public function note($message);
  42677. public function caution($message);
  42678. public function table(array $headers, array $rows);
  42679. public function ask($question, $default = null, $validator = null);
  42680. public function askHidden($question, $validator = null);
  42681. public function confirm($question, $default = true);
  42682. public function choice($question, array $choices, $default = null);
  42683. public function newLine($count = 1);
  42684. public function progressStart($max = 0);
  42685. public function progressAdvance($step = 1);
  42686. public function progressFinish();
  42687. }
  42688. <?php
  42689. namespace Symfony\Component\Console\Style;
  42690. use Symfony\Component\Console\Application;
  42691. use Symfony\Component\Console\Exception\RuntimeException;
  42692. use Symfony\Component\Console\Formatter\OutputFormatter;
  42693. use Symfony\Component\Console\Helper\Helper;
  42694. use Symfony\Component\Console\Helper\ProgressBar;
  42695. use Symfony\Component\Console\Helper\SymfonyQuestionHelper;
  42696. use Symfony\Component\Console\Helper\Table;
  42697. use Symfony\Component\Console\Input\InputInterface;
  42698. use Symfony\Component\Console\Output\BufferedOutput;
  42699. use Symfony\Component\Console\Output\OutputInterface;
  42700. use Symfony\Component\Console\Question\ChoiceQuestion;
  42701. use Symfony\Component\Console\Question\ConfirmationQuestion;
  42702. use Symfony\Component\Console\Question\Question;
  42703. class SymfonyStyle extends OutputStyle
  42704. {
  42705. const MAX_LINE_LENGTH = 120;
  42706. private $input;
  42707. private $questionHelper;
  42708. private $progressBar;
  42709. private $lineLength;
  42710. private $bufferedOutput;
  42711. public function __construct(InputInterface $input, OutputInterface $output)
  42712. {
  42713. $this->input = $input;
  42714. $this->bufferedOutput = new BufferedOutput($output->getVerbosity(), false, clone $output->getFormatter());
  42715. $this->lineLength = min($this->getTerminalWidth() - (int) (\DIRECTORY_SEPARATOR === '\\'), self::MAX_LINE_LENGTH);
  42716. parent::__construct($output);
  42717. }
  42718. public function block($messages, $type = null, $style = null, $prefix = ' ', $padding = false)
  42719. {
  42720. $messages = \is_array($messages) ? array_values($messages) : array($messages);
  42721. $this->autoPrependBlock();
  42722. $this->writeln($this->createBlock($messages, $type, $style, $prefix, $padding, true));
  42723. $this->newLine();
  42724. }
  42725. public function title($message)
  42726. {
  42727. $this->autoPrependBlock();
  42728. $this->writeln(array(
  42729. sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
  42730. sprintf('<comment>%s</>', str_repeat('=', Helper::strlenWithoutDecoration($this->getFormatter(), $message))),
  42731. ));
  42732. $this->newLine();
  42733. }
  42734. public function section($message)
  42735. {
  42736. $this->autoPrependBlock();
  42737. $this->writeln(array(
  42738. sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
  42739. sprintf('<comment>%s</>', str_repeat('-', Helper::strlenWithoutDecoration($this->getFormatter(), $message))),
  42740. ));
  42741. $this->newLine();
  42742. }
  42743. public function listing(array $elements)
  42744. {
  42745. $this->autoPrependText();
  42746. $elements = array_map(function ($element) {
  42747. return sprintf(' * %s', $element);
  42748. }, $elements);
  42749. $this->writeln($elements);
  42750. $this->newLine();
  42751. }
  42752. public function text($message)
  42753. {
  42754. $this->autoPrependText();
  42755. $messages = \is_array($message) ? array_values($message) : array($message);
  42756. foreach ($messages as $message) {
  42757. $this->writeln(sprintf(' %s', $message));
  42758. }
  42759. }
  42760. public function comment($message)
  42761. {
  42762. $messages = \is_array($message) ? array_values($message) : array($message);
  42763. $this->autoPrependBlock();
  42764. $this->writeln($this->createBlock($messages, null, null, '<fg=default;bg=default> // </>'));
  42765. $this->newLine();
  42766. }
  42767. public function success($message)
  42768. {
  42769. $this->block($message, 'OK', 'fg=black;bg=green', ' ', true);
  42770. }
  42771. public function error($message)
  42772. {
  42773. $this->block($message, 'ERROR', 'fg=white;bg=red', ' ', true);
  42774. }
  42775. public function warning($message)
  42776. {
  42777. $this->block($message, 'WARNING', 'fg=white;bg=red', ' ', true);
  42778. }
  42779. public function note($message)
  42780. {
  42781. $this->block($message, 'NOTE', 'fg=yellow', ' ! ');
  42782. }
  42783. public function caution($message)
  42784. {
  42785. $this->block($message, 'CAUTION', 'fg=white;bg=red', ' ! ', true);
  42786. }
  42787. public function table(array $headers, array $rows)
  42788. {
  42789. $style = clone Table::getStyleDefinition('symfony-style-guide');
  42790. $style->setCellHeaderFormat('<info>%s</info>');
  42791. $table = new Table($this);
  42792. $table->setHeaders($headers);
  42793. $table->setRows($rows);
  42794. $table->setStyle($style);
  42795. $table->render();
  42796. $this->newLine();
  42797. }
  42798. public function ask($question, $default = null, $validator = null)
  42799. {
  42800. $question = new Question($question, $default);
  42801. $question->setValidator($validator);
  42802. return $this->askQuestion($question);
  42803. }
  42804. public function askHidden($question, $validator = null)
  42805. {
  42806. $question = new Question($question);
  42807. $question->setHidden(true);
  42808. $question->setValidator($validator);
  42809. return $this->askQuestion($question);
  42810. }
  42811. public function confirm($question, $default = true)
  42812. {
  42813. return $this->askQuestion(new ConfirmationQuestion($question, $default));
  42814. }
  42815. public function choice($question, array $choices, $default = null)
  42816. {
  42817. if (null !== $default) {
  42818. $values = array_flip($choices);
  42819. $default = $values[$default];
  42820. }
  42821. return $this->askQuestion(new ChoiceQuestion($question, $choices, $default));
  42822. }
  42823. public function progressStart($max = 0)
  42824. {
  42825. $this->progressBar = $this->createProgressBar($max);
  42826. $this->progressBar->start();
  42827. }
  42828. public function progressAdvance($step = 1)
  42829. {
  42830. $this->getProgressBar()->advance($step);
  42831. }
  42832. public function progressFinish()
  42833. {
  42834. $this->getProgressBar()->finish();
  42835. $this->newLine(2);
  42836. $this->progressBar = null;
  42837. }
  42838. public function createProgressBar($max = 0)
  42839. {
  42840. $progressBar = parent::createProgressBar($max);
  42841. if ('\\' !== \DIRECTORY_SEPARATOR || 'Hyper' === getenv('TERM_PROGRAM')) {
  42842. $progressBar->setEmptyBarCharacter('â–‘');
  42843. $progressBar->setProgressCharacter('');
  42844. $progressBar->setBarCharacter('â–“');
  42845. }
  42846. return $progressBar;
  42847. }
  42848. public function askQuestion(Question $question)
  42849. {
  42850. if ($this->input->isInteractive()) {
  42851. $this->autoPrependBlock();
  42852. }
  42853. if (!$this->questionHelper) {
  42854. $this->questionHelper = new SymfonyQuestionHelper();
  42855. }
  42856. $answer = $this->questionHelper->ask($this->input, $this, $question);
  42857. if ($this->input->isInteractive()) {
  42858. $this->newLine();
  42859. $this->bufferedOutput->write("\n");
  42860. }
  42861. return $answer;
  42862. }
  42863. public function writeln($messages, $type = self::OUTPUT_NORMAL)
  42864. {
  42865. parent::writeln($messages, $type);
  42866. $this->bufferedOutput->writeln($this->reduceBuffer($messages), $type);
  42867. }
  42868. public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL)
  42869. {
  42870. parent::write($messages, $newline, $type);
  42871. $this->bufferedOutput->write($this->reduceBuffer($messages), $newline, $type);
  42872. }
  42873. public function newLine($count = 1)
  42874. {
  42875. parent::newLine($count);
  42876. $this->bufferedOutput->write(str_repeat("\n", $count));
  42877. }
  42878. private function getProgressBar()
  42879. {
  42880. if (!$this->progressBar) {
  42881. throw new RuntimeException('The ProgressBar is not started.');
  42882. }
  42883. return $this->progressBar;
  42884. }
  42885. private function getTerminalWidth()
  42886. {
  42887. $application = new Application();
  42888. $dimensions = $application->getTerminalDimensions();
  42889. return $dimensions[0] ?: self::MAX_LINE_LENGTH;
  42890. }
  42891. private function autoPrependBlock()
  42892. {
  42893. $chars = substr(str_replace(PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2);
  42894. if (!isset($chars[0])) {
  42895. return $this->newLine();
  42896. }
  42897. $this->newLine(2 - substr_count($chars, "\n"));
  42898. }
  42899. private function autoPrependText()
  42900. {
  42901. $fetched = $this->bufferedOutput->fetch();
  42902. if ("\n" !== substr($fetched, -1)) {
  42903. $this->newLine();
  42904. }
  42905. }
  42906. private function reduceBuffer($messages)
  42907. {
  42908. return array_map(function ($value) {
  42909. return substr($value, -4);
  42910. }, array_merge(array($this->bufferedOutput->fetch()), (array) $messages));
  42911. }
  42912. private function createBlock($messages, $type = null, $style = null, $prefix = ' ', $padding = false, $escape = false)
  42913. {
  42914. $indentLength = 0;
  42915. $prefixLength = Helper::strlenWithoutDecoration($this->getFormatter(), $prefix);
  42916. $lines = array();
  42917. if (null !== $type) {
  42918. $type = sprintf('[%s] ', $type);
  42919. $indentLength = \strlen($type);
  42920. $lineIndentation = str_repeat(' ', $indentLength);
  42921. }
  42922. foreach ($messages as $key => $message) {
  42923. if ($escape) {
  42924. $message = OutputFormatter::escape($message);
  42925. }
  42926. $lines = array_merge($lines, explode(PHP_EOL, wordwrap($message, $this->lineLength - $prefixLength - $indentLength, PHP_EOL, true)));
  42927. if (\count($messages) > 1 && $key < \count($messages) - 1) {
  42928. $lines[] = '';
  42929. }
  42930. }
  42931. $firstLineIndex = 0;
  42932. if ($padding && $this->isDecorated()) {
  42933. $firstLineIndex = 1;
  42934. array_unshift($lines, '');
  42935. $lines[] = '';
  42936. }
  42937. foreach ($lines as $i => &$line) {
  42938. if (null !== $type) {
  42939. $line = $firstLineIndex === $i ? $type.$line : $lineIndentation.$line;
  42940. }
  42941. $line = $prefix.$line;
  42942. $line .= str_repeat(' ', $this->lineLength - Helper::strlenWithoutDecoration($this->getFormatter(), $line));
  42943. if ($style) {
  42944. $line = sprintf('<%s>%s</>', $style, $line);
  42945. }
  42946. }
  42947. return $lines;
  42948. }
  42949. }
  42950. <?php
  42951. namespace Symfony\Component\Console\Tester;
  42952. use Symfony\Component\Console\Application;
  42953. use Symfony\Component\Console\Input\ArrayInput;
  42954. use Symfony\Component\Console\Input\InputInterface;
  42955. use Symfony\Component\Console\Output\OutputInterface;
  42956. use Symfony\Component\Console\Output\StreamOutput;
  42957. class ApplicationTester
  42958. {
  42959. private $application;
  42960. private $input;
  42961. private $output;
  42962. private $statusCode;
  42963. public function __construct(Application $application)
  42964. {
  42965. $this->application = $application;
  42966. }
  42967. public function run(array $input, $options = array())
  42968. {
  42969. $this->input = new ArrayInput($input);
  42970. if (isset($options['interactive'])) {
  42971. $this->input->setInteractive($options['interactive']);
  42972. }
  42973. $this->output = new StreamOutput(fopen('php://memory', 'w', false));
  42974. if (isset($options['decorated'])) {
  42975. $this->output->setDecorated($options['decorated']);
  42976. }
  42977. if (isset($options['verbosity'])) {
  42978. $this->output->setVerbosity($options['verbosity']);
  42979. }
  42980. return $this->statusCode = $this->application->run($this->input, $this->output);
  42981. }
  42982. public function getDisplay($normalize = false)
  42983. {
  42984. rewind($this->output->getStream());
  42985. $display = stream_get_contents($this->output->getStream());
  42986. if ($normalize) {
  42987. $display = str_replace(PHP_EOL, "\n", $display);
  42988. }
  42989. return $display;
  42990. }
  42991. public function getInput()
  42992. {
  42993. return $this->input;
  42994. }
  42995. public function getOutput()
  42996. {
  42997. return $this->output;
  42998. }
  42999. public function getStatusCode()
  43000. {
  43001. return $this->statusCode;
  43002. }
  43003. }
  43004. <?php
  43005. namespace Symfony\Component\Console\Tester;
  43006. use Symfony\Component\Console\Command\Command;
  43007. use Symfony\Component\Console\Input\ArrayInput;
  43008. use Symfony\Component\Console\Input\InputInterface;
  43009. use Symfony\Component\Console\Output\OutputInterface;
  43010. use Symfony\Component\Console\Output\StreamOutput;
  43011. class CommandTester
  43012. {
  43013. private $command;
  43014. private $input;
  43015. private $output;
  43016. private $statusCode;
  43017. public function __construct(Command $command)
  43018. {
  43019. $this->command = $command;
  43020. }
  43021. public function execute(array $input, array $options = array())
  43022. {
  43023. if (!isset($input['command'])
  43024. && (null !== $application = $this->command->getApplication())
  43025. && $application->getDefinition()->hasArgument('command')
  43026. ) {
  43027. $input = array_merge(array('command' => $this->command->getName()), $input);
  43028. }
  43029. $this->input = new ArrayInput($input);
  43030. if (isset($options['interactive'])) {
  43031. $this->input->setInteractive($options['interactive']);
  43032. }
  43033. $this->output = new StreamOutput(fopen('php://memory', 'w', false));
  43034. $this->output->setDecorated(isset($options['decorated']) ? $options['decorated'] : false);
  43035. if (isset($options['verbosity'])) {
  43036. $this->output->setVerbosity($options['verbosity']);
  43037. }
  43038. return $this->statusCode = $this->command->run($this->input, $this->output);
  43039. }
  43040. public function getDisplay($normalize = false)
  43041. {
  43042. rewind($this->output->getStream());
  43043. $display = stream_get_contents($this->output->getStream());
  43044. if ($normalize) {
  43045. $display = str_replace(PHP_EOL, "\n", $display);
  43046. }
  43047. return $display;
  43048. }
  43049. public function getInput()
  43050. {
  43051. return $this->input;
  43052. }
  43053. public function getOutput()
  43054. {
  43055. return $this->output;
  43056. }
  43057. public function getStatusCode()
  43058. {
  43059. return $this->statusCode;
  43060. }
  43061. }
  43062. <?php
  43063. namespace Symfony\Component\Debug;
  43064. use Psr\Log\AbstractLogger;
  43065. class BufferingLogger extends AbstractLogger
  43066. {
  43067. private $logs = array();
  43068. public function log($level, $message, array $context = array())
  43069. {
  43070. $this->logs[] = array($level, $message, $context);
  43071. }
  43072. public function cleanLogs()
  43073. {
  43074. $logs = $this->logs;
  43075. $this->logs = array();
  43076. return $logs;
  43077. }
  43078. }
  43079. <?php
  43080. namespace Symfony\Component\Debug;
  43081. class Debug
  43082. {
  43083. private static $enabled = false;
  43084. public static function enable($errorReportingLevel = null, $displayErrors = true)
  43085. {
  43086. if (static::$enabled) {
  43087. return;
  43088. }
  43089. static::$enabled = true;
  43090. if (null !== $errorReportingLevel) {
  43091. error_reporting($errorReportingLevel);
  43092. } else {
  43093. error_reporting(-1);
  43094. }
  43095. if (!\in_array(\PHP_SAPI, array('cli', 'phpdbg'), true)) {
  43096. ini_set('display_errors', 0);
  43097. ExceptionHandler::register();
  43098. } elseif ($displayErrors && (!filter_var(ini_get('log_errors'), FILTER_VALIDATE_BOOLEAN) || ini_get('error_log'))) {
  43099. ini_set('display_errors', 1);
  43100. }
  43101. if ($displayErrors) {
  43102. ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
  43103. } else {
  43104. ErrorHandler::register()->throwAt(0, true);
  43105. }
  43106. DebugClassLoader::enable();
  43107. }
  43108. }
  43109. <?php
  43110. namespace Symfony\Component\Debug;
  43111. class DebugClassLoader
  43112. {
  43113. private $classLoader;
  43114. private $isFinder;
  43115. private $loaded = array();
  43116. private $wasFinder;
  43117. private static $caseCheck;
  43118. private static $deprecated = array();
  43119. private static $php7Reserved = array('int', 'float', 'bool', 'string', 'true', 'false', 'null');
  43120. private static $darwinCache = array('/' => array('/', array()));
  43121. public function __construct($classLoader)
  43122. {
  43123. $this->wasFinder = \is_object($classLoader) && method_exists($classLoader, 'findFile');
  43124. if ($this->wasFinder) {
  43125. @trigger_error('The '.__METHOD__.' method will no longer support receiving an object into its $classLoader argument in 3.0.', E_USER_DEPRECATED);
  43126. $this->classLoader = array($classLoader, 'loadClass');
  43127. $this->isFinder = true;
  43128. } else {
  43129. $this->classLoader = $classLoader;
  43130. $this->isFinder = \is_array($classLoader) && method_exists($classLoader[0], 'findFile');
  43131. }
  43132. if (!isset(self::$caseCheck)) {
  43133. $file = file_exists(__FILE__) ? __FILE__ : rtrim(realpath('.'), \DIRECTORY_SEPARATOR);
  43134. $i = strrpos($file, \DIRECTORY_SEPARATOR);
  43135. $dir = substr($file, 0, 1 + $i);
  43136. $file = substr($file, 1 + $i);
  43137. $test = strtoupper($file) === $file ? strtolower($file) : strtoupper($file);
  43138. $test = realpath($dir.$test);
  43139. if (false === $test || false === $i) {
  43140. self::$caseCheck = 0;
  43141. } elseif (substr($test, -\strlen($file)) === $file) {
  43142. self::$caseCheck = 1;
  43143. } elseif (false !== stripos(PHP_OS, 'darwin')) {
  43144. self::$caseCheck = 2;
  43145. } else {
  43146. self::$caseCheck = 0;
  43147. }
  43148. }
  43149. }
  43150. public function getClassLoader()
  43151. {
  43152. return $this->wasFinder ? $this->classLoader[0] : $this->classLoader;
  43153. }
  43154. public static function enable()
  43155. {
  43156. class_exists('Symfony\Component\Debug\ErrorHandler');
  43157. class_exists('Psr\Log\LogLevel');
  43158. if (!\is_array($functions = spl_autoload_functions())) {
  43159. return;
  43160. }
  43161. foreach ($functions as $function) {
  43162. spl_autoload_unregister($function);
  43163. }
  43164. foreach ($functions as $function) {
  43165. if (!\is_array($function) || !$function[0] instanceof self) {
  43166. $function = array(new static($function), 'loadClass');
  43167. }
  43168. spl_autoload_register($function);
  43169. }
  43170. }
  43171. public static function disable()
  43172. {
  43173. if (!\is_array($functions = spl_autoload_functions())) {
  43174. return;
  43175. }
  43176. foreach ($functions as $function) {
  43177. spl_autoload_unregister($function);
  43178. }
  43179. foreach ($functions as $function) {
  43180. if (\is_array($function) && $function[0] instanceof self) {
  43181. $function = $function[0]->getClassLoader();
  43182. }
  43183. spl_autoload_register($function);
  43184. }
  43185. }
  43186. public function findFile($class)
  43187. {
  43188. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  43189. if ($this->wasFinder) {
  43190. return $this->classLoader[0]->findFile($class);
  43191. }
  43192. }
  43193. public function loadClass($class)
  43194. {
  43195. ErrorHandler::stackErrors();
  43196. try {
  43197. if ($this->isFinder && !isset($this->loaded[$class])) {
  43198. $this->loaded[$class] = true;
  43199. if ($file = $this->classLoader[0]->findFile($class)) {
  43200. require $file;
  43201. }
  43202. } else {
  43203. \call_user_func($this->classLoader, $class);
  43204. $file = false;
  43205. }
  43206. } catch (\Exception $e) {
  43207. ErrorHandler::unstackErrors();
  43208. throw $e;
  43209. } catch (\Throwable $e) {
  43210. ErrorHandler::unstackErrors();
  43211. throw $e;
  43212. }
  43213. ErrorHandler::unstackErrors();
  43214. $exists = class_exists($class, false) || interface_exists($class, false) || (\function_exists('trait_exists') && trait_exists($class, false));
  43215. if ($class && '\\' === $class[0]) {
  43216. $class = substr($class, 1);
  43217. }
  43218. if ($exists) {
  43219. $refl = new \ReflectionClass($class);
  43220. $name = $refl->getName();
  43221. if ($name !== $class && 0 === strcasecmp($name, $class)) {
  43222. throw new \RuntimeException(sprintf('Case mismatch between loaded and declared class names: %s vs %s', $class, $name));
  43223. }
  43224. if (\in_array(strtolower($refl->getShortName()), self::$php7Reserved)) {
  43225. @trigger_error(sprintf('%s uses a reserved class name (%s) that will break on PHP 7 and higher', $name, $refl->getShortName()), E_USER_DEPRECATED);
  43226. } elseif (preg_match('#\n \* @deprecated (.*?)\r?\n \*(?: @|/$)#s', $refl->getDocComment(), $notice)) {
  43227. self::$deprecated[$name] = preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]);
  43228. } else {
  43229. if (2 > $len = 1 + (strpos($name, '\\') ?: strpos($name, '_'))) {
  43230. $len = 0;
  43231. $ns = '';
  43232. } else {
  43233. $ns = substr($name, 0, $len);
  43234. }
  43235. $parent = get_parent_class($class);
  43236. if (!$parent || strncmp($ns, $parent, $len)) {
  43237. if ($parent && isset(self::$deprecated[$parent]) && strncmp($ns, $parent, $len)) {
  43238. @trigger_error(sprintf('The %s class extends %s that is deprecated %s', $name, $parent, self::$deprecated[$parent]), E_USER_DEPRECATED);
  43239. }
  43240. $parentInterfaces = array();
  43241. $deprecatedInterfaces = array();
  43242. if ($parent) {
  43243. foreach (class_implements($parent) as $interface) {
  43244. $parentInterfaces[$interface] = 1;
  43245. }
  43246. }
  43247. foreach ($refl->getInterfaceNames() as $interface) {
  43248. if (isset(self::$deprecated[$interface]) && strncmp($ns, $interface, $len)) {
  43249. $deprecatedInterfaces[] = $interface;
  43250. }
  43251. foreach (class_implements($interface) as $interface) {
  43252. $parentInterfaces[$interface] = 1;
  43253. }
  43254. }
  43255. foreach ($deprecatedInterfaces as $interface) {
  43256. if (!isset($parentInterfaces[$interface])) {
  43257. @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);
  43258. }
  43259. }
  43260. }
  43261. }
  43262. }
  43263. if ($file) {
  43264. if (!$exists) {
  43265. if (false !== strpos($class, '/')) {
  43266. 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));
  43267. }
  43268. 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));
  43269. }
  43270. if (self::$caseCheck) {
  43271. $real = explode('\\', $class.strrchr($file, '.'));
  43272. $tail = explode(\DIRECTORY_SEPARATOR, str_replace('/', \DIRECTORY_SEPARATOR, $file));
  43273. $i = \count($tail) - 1;
  43274. $j = \count($real) - 1;
  43275. while (isset($tail[$i], $real[$j]) && $tail[$i] === $real[$j]) {
  43276. --$i;
  43277. --$j;
  43278. }
  43279. array_splice($tail, 0, $i + 1);
  43280. }
  43281. if (self::$caseCheck && $tail) {
  43282. $tail = \DIRECTORY_SEPARATOR.implode(\DIRECTORY_SEPARATOR, $tail);
  43283. $tailLen = \strlen($tail);
  43284. $real = $refl->getFileName();
  43285. if (2 === self::$caseCheck) {
  43286. $i = 1 + strrpos($real, '/');
  43287. $file = substr($real, $i);
  43288. $real = substr($real, 0, $i);
  43289. if (isset(self::$darwinCache[$real])) {
  43290. $kDir = $real;
  43291. } else {
  43292. $kDir = strtolower($real);
  43293. if (isset(self::$darwinCache[$kDir])) {
  43294. $real = self::$darwinCache[$kDir][0];
  43295. } else {
  43296. $dir = getcwd();
  43297. chdir($real);
  43298. $real = getcwd().'/';
  43299. chdir($dir);
  43300. $dir = $real;
  43301. $k = $kDir;
  43302. $i = \strlen($dir) - 1;
  43303. while (!isset(self::$darwinCache[$k])) {
  43304. self::$darwinCache[$k] = array($dir, array());
  43305. self::$darwinCache[$dir] = &self::$darwinCache[$k];
  43306. while ('/' !== $dir[--$i]) {
  43307. }
  43308. $k = substr($k, 0, ++$i);
  43309. $dir = substr($dir, 0, $i--);
  43310. }
  43311. }
  43312. }
  43313. $dirFiles = self::$darwinCache[$kDir][1];
  43314. if (isset($dirFiles[$file])) {
  43315. $kFile = $file;
  43316. } else {
  43317. $kFile = strtolower($file);
  43318. if (!isset($dirFiles[$kFile])) {
  43319. foreach (scandir($real, 2) as $f) {
  43320. if ('.' !== $f[0]) {
  43321. $dirFiles[$f] = $f;
  43322. if ($f === $file) {
  43323. $kFile = $k = $file;
  43324. } elseif ($f !== $k = strtolower($f)) {
  43325. $dirFiles[$k] = $f;
  43326. }
  43327. }
  43328. }
  43329. self::$darwinCache[$kDir][1] = $dirFiles;
  43330. }
  43331. }
  43332. $real .= $dirFiles[$kFile];
  43333. }
  43334. if (0 === substr_compare($real, $tail, -$tailLen, $tailLen, true)
  43335. && 0 !== substr_compare($real, $tail, -$tailLen, $tailLen, false)
  43336. ) {
  43337. 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)));
  43338. }
  43339. }
  43340. return true;
  43341. }
  43342. }
  43343. }
  43344. <?php
  43345. namespace Symfony\Component\Debug;
  43346. use Psr\Log\LoggerInterface;
  43347. use Psr\Log\LogLevel;
  43348. use Symfony\Component\Debug\Exception\ContextErrorException;
  43349. use Symfony\Component\Debug\Exception\FatalErrorException;
  43350. use Symfony\Component\Debug\Exception\FatalThrowableError;
  43351. use Symfony\Component\Debug\Exception\OutOfMemoryException;
  43352. use Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler;
  43353. use Symfony\Component\Debug\FatalErrorHandler\FatalErrorHandlerInterface;
  43354. use Symfony\Component\Debug\FatalErrorHandler\UndefinedFunctionFatalErrorHandler;
  43355. use Symfony\Component\Debug\FatalErrorHandler\UndefinedMethodFatalErrorHandler;
  43356. class ErrorHandler
  43357. {
  43358. const TYPE_DEPRECATION = -100;
  43359. private $levels = array(
  43360. E_DEPRECATED => 'Deprecated',
  43361. E_USER_DEPRECATED => 'User Deprecated',
  43362. E_NOTICE => 'Notice',
  43363. E_USER_NOTICE => 'User Notice',
  43364. E_STRICT => 'Runtime Notice',
  43365. E_WARNING => 'Warning',
  43366. E_USER_WARNING => 'User Warning',
  43367. E_COMPILE_WARNING => 'Compile Warning',
  43368. E_CORE_WARNING => 'Core Warning',
  43369. E_USER_ERROR => 'User Error',
  43370. E_RECOVERABLE_ERROR => 'Catchable Fatal Error',
  43371. E_COMPILE_ERROR => 'Compile Error',
  43372. E_PARSE => 'Parse Error',
  43373. E_ERROR => 'Error',
  43374. E_CORE_ERROR => 'Core Error',
  43375. );
  43376. private $loggers = array(
  43377. E_DEPRECATED => array(null, LogLevel::INFO),
  43378. E_USER_DEPRECATED => array(null, LogLevel::INFO),
  43379. E_NOTICE => array(null, LogLevel::WARNING),
  43380. E_USER_NOTICE => array(null, LogLevel::WARNING),
  43381. E_STRICT => array(null, LogLevel::WARNING),
  43382. E_WARNING => array(null, LogLevel::WARNING),
  43383. E_USER_WARNING => array(null, LogLevel::WARNING),
  43384. E_COMPILE_WARNING => array(null, LogLevel::WARNING),
  43385. E_CORE_WARNING => array(null, LogLevel::WARNING),
  43386. E_USER_ERROR => array(null, LogLevel::CRITICAL),
  43387. E_RECOVERABLE_ERROR => array(null, LogLevel::CRITICAL),
  43388. E_COMPILE_ERROR => array(null, LogLevel::CRITICAL),
  43389. E_PARSE => array(null, LogLevel::CRITICAL),
  43390. E_ERROR => array(null, LogLevel::CRITICAL),
  43391. E_CORE_ERROR => array(null, LogLevel::CRITICAL),
  43392. );
  43393. private $thrownErrors = 0x1FFF;
  43394. private $scopedErrors = 0x1FFF;
  43395. private $tracedErrors = 0x77FB;
  43396. private $screamedErrors = 0x55;
  43397. private $loggedErrors = 0;
  43398. private $loggedTraces = array();
  43399. private $isRecursive = 0;
  43400. private $isRoot = false;
  43401. private $exceptionHandler;
  43402. private $bootstrappingLogger;
  43403. private static $reservedMemory;
  43404. private static $stackedErrors = array();
  43405. private static $stackedErrorLevels = array();
  43406. private static $toStringException = null;
  43407. private static $exitCode = 0;
  43408. private $displayErrors = 0x1FFF;
  43409. public static function register($handler = null, $replace = true)
  43410. {
  43411. if (null === self::$reservedMemory) {
  43412. self::$reservedMemory = str_repeat('x', 10240);
  43413. register_shutdown_function(__CLASS__.'::handleFatalError');
  43414. }
  43415. $levels = -1;
  43416. if ($handlerIsNew = !$handler instanceof self) {
  43417. if (null !== $handler) {
  43418. $levels = $replace ? $handler : 0;
  43419. $replace = true;
  43420. }
  43421. $handler = new static();
  43422. }
  43423. if (null === $prev = set_error_handler(array($handler, 'handleError'))) {
  43424. restore_error_handler();
  43425. set_error_handler(array($handler, 'handleError'), $handler->thrownErrors | $handler->loggedErrors);
  43426. $handler->isRoot = true;
  43427. }
  43428. if ($handlerIsNew && \is_array($prev) && $prev[0] instanceof self) {
  43429. $handler = $prev[0];
  43430. $replace = false;
  43431. }
  43432. if (!$replace && $prev) {
  43433. restore_error_handler();
  43434. $handlerIsRegistered = \is_array($prev) && $handler === $prev[0];
  43435. } else {
  43436. $handlerIsRegistered = true;
  43437. }
  43438. if (\is_array($prev = set_exception_handler(array($handler, 'handleException'))) && $prev[0] instanceof self) {
  43439. restore_exception_handler();
  43440. if (!$handlerIsRegistered) {
  43441. $handler = $prev[0];
  43442. } elseif ($handler !== $prev[0] && $replace) {
  43443. set_exception_handler(array($handler, 'handleException'));
  43444. $p = $prev[0]->setExceptionHandler(null);
  43445. $handler->setExceptionHandler($p);
  43446. $prev[0]->setExceptionHandler($p);
  43447. }
  43448. } else {
  43449. $handler->setExceptionHandler($prev);
  43450. }
  43451. $handler->throwAt($levels & $handler->thrownErrors, true);
  43452. return $handler;
  43453. }
  43454. public function __construct(BufferingLogger $bootstrappingLogger = null)
  43455. {
  43456. if ($bootstrappingLogger) {
  43457. $this->bootstrappingLogger = $bootstrappingLogger;
  43458. $this->setDefaultLogger($bootstrappingLogger);
  43459. }
  43460. }
  43461. public function setDefaultLogger(LoggerInterface $logger, $levels = null, $replace = false)
  43462. {
  43463. $loggers = array();
  43464. if (\is_array($levels)) {
  43465. foreach ($levels as $type => $logLevel) {
  43466. if (empty($this->loggers[$type][0]) || $replace || $this->loggers[$type][0] === $this->bootstrappingLogger) {
  43467. $loggers[$type] = array($logger, $logLevel);
  43468. }
  43469. }
  43470. } else {
  43471. if (null === $levels) {
  43472. $levels = E_ALL | E_STRICT;
  43473. }
  43474. foreach ($this->loggers as $type => $log) {
  43475. if (($type & $levels) && (empty($log[0]) || $replace || $log[0] === $this->bootstrappingLogger)) {
  43476. $log[0] = $logger;
  43477. $loggers[$type] = $log;
  43478. }
  43479. }
  43480. }
  43481. $this->setLoggers($loggers);
  43482. }
  43483. public function setLoggers(array $loggers)
  43484. {
  43485. $prevLogged = $this->loggedErrors;
  43486. $prev = $this->loggers;
  43487. $flush = array();
  43488. foreach ($loggers as $type => $log) {
  43489. if (!isset($prev[$type])) {
  43490. throw new \InvalidArgumentException('Unknown error type: '.$type);
  43491. }
  43492. if (!\is_array($log)) {
  43493. $log = array($log);
  43494. } elseif (!array_key_exists(0, $log)) {
  43495. throw new \InvalidArgumentException('No logger provided');
  43496. }
  43497. if (null === $log[0]) {
  43498. $this->loggedErrors &= ~$type;
  43499. } elseif ($log[0] instanceof LoggerInterface) {
  43500. $this->loggedErrors |= $type;
  43501. } else {
  43502. throw new \InvalidArgumentException('Invalid logger provided');
  43503. }
  43504. $this->loggers[$type] = $log + $prev[$type];
  43505. if ($this->bootstrappingLogger && $prev[$type][0] === $this->bootstrappingLogger) {
  43506. $flush[$type] = $type;
  43507. }
  43508. }
  43509. $this->reRegister($prevLogged | $this->thrownErrors);
  43510. if ($flush) {
  43511. foreach ($this->bootstrappingLogger->cleanLogs() as $log) {
  43512. $type = $log[2]['type'];
  43513. if (!isset($flush[$type])) {
  43514. $this->bootstrappingLogger->log($log[0], $log[1], $log[2]);
  43515. } elseif ($this->loggers[$type][0]) {
  43516. $this->loggers[$type][0]->log($this->loggers[$type][1], $log[1], $log[2]);
  43517. }
  43518. }
  43519. }
  43520. return $prev;
  43521. }
  43522. public function setExceptionHandler($handler)
  43523. {
  43524. if (null !== $handler && !\is_callable($handler)) {
  43525. throw new \LogicException('The exception handler must be a valid PHP callable.');
  43526. }
  43527. $prev = $this->exceptionHandler;
  43528. $this->exceptionHandler = $handler;
  43529. return $prev;
  43530. }
  43531. public function throwAt($levels, $replace = false)
  43532. {
  43533. $prev = $this->thrownErrors;
  43534. $this->thrownErrors = ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED;
  43535. if (!$replace) {
  43536. $this->thrownErrors |= $prev;
  43537. }
  43538. $this->reRegister($prev | $this->loggedErrors);
  43539. $this->displayErrors = $this->thrownErrors;
  43540. return $prev;
  43541. }
  43542. public function scopeAt($levels, $replace = false)
  43543. {
  43544. $prev = $this->scopedErrors;
  43545. $this->scopedErrors = (int) $levels;
  43546. if (!$replace) {
  43547. $this->scopedErrors |= $prev;
  43548. }
  43549. return $prev;
  43550. }
  43551. public function traceAt($levels, $replace = false)
  43552. {
  43553. $prev = $this->tracedErrors;
  43554. $this->tracedErrors = (int) $levels;
  43555. if (!$replace) {
  43556. $this->tracedErrors |= $prev;
  43557. }
  43558. return $prev;
  43559. }
  43560. public function screamAt($levels, $replace = false)
  43561. {
  43562. $prev = $this->screamedErrors;
  43563. $this->screamedErrors = (int) $levels;
  43564. if (!$replace) {
  43565. $this->screamedErrors |= $prev;
  43566. }
  43567. return $prev;
  43568. }
  43569. private function reRegister($prev)
  43570. {
  43571. if ($prev !== $this->thrownErrors | $this->loggedErrors) {
  43572. $handler = set_error_handler('var_dump');
  43573. $handler = \is_array($handler) ? $handler[0] : null;
  43574. restore_error_handler();
  43575. if ($handler === $this) {
  43576. restore_error_handler();
  43577. if ($this->isRoot) {
  43578. set_error_handler(array($this, 'handleError'), $this->thrownErrors | $this->loggedErrors);
  43579. } else {
  43580. set_error_handler(array($this, 'handleError'));
  43581. }
  43582. }
  43583. }
  43584. }
  43585. public function handleError($type, $message, $file, $line)
  43586. {
  43587. $level = error_reporting();
  43588. $silenced = 0 === ($level & $type);
  43589. $level |= E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED;
  43590. $log = $this->loggedErrors & $type;
  43591. $throw = $this->thrownErrors & $type & $level;
  43592. $type &= $level | $this->screamedErrors;
  43593. if (!$type || (!$log && !$throw)) {
  43594. return !$silenced && $type && $log;
  43595. }
  43596. $scope = $this->scopedErrors & $type;
  43597. if (4 < $numArgs = \func_num_args()) {
  43598. $context = $scope ? (func_get_arg(4) ?: array()) : array();
  43599. $backtrace = 5 < $numArgs ? func_get_arg(5) : null;
  43600. } else {
  43601. $context = array();
  43602. $backtrace = null;
  43603. }
  43604. if (isset($context['GLOBALS']) && $scope) {
  43605. $e = $context;
  43606. unset($e['GLOBALS'], $context);
  43607. $context = $e;
  43608. }
  43609. if (null !== $backtrace && $type & E_ERROR) {
  43610. $this->handleFatalError(compact('type', 'message', 'file', 'line', 'backtrace'));
  43611. return true;
  43612. }
  43613. if ($throw) {
  43614. if (null !== self::$toStringException) {
  43615. $throw = self::$toStringException;
  43616. self::$toStringException = null;
  43617. } elseif ($scope && class_exists('Symfony\Component\Debug\Exception\ContextErrorException')) {
  43618. $throw = new ContextErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line, $context);
  43619. } else {
  43620. $throw = new \ErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line);
  43621. }
  43622. if (\PHP_VERSION_ID <= 50407 && (\PHP_VERSION_ID >= 50400 || \PHP_VERSION_ID <= 50317)) {
  43623. $throw->errorHandlerCanary = new ErrorHandlerCanary();
  43624. }
  43625. if (E_USER_ERROR & $type) {
  43626. $backtrace = $backtrace ?: $throw->getTrace();
  43627. for ($i = 1; isset($backtrace[$i]); ++$i) {
  43628. if (isset($backtrace[$i]['function'], $backtrace[$i]['type'], $backtrace[$i - 1]['function'])
  43629. && '__toString' === $backtrace[$i]['function']
  43630. && '->' === $backtrace[$i]['type']
  43631. && !isset($backtrace[$i - 1]['class'])
  43632. && ('trigger_error' === $backtrace[$i - 1]['function'] || 'user_error' === $backtrace[$i - 1]['function'])
  43633. ) {
  43634. foreach ($context as $e) {
  43635. if (($e instanceof \Exception || $e instanceof \Throwable) && $e->__toString() === $message) {
  43636. if (1 === $i) {
  43637. $throw = $e;
  43638. break;
  43639. }
  43640. self::$toStringException = $e;
  43641. return true;
  43642. }
  43643. }
  43644. if (1 < $i) {
  43645. $this->handleException($throw);
  43646. return false;
  43647. }
  43648. }
  43649. }
  43650. }
  43651. throw $throw;
  43652. }
  43653. $e = md5("{$type}/{$line}/{$file}\x00{$message}", true);
  43654. $trace = true;
  43655. if (!($this->tracedErrors & $type) || isset($this->loggedTraces[$e])) {
  43656. $trace = false;
  43657. } else {
  43658. $this->loggedTraces[$e] = 1;
  43659. }
  43660. $e = compact('type', 'file', 'line', 'level');
  43661. if ($type & $level) {
  43662. if ($scope) {
  43663. $e['scope_vars'] = $context;
  43664. if ($trace) {
  43665. $e['stack'] = $backtrace ?: debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT);
  43666. }
  43667. } elseif ($trace) {
  43668. if (null === $backtrace) {
  43669. $e['stack'] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
  43670. } else {
  43671. foreach ($backtrace as &$frame) {
  43672. unset($frame['args'], $frame);
  43673. }
  43674. $e['stack'] = $backtrace;
  43675. }
  43676. }
  43677. }
  43678. if ($this->isRecursive) {
  43679. $log = 0;
  43680. } elseif (self::$stackedErrorLevels) {
  43681. self::$stackedErrors[] = array($this->loggers[$type][0], ($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG, $message, $e);
  43682. } else {
  43683. try {
  43684. $this->isRecursive = true;
  43685. $this->loggers[$type][0]->log(($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG, $message, $e);
  43686. $this->isRecursive = false;
  43687. } catch (\Exception $e) {
  43688. $this->isRecursive = false;
  43689. throw $e;
  43690. } catch (\Throwable $e) {
  43691. $this->isRecursive = false;
  43692. throw $e;
  43693. }
  43694. }
  43695. return !$silenced && $type && $log;
  43696. }
  43697. public function handleException($exception, array $error = null)
  43698. {
  43699. if (null === $error) {
  43700. self::$exitCode = 255;
  43701. }
  43702. if (!$exception instanceof \Exception) {
  43703. $exception = new FatalThrowableError($exception);
  43704. }
  43705. $type = $exception instanceof FatalErrorException ? $exception->getSeverity() : E_ERROR;
  43706. $handlerException = null;
  43707. if (($this->loggedErrors & $type) || $exception instanceof FatalThrowableError) {
  43708. $e = array(
  43709. 'type' => $type,
  43710. 'file' => $exception->getFile(),
  43711. 'line' => $exception->getLine(),
  43712. 'level' => error_reporting(),
  43713. 'stack' => $exception->getTrace(),
  43714. );
  43715. if ($exception instanceof FatalErrorException) {
  43716. if ($exception instanceof FatalThrowableError) {
  43717. $error = array(
  43718. 'type' => $type,
  43719. 'message' => $message = $exception->getMessage(),
  43720. 'file' => $e['file'],
  43721. 'line' => $e['line'],
  43722. );
  43723. } else {
  43724. $message = 'Fatal '.$exception->getMessage();
  43725. }
  43726. } elseif ($exception instanceof \ErrorException) {
  43727. $message = 'Uncaught '.$exception->getMessage();
  43728. if ($exception instanceof ContextErrorException) {
  43729. $e['context'] = $exception->getContext();
  43730. }
  43731. } else {
  43732. $message = 'Uncaught Exception: '.$exception->getMessage();
  43733. }
  43734. }
  43735. if ($this->loggedErrors & $type) {
  43736. try {
  43737. $this->loggers[$type][0]->log($this->loggers[$type][1], $message, $e);
  43738. } catch (\Exception $handlerException) {
  43739. } catch (\Throwable $handlerException) {
  43740. }
  43741. }
  43742. if ($exception instanceof FatalErrorException && !$exception instanceof OutOfMemoryException && $error) {
  43743. foreach ($this->getFatalErrorHandlers() as $handler) {
  43744. if ($e = $handler->handleError($error, $exception)) {
  43745. $exception = $e;
  43746. break;
  43747. }
  43748. }
  43749. }
  43750. $exceptionHandler = $this->exceptionHandler;
  43751. $this->exceptionHandler = null;
  43752. try {
  43753. if (null !== $exceptionHandler) {
  43754. return \call_user_func($exceptionHandler, $exception);
  43755. }
  43756. $handlerException = $handlerException ?: $exception;
  43757. } catch (\Exception $handlerException) {
  43758. } catch (\Throwable $handlerException) {
  43759. }
  43760. if ($exception === $handlerException) {
  43761. self::$reservedMemory = null;
  43762. throw $exception;
  43763. }
  43764. $this->handleException($handlerException);
  43765. }
  43766. public static function handleFatalError(array $error = null)
  43767. {
  43768. if (null === self::$reservedMemory) {
  43769. return;
  43770. }
  43771. $handler = self::$reservedMemory = null;
  43772. $handlers = array();
  43773. $previousHandler = null;
  43774. $sameHandlerLimit = 10;
  43775. while (!\is_array($handler) || !$handler[0] instanceof self) {
  43776. $handler = set_exception_handler('var_dump');
  43777. restore_exception_handler();
  43778. if (!$handler) {
  43779. break;
  43780. }
  43781. restore_exception_handler();
  43782. if ($handler !== $previousHandler) {
  43783. array_unshift($handlers, $handler);
  43784. $previousHandler = $handler;
  43785. } elseif (0 === --$sameHandlerLimit) {
  43786. $handler = null;
  43787. break;
  43788. }
  43789. }
  43790. foreach ($handlers as $h) {
  43791. set_exception_handler($h);
  43792. }
  43793. if (!$handler) {
  43794. return;
  43795. }
  43796. if ($handler !== $h) {
  43797. $handler[0]->setExceptionHandler($h);
  43798. }
  43799. $handler = $handler[0];
  43800. $handlers = array();
  43801. if ($exit = null === $error) {
  43802. $error = error_get_last();
  43803. }
  43804. try {
  43805. while (self::$stackedErrorLevels) {
  43806. static::unstackErrors();
  43807. }
  43808. } catch (\Exception $exception) {
  43809. } catch (\Throwable $exception) {
  43810. }
  43811. if ($error && $error['type'] &= E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR) {
  43812. $handler->throwAt(0, true);
  43813. $trace = isset($error['backtrace']) ? $error['backtrace'] : null;
  43814. if (0 === strpos($error['message'], 'Allowed memory') || 0 === strpos($error['message'], 'Out of memory')) {
  43815. $exception = new OutOfMemoryException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, false, $trace);
  43816. } else {
  43817. $exception = new FatalErrorException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, true, $trace);
  43818. }
  43819. }
  43820. try {
  43821. if (isset($exception)) {
  43822. self::$exitCode = 255;
  43823. $handler->handleException($exception, $error);
  43824. }
  43825. } catch (FatalErrorException $e) {
  43826. }
  43827. if ($exit && self::$exitCode) {
  43828. $exitCode = self::$exitCode;
  43829. register_shutdown_function('register_shutdown_function', function () use ($exitCode) { exit($exitCode); });
  43830. }
  43831. }
  43832. public static function stackErrors()
  43833. {
  43834. self::$stackedErrorLevels[] = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
  43835. }
  43836. public static function unstackErrors()
  43837. {
  43838. $level = array_pop(self::$stackedErrorLevels);
  43839. if (null !== $level) {
  43840. $e = error_reporting($level);
  43841. if ($e !== ($level | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR)) {
  43842. error_reporting($e);
  43843. }
  43844. }
  43845. if (empty(self::$stackedErrorLevels)) {
  43846. $errors = self::$stackedErrors;
  43847. self::$stackedErrors = array();
  43848. foreach ($errors as $e) {
  43849. $e[0]->log($e[1], $e[2], $e[3]);
  43850. }
  43851. }
  43852. }
  43853. protected function getFatalErrorHandlers()
  43854. {
  43855. return array(
  43856. new UndefinedFunctionFatalErrorHandler(),
  43857. new UndefinedMethodFatalErrorHandler(),
  43858. new ClassNotFoundFatalErrorHandler(),
  43859. );
  43860. }
  43861. public function setLevel($level)
  43862. {
  43863. @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);
  43864. $level = null === $level ? error_reporting() : $level;
  43865. $this->throwAt($level, true);
  43866. }
  43867. public function setDisplayErrors($displayErrors)
  43868. {
  43869. @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);
  43870. if ($displayErrors) {
  43871. $this->throwAt($this->displayErrors, true);
  43872. } else {
  43873. $displayErrors = $this->displayErrors;
  43874. $this->throwAt(0, true);
  43875. $this->displayErrors = $displayErrors;
  43876. }
  43877. }
  43878. public static function setLogger(LoggerInterface $logger, $channel = 'deprecation')
  43879. {
  43880. @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);
  43881. $handler = set_error_handler('var_dump');
  43882. $handler = \is_array($handler) ? $handler[0] : null;
  43883. restore_error_handler();
  43884. if (!$handler instanceof self) {
  43885. return;
  43886. }
  43887. if ('deprecation' === $channel) {
  43888. $handler->setDefaultLogger($logger, E_DEPRECATED | E_USER_DEPRECATED, true);
  43889. $handler->screamAt(E_DEPRECATED | E_USER_DEPRECATED);
  43890. } elseif ('scream' === $channel) {
  43891. $handler->setDefaultLogger($logger, E_ALL | E_STRICT, false);
  43892. $handler->screamAt(E_ALL | E_STRICT);
  43893. } elseif ('emergency' === $channel) {
  43894. $handler->setDefaultLogger($logger, E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR, true);
  43895. $handler->screamAt(E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
  43896. }
  43897. }
  43898. public function handle($level, $message, $file = 'unknown', $line = 0, $context = array())
  43899. {
  43900. $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());
  43901. return $this->handleError($level, $message, $file, $line, (array) $context);
  43902. }
  43903. public function handleFatal()
  43904. {
  43905. @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);
  43906. static::handleFatalError();
  43907. }
  43908. }
  43909. class ErrorHandlerCanary
  43910. {
  43911. private static $displayErrors = null;
  43912. public function __construct()
  43913. {
  43914. if (null === self::$displayErrors) {
  43915. self::$displayErrors = ini_set('display_errors', 1);
  43916. }
  43917. }
  43918. public function __destruct()
  43919. {
  43920. if (null !== self::$displayErrors) {
  43921. ini_set('display_errors', self::$displayErrors);
  43922. self::$displayErrors = null;
  43923. }
  43924. }
  43925. }
  43926. <?php
  43927. namespace Symfony\Component\Debug\Exception;
  43928. class ClassNotFoundException extends FatalErrorException
  43929. {
  43930. public function __construct($message, \ErrorException $previous)
  43931. {
  43932. parent::__construct(
  43933. $message,
  43934. $previous->getCode(),
  43935. $previous->getSeverity(),
  43936. $previous->getFile(),
  43937. $previous->getLine(),
  43938. null,
  43939. true,
  43940. null,
  43941. $previous->getPrevious()
  43942. );
  43943. $this->setTrace($previous->getTrace());
  43944. }
  43945. }
  43946. <?php
  43947. namespace Symfony\Component\Debug\Exception;
  43948. class ContextErrorException extends \ErrorException
  43949. {
  43950. private $context = array();
  43951. public function __construct($message, $code, $severity, $filename, $lineno, $context = array())
  43952. {
  43953. parent::__construct($message, $code, $severity, $filename, $lineno);
  43954. $this->context = $context;
  43955. }
  43956. public function getContext()
  43957. {
  43958. return $this->context;
  43959. }
  43960. }
  43961. <?php
  43962. namespace Symfony\Component\Debug\Exception;
  43963. @trigger_error('The '.__NAMESPACE__.'\DummyException class is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  43964. class DummyException extends \ErrorException
  43965. {
  43966. }
  43967. <?php
  43968. namespace Symfony\Component\HttpKernel\Exception;
  43969. class FatalErrorException extends \ErrorException
  43970. {
  43971. }
  43972. namespace Symfony\Component\Debug\Exception;
  43973. use Symfony\Component\HttpKernel\Exception\FatalErrorException as LegacyFatalErrorException;
  43974. class FatalErrorException extends LegacyFatalErrorException
  43975. {
  43976. public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true, array $trace = null, $previous = null)
  43977. {
  43978. parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
  43979. if (null !== $trace) {
  43980. if (!$traceArgs) {
  43981. foreach ($trace as &$frame) {
  43982. unset($frame['args'], $frame['this'], $frame);
  43983. }
  43984. }
  43985. $this->setTrace($trace);
  43986. } elseif (null !== $traceOffset) {
  43987. if (\function_exists('xdebug_get_function_stack')) {
  43988. $trace = xdebug_get_function_stack();
  43989. if (0 < $traceOffset) {
  43990. array_splice($trace, -$traceOffset);
  43991. }
  43992. foreach ($trace as &$frame) {
  43993. if (!isset($frame['type'])) {
  43994. if (isset($frame['class'])) {
  43995. $frame['type'] = '::';
  43996. }
  43997. } elseif ('dynamic' === $frame['type']) {
  43998. $frame['type'] = '->';
  43999. } elseif ('static' === $frame['type']) {
  44000. $frame['type'] = '::';
  44001. }
  44002. if (!$traceArgs) {
  44003. unset($frame['params'], $frame['args']);
  44004. } elseif (isset($frame['params']) && !isset($frame['args'])) {
  44005. $frame['args'] = $frame['params'];
  44006. unset($frame['params']);
  44007. }
  44008. }
  44009. unset($frame);
  44010. $trace = array_reverse($trace);
  44011. } elseif (\function_exists('symfony_debug_backtrace')) {
  44012. $trace = symfony_debug_backtrace();
  44013. if (0 < $traceOffset) {
  44014. array_splice($trace, 0, $traceOffset);
  44015. }
  44016. } else {
  44017. $trace = array();
  44018. }
  44019. $this->setTrace($trace);
  44020. }
  44021. }
  44022. protected function setTrace($trace)
  44023. {
  44024. $traceReflector = new \ReflectionProperty('Exception', 'trace');
  44025. $traceReflector->setAccessible(true);
  44026. $traceReflector->setValue($this, $trace);
  44027. }
  44028. }
  44029. <?php
  44030. namespace Symfony\Component\Debug\Exception;
  44031. class FatalThrowableError extends FatalErrorException
  44032. {
  44033. public function __construct(\Throwable $e)
  44034. {
  44035. if ($e instanceof \ParseError) {
  44036. $message = 'Parse error: '.$e->getMessage();
  44037. $severity = E_PARSE;
  44038. } elseif ($e instanceof \TypeError) {
  44039. $message = 'Type error: '.$e->getMessage();
  44040. $severity = E_RECOVERABLE_ERROR;
  44041. } else {
  44042. $message = $e->getMessage();
  44043. $severity = E_ERROR;
  44044. }
  44045. \ErrorException::__construct(
  44046. $message,
  44047. $e->getCode(),
  44048. $severity,
  44049. $e->getFile(),
  44050. $e->getLine(),
  44051. $e->getPrevious()
  44052. );
  44053. $this->setTrace($e->getTrace());
  44054. }
  44055. }
  44056. <?php
  44057. namespace Symfony\Component\HttpKernel\Exception;
  44058. use Symfony\Component\Debug\Exception\FlattenException as DebugFlattenException;
  44059. class FlattenException
  44060. {
  44061. private $handler;
  44062. public static function __callStatic($method, $args)
  44063. {
  44064. if (!method_exists('Symfony\Component\Debug\Exception\FlattenException', $method)) {
  44065. throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', \get_called_class(), $method));
  44066. }
  44067. return \call_user_func_array(array('Symfony\Component\Debug\Exception\FlattenException', $method), $args);
  44068. }
  44069. public function __call($method, $args)
  44070. {
  44071. if (!isset($this->handler)) {
  44072. $this->handler = new DebugFlattenException();
  44073. }
  44074. if (!method_exists($this->handler, $method)) {
  44075. throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', \get_class($this), $method));
  44076. }
  44077. return \call_user_func_array(array($this->handler, $method), $args);
  44078. }
  44079. }
  44080. namespace Symfony\Component\Debug\Exception;
  44081. use Symfony\Component\HttpKernel\Exception\FlattenException as LegacyFlattenException;
  44082. use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
  44083. class FlattenException extends LegacyFlattenException
  44084. {
  44085. private $message;
  44086. private $code;
  44087. private $previous;
  44088. private $trace;
  44089. private $class;
  44090. private $statusCode;
  44091. private $headers;
  44092. private $file;
  44093. private $line;
  44094. public static function create(\Exception $exception, $statusCode = null, array $headers = array())
  44095. {
  44096. $e = new static();
  44097. $e->setMessage($exception->getMessage());
  44098. $e->setCode($exception->getCode());
  44099. if ($exception instanceof HttpExceptionInterface) {
  44100. $statusCode = $exception->getStatusCode();
  44101. $headers = array_merge($headers, $exception->getHeaders());
  44102. }
  44103. if (null === $statusCode) {
  44104. $statusCode = 500;
  44105. }
  44106. $e->setStatusCode($statusCode);
  44107. $e->setHeaders($headers);
  44108. $e->setTraceFromException($exception);
  44109. $e->setClass(\get_class($exception));
  44110. $e->setFile($exception->getFile());
  44111. $e->setLine($exception->getLine());
  44112. $previous = $exception->getPrevious();
  44113. if ($previous instanceof \Exception) {
  44114. $e->setPrevious(static::create($previous));
  44115. } elseif ($previous instanceof \Throwable) {
  44116. $e->setPrevious(static::create(new FatalThrowableError($previous)));
  44117. }
  44118. return $e;
  44119. }
  44120. public function toArray()
  44121. {
  44122. $exceptions = array();
  44123. foreach (array_merge(array($this), $this->getAllPrevious()) as $exception) {
  44124. $exceptions[] = array(
  44125. 'message' => $exception->getMessage(),
  44126. 'class' => $exception->getClass(),
  44127. 'trace' => $exception->getTrace(),
  44128. );
  44129. }
  44130. return $exceptions;
  44131. }
  44132. public function getStatusCode()
  44133. {
  44134. return $this->statusCode;
  44135. }
  44136. public function setStatusCode($code)
  44137. {
  44138. $this->statusCode = $code;
  44139. }
  44140. public function getHeaders()
  44141. {
  44142. return $this->headers;
  44143. }
  44144. public function setHeaders(array $headers)
  44145. {
  44146. $this->headers = $headers;
  44147. }
  44148. public function getClass()
  44149. {
  44150. return $this->class;
  44151. }
  44152. public function setClass($class)
  44153. {
  44154. $this->class = $class;
  44155. }
  44156. public function getFile()
  44157. {
  44158. return $this->file;
  44159. }
  44160. public function setFile($file)
  44161. {
  44162. $this->file = $file;
  44163. }
  44164. public function getLine()
  44165. {
  44166. return $this->line;
  44167. }
  44168. public function setLine($line)
  44169. {
  44170. $this->line = $line;
  44171. }
  44172. public function getMessage()
  44173. {
  44174. return $this->message;
  44175. }
  44176. public function setMessage($message)
  44177. {
  44178. $this->message = $message;
  44179. }
  44180. public function getCode()
  44181. {
  44182. return $this->code;
  44183. }
  44184. public function setCode($code)
  44185. {
  44186. $this->code = $code;
  44187. }
  44188. public function getPrevious()
  44189. {
  44190. return $this->previous;
  44191. }
  44192. public function setPrevious(FlattenException $previous)
  44193. {
  44194. $this->previous = $previous;
  44195. }
  44196. public function getAllPrevious()
  44197. {
  44198. $exceptions = array();
  44199. $e = $this;
  44200. while ($e = $e->getPrevious()) {
  44201. $exceptions[] = $e;
  44202. }
  44203. return $exceptions;
  44204. }
  44205. public function getTrace()
  44206. {
  44207. return $this->trace;
  44208. }
  44209. public function setTraceFromException(\Exception $exception)
  44210. {
  44211. $this->setTrace($exception->getTrace(), $exception->getFile(), $exception->getLine());
  44212. }
  44213. public function setTrace($trace, $file, $line)
  44214. {
  44215. $this->trace = array();
  44216. $this->trace[] = array(
  44217. 'namespace' => '',
  44218. 'short_class' => '',
  44219. 'class' => '',
  44220. 'type' => '',
  44221. 'function' => '',
  44222. 'file' => $file,
  44223. 'line' => $line,
  44224. 'args' => array(),
  44225. );
  44226. foreach ($trace as $entry) {
  44227. $class = '';
  44228. $namespace = '';
  44229. if (isset($entry['class'])) {
  44230. $parts = explode('\\', $entry['class']);
  44231. $class = array_pop($parts);
  44232. $namespace = implode('\\', $parts);
  44233. }
  44234. $this->trace[] = array(
  44235. 'namespace' => $namespace,
  44236. 'short_class' => $class,
  44237. 'class' => isset($entry['class']) ? $entry['class'] : '',
  44238. 'type' => isset($entry['type']) ? $entry['type'] : '',
  44239. 'function' => isset($entry['function']) ? $entry['function'] : null,
  44240. 'file' => isset($entry['file']) ? $entry['file'] : null,
  44241. 'line' => isset($entry['line']) ? $entry['line'] : null,
  44242. 'args' => isset($entry['args']) ? $this->flattenArgs($entry['args']) : array(),
  44243. );
  44244. }
  44245. }
  44246. private function flattenArgs($args, $level = 0, &$count = 0)
  44247. {
  44248. $result = array();
  44249. foreach ($args as $key => $value) {
  44250. if (++$count > 1e4) {
  44251. return array('array', '*SKIPPED over 10000 entries*');
  44252. }
  44253. if ($value instanceof \__PHP_Incomplete_Class) {
  44254. $result[$key] = array('incomplete-object', $this->getClassNameFromIncomplete($value));
  44255. } elseif (\is_object($value)) {
  44256. $result[$key] = array('object', \get_class($value));
  44257. } elseif (\is_array($value)) {
  44258. if ($level > 10) {
  44259. $result[$key] = array('array', '*DEEP NESTED ARRAY*');
  44260. } else {
  44261. $result[$key] = array('array', $this->flattenArgs($value, $level + 1, $count));
  44262. }
  44263. } elseif (null === $value) {
  44264. $result[$key] = array('null', null);
  44265. } elseif (\is_bool($value)) {
  44266. $result[$key] = array('boolean', $value);
  44267. } elseif (\is_resource($value)) {
  44268. $result[$key] = array('resource', get_resource_type($value));
  44269. } else {
  44270. $result[$key] = array('string', (string) $value);
  44271. }
  44272. }
  44273. return $result;
  44274. }
  44275. private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $value)
  44276. {
  44277. $array = new \ArrayObject($value);
  44278. return $array['__PHP_Incomplete_Class_Name'];
  44279. }
  44280. }
  44281. <?php
  44282. namespace Symfony\Component\Debug\Exception;
  44283. class OutOfMemoryException extends FatalErrorException
  44284. {
  44285. }
  44286. <?php
  44287. namespace Symfony\Component\Debug\Exception;
  44288. class UndefinedFunctionException extends FatalErrorException
  44289. {
  44290. public function __construct($message, \ErrorException $previous)
  44291. {
  44292. parent::__construct(
  44293. $message,
  44294. $previous->getCode(),
  44295. $previous->getSeverity(),
  44296. $previous->getFile(),
  44297. $previous->getLine(),
  44298. null,
  44299. true,
  44300. null,
  44301. $previous->getPrevious()
  44302. );
  44303. $this->setTrace($previous->getTrace());
  44304. }
  44305. }
  44306. <?php
  44307. namespace Symfony\Component\Debug\Exception;
  44308. class UndefinedMethodException extends FatalErrorException
  44309. {
  44310. public function __construct($message, \ErrorException $previous)
  44311. {
  44312. parent::__construct(
  44313. $message,
  44314. $previous->getCode(),
  44315. $previous->getSeverity(),
  44316. $previous->getFile(),
  44317. $previous->getLine(),
  44318. null,
  44319. true,
  44320. null,
  44321. $previous->getPrevious()
  44322. );
  44323. $this->setTrace($previous->getTrace());
  44324. }
  44325. }
  44326. <?php
  44327. namespace Symfony\Component\Debug;
  44328. use Symfony\Component\Debug\Exception\FlattenException;
  44329. use Symfony\Component\Debug\Exception\OutOfMemoryException;
  44330. use Symfony\Component\HttpFoundation\Response;
  44331. class ExceptionHandler
  44332. {
  44333. private $debug;
  44334. private $charset;
  44335. private $handler;
  44336. private $caughtBuffer;
  44337. private $caughtLength;
  44338. private $fileLinkFormat;
  44339. public function __construct($debug = true, $charset = null, $fileLinkFormat = null)
  44340. {
  44341. if (false !== strpos($charset, '%')) {
  44342. @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);
  44343. $pivot = $fileLinkFormat;
  44344. $fileLinkFormat = $charset;
  44345. $charset = $pivot;
  44346. }
  44347. $this->debug = $debug;
  44348. $this->charset = $charset ?: ini_get('default_charset') ?: 'UTF-8';
  44349. $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
  44350. }
  44351. public static function register($debug = true, $charset = null, $fileLinkFormat = null)
  44352. {
  44353. $handler = new static($debug, $charset, $fileLinkFormat);
  44354. $prev = set_exception_handler(array($handler, 'handle'));
  44355. if (\is_array($prev) && $prev[0] instanceof ErrorHandler) {
  44356. restore_exception_handler();
  44357. $prev[0]->setExceptionHandler(array($handler, 'handle'));
  44358. }
  44359. return $handler;
  44360. }
  44361. public function setHandler($handler)
  44362. {
  44363. if (null !== $handler && !\is_callable($handler)) {
  44364. throw new \LogicException('The exception handler must be a valid PHP callable.');
  44365. }
  44366. $old = $this->handler;
  44367. $this->handler = $handler;
  44368. return $old;
  44369. }
  44370. public function setFileLinkFormat($format)
  44371. {
  44372. $old = $this->fileLinkFormat;
  44373. $this->fileLinkFormat = $format;
  44374. return $old;
  44375. }
  44376. public function handle(\Exception $exception)
  44377. {
  44378. if (null === $this->handler || $exception instanceof OutOfMemoryException) {
  44379. $this->failSafeHandle($exception);
  44380. return;
  44381. }
  44382. $caughtLength = $this->caughtLength = 0;
  44383. ob_start(array($this, 'catchOutput'));
  44384. $this->failSafeHandle($exception);
  44385. while (null === $this->caughtBuffer && ob_end_flush()) {
  44386. }
  44387. if (isset($this->caughtBuffer[0])) {
  44388. ob_start(array($this, 'cleanOutput'));
  44389. echo $this->caughtBuffer;
  44390. $caughtLength = ob_get_length();
  44391. }
  44392. $this->caughtBuffer = null;
  44393. try {
  44394. \call_user_func($this->handler, $exception);
  44395. $this->caughtLength = $caughtLength;
  44396. } catch (\Exception $e) {
  44397. if (!$caughtLength) {
  44398. throw $exception;
  44399. }
  44400. }
  44401. }
  44402. private function failSafeHandle(\Exception $exception)
  44403. {
  44404. if (class_exists('Symfony\Component\HttpFoundation\Response', false)
  44405. && __CLASS__ !== \get_class($this)
  44406. && ($reflector = new \ReflectionMethod($this, 'createResponse'))
  44407. && __CLASS__ !== $reflector->class
  44408. ) {
  44409. $response = $this->createResponse($exception);
  44410. $response->sendHeaders();
  44411. $response->sendContent();
  44412. @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);
  44413. return;
  44414. }
  44415. $this->sendPhpResponse($exception);
  44416. }
  44417. public function sendPhpResponse($exception)
  44418. {
  44419. if (!$exception instanceof FlattenException) {
  44420. $exception = FlattenException::create($exception);
  44421. }
  44422. if (!headers_sent()) {
  44423. header(sprintf('HTTP/1.0 %s', $exception->getStatusCode()));
  44424. foreach ($exception->getHeaders() as $name => $value) {
  44425. header($name.': '.$value, false);
  44426. }
  44427. header('Content-Type: text/html; charset='.$this->charset);
  44428. }
  44429. echo $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
  44430. }
  44431. public function createResponse($exception)
  44432. {
  44433. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  44434. if (!$exception instanceof FlattenException) {
  44435. $exception = FlattenException::create($exception);
  44436. }
  44437. return Response::create($this->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders())->setCharset($this->charset);
  44438. }
  44439. public function getHtml($exception)
  44440. {
  44441. if (!$exception instanceof FlattenException) {
  44442. $exception = FlattenException::create($exception);
  44443. }
  44444. return $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
  44445. }
  44446. public function getContent(FlattenException $exception)
  44447. {
  44448. switch ($exception->getStatusCode()) {
  44449. case 404:
  44450. $title = 'Sorry, the page you are looking for could not be found.';
  44451. break;
  44452. default:
  44453. $title = 'Whoops, looks like something went wrong.';
  44454. }
  44455. $content = '';
  44456. if ($this->debug) {
  44457. try {
  44458. $count = \count($exception->getAllPrevious());
  44459. $total = $count + 1;
  44460. foreach ($exception->toArray() as $position => $e) {
  44461. $ind = $count - $position + 1;
  44462. $class = $this->formatClass($e['class']);
  44463. $message = nl2br($this->escapeHtml($e['message']));
  44464. $content .= sprintf(<<<'EOF'
  44465. <h2 class="block_exception clear_fix">
  44466. <span class="exception_counter">%d/%d</span>
  44467. <span class="exception_title">%s%s:</span>
  44468. <span class="exception_message">%s</span>
  44469. </h2>
  44470. <div class="block">
  44471. <ol class="traces list_exception">
  44472. EOF
  44473. , $ind, $total, $class, $this->formatPath($e['trace'][0]['file'], $e['trace'][0]['line']), $message);
  44474. foreach ($e['trace'] as $trace) {
  44475. $content .= ' <li>';
  44476. if ($trace['function']) {
  44477. $content .= sprintf('at %s%s%s(%s)', $this->formatClass($trace['class']), $trace['type'], $trace['function'], $this->formatArgs($trace['args']));
  44478. }
  44479. if (isset($trace['file']) && isset($trace['line'])) {
  44480. $content .= $this->formatPath($trace['file'], $trace['line']);
  44481. }
  44482. $content .= "</li>\n";
  44483. }
  44484. $content .= " </ol>\n</div>\n";
  44485. }
  44486. } catch (\Exception $e) {
  44487. if ($this->debug) {
  44488. $title = sprintf('Exception thrown when handling an exception (%s: %s)', \get_class($e), $this->escapeHtml($e->getMessage()));
  44489. } else {
  44490. $title = 'Whoops, looks like something went wrong.';
  44491. }
  44492. }
  44493. }
  44494. return <<<EOF
  44495. <div id="sf-resetcontent" class="sf-reset">
  44496. <h1>$title</h1>
  44497. $content
  44498. </div>
  44499. EOF;
  44500. }
  44501. public function getStylesheet(FlattenException $exception)
  44502. {
  44503. return <<<'EOF'
  44504. .sf-reset { font: 11px Verdana, Arial, sans-serif; color: #333 }
  44505. .sf-reset .clear { clear:both; height:0; font-size:0; line-height:0; }
  44506. .sf-reset .clear_fix:after { display:block; height:0; clear:both; visibility:hidden; }
  44507. .sf-reset .clear_fix { display:inline-block; }
  44508. .sf-reset * html .clear_fix { height:1%; }
  44509. .sf-reset .clear_fix { display:block; }
  44510. .sf-reset, .sf-reset .block { margin: auto }
  44511. .sf-reset abbr { border-bottom: 1px dotted #000; cursor: help; }
  44512. .sf-reset p { font-size:14px; line-height:20px; color:#868686; padding-bottom:20px }
  44513. .sf-reset strong { font-weight:bold; }
  44514. .sf-reset a { color:#6c6159; cursor: default; }
  44515. .sf-reset a img { border:none; }
  44516. .sf-reset a:hover { text-decoration:underline; }
  44517. .sf-reset em { font-style:italic; }
  44518. .sf-reset h1, .sf-reset h2 { font: 20px Georgia, "Times New Roman", Times, serif }
  44519. .sf-reset .exception_counter { background-color: #fff; color: #333; padding: 6px; float: left; margin-right: 10px; float: left; display: block; }
  44520. .sf-reset .exception_title { margin-left: 3em; margin-bottom: 0.7em; display: block; }
  44521. .sf-reset .exception_message { margin-left: 3em; display: block; }
  44522. .sf-reset .traces li { font-size:12px; padding: 2px 4px; list-style-type:decimal; margin-left:20px; }
  44523. .sf-reset .block { background-color:#FFFFFF; padding:10px 28px; margin-bottom:20px;
  44524. -webkit-border-bottom-right-radius: 16px;
  44525. -webkit-border-bottom-left-radius: 16px;
  44526. -moz-border-radius-bottomright: 16px;
  44527. -moz-border-radius-bottomleft: 16px;
  44528. border-bottom-right-radius: 16px;
  44529. border-bottom-left-radius: 16px;
  44530. border-bottom:1px solid #ccc;
  44531. border-right:1px solid #ccc;
  44532. border-left:1px solid #ccc;
  44533. word-wrap: break-word;
  44534. }
  44535. .sf-reset .block_exception { background-color:#ddd; color: #333; padding:20px;
  44536. -webkit-border-top-left-radius: 16px;
  44537. -webkit-border-top-right-radius: 16px;
  44538. -moz-border-radius-topleft: 16px;
  44539. -moz-border-radius-topright: 16px;
  44540. border-top-left-radius: 16px;
  44541. border-top-right-radius: 16px;
  44542. border-top:1px solid #ccc;
  44543. border-right:1px solid #ccc;
  44544. border-left:1px solid #ccc;
  44545. overflow: hidden;
  44546. word-wrap: break-word;
  44547. }
  44548. .sf-reset a { background:none; color:#868686; text-decoration:none; }
  44549. .sf-reset a:hover { background:none; color:#313131; text-decoration:underline; }
  44550. .sf-reset ol { padding: 10px 0; }
  44551. .sf-reset h1 { background-color:#FFFFFF; padding: 15px 28px; margin-bottom: 20px;
  44552. -webkit-border-radius: 10px;
  44553. -moz-border-radius: 10px;
  44554. border-radius: 10px;
  44555. border: 1px solid #ccc;
  44556. }
  44557. EOF;
  44558. }
  44559. private function decorate($content, $css)
  44560. {
  44561. return <<<EOF
  44562. <!DOCTYPE html>
  44563. <html>
  44564. <head>
  44565. <meta charset="{$this->charset}" />
  44566. <meta name="robots" content="noindex,nofollow" />
  44567. <style>
  44568. /* Copyright (c) 2010, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html */
  44569. 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;}
  44570. html { background: #eee; padding: 10px }
  44571. img { border: 0; }
  44572. #sf-resetcontent { width:970px; margin:0 auto; }
  44573. $css
  44574. </style>
  44575. </head>
  44576. <body>
  44577. $content
  44578. </body>
  44579. </html>
  44580. EOF;
  44581. }
  44582. private function formatClass($class)
  44583. {
  44584. $parts = explode('\\', $class);
  44585. return sprintf('<abbr title="%s">%s</abbr>', $class, array_pop($parts));
  44586. }
  44587. private function formatPath($path, $line)
  44588. {
  44589. $path = $this->escapeHtml($path);
  44590. $file = preg_match('#[^/\\\\]*$#', $path, $file) ? $file[0] : $path;
  44591. if ($linkFormat = $this->fileLinkFormat) {
  44592. $link = strtr($this->escapeHtml($linkFormat), array('%f' => $path, '%l' => (int) $line));
  44593. return sprintf(' in <a href="%s" title="Go to source">%s line %d</a>', $link, $file, $line);
  44594. }
  44595. 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);
  44596. }
  44597. private function formatArgs(array $args)
  44598. {
  44599. $result = array();
  44600. foreach ($args as $key => $item) {
  44601. if ('object' === $item[0]) {
  44602. $formattedValue = sprintf('<em>object</em>(%s)', $this->formatClass($item[1]));
  44603. } elseif ('array' === $item[0]) {
  44604. $formattedValue = sprintf('<em>array</em>(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
  44605. } elseif ('string' === $item[0]) {
  44606. $formattedValue = sprintf("'%s'", $this->escapeHtml($item[1]));
  44607. } elseif ('null' === $item[0]) {
  44608. $formattedValue = '<em>null</em>';
  44609. } elseif ('boolean' === $item[0]) {
  44610. $formattedValue = '<em>'.strtolower(var_export($item[1], true)).'</em>';
  44611. } elseif ('resource' === $item[0]) {
  44612. $formattedValue = '<em>resource</em>';
  44613. } else {
  44614. $formattedValue = str_replace("\n", '', var_export($this->escapeHtml((string) $item[1]), true));
  44615. }
  44616. $result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $this->escapeHtml($key), $formattedValue);
  44617. }
  44618. return implode(', ', $result);
  44619. }
  44620. protected static function utf8Htmlize($str)
  44621. {
  44622. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
  44623. return htmlspecialchars($str, ENT_QUOTES | (\PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), 'UTF-8');
  44624. }
  44625. private function escapeHtml($str)
  44626. {
  44627. return htmlspecialchars($str, ENT_QUOTES | (\PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), $this->charset);
  44628. }
  44629. public function catchOutput($buffer)
  44630. {
  44631. $this->caughtBuffer = $buffer;
  44632. return '';
  44633. }
  44634. public function cleanOutput($buffer)
  44635. {
  44636. if ($this->caughtLength) {
  44637. $cleanBuffer = substr_replace($buffer, '', 0, $this->caughtLength);
  44638. if (isset($cleanBuffer[0])) {
  44639. $buffer = $cleanBuffer;
  44640. }
  44641. }
  44642. return $buffer;
  44643. }
  44644. }
  44645. <?php
  44646. namespace Symfony\Component\Debug\FatalErrorHandler;
  44647. use Composer\Autoload\ClassLoader as ComposerClassLoader;
  44648. use Symfony\Component\ClassLoader\ClassLoader as SymfonyClassLoader;
  44649. use Symfony\Component\ClassLoader\UniversalClassLoader as SymfonyUniversalClassLoader;
  44650. use Symfony\Component\Debug\DebugClassLoader;
  44651. use Symfony\Component\Debug\Exception\ClassNotFoundException;
  44652. use Symfony\Component\Debug\Exception\FatalErrorException;
  44653. class ClassNotFoundFatalErrorHandler implements FatalErrorHandlerInterface
  44654. {
  44655. public function handleError(array $error, FatalErrorException $exception)
  44656. {
  44657. $messageLen = \strlen($error['message']);
  44658. $notFoundSuffix = '\' not found';
  44659. $notFoundSuffixLen = \strlen($notFoundSuffix);
  44660. if ($notFoundSuffixLen > $messageLen) {
  44661. return;
  44662. }
  44663. if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) {
  44664. return;
  44665. }
  44666. foreach (array('class', 'interface', 'trait') as $typeName) {
  44667. $prefix = ucfirst($typeName).' \'';
  44668. $prefixLen = \strlen($prefix);
  44669. if (0 !== strpos($error['message'], $prefix)) {
  44670. continue;
  44671. }
  44672. $fullyQualifiedClassName = substr($error['message'], $prefixLen, -$notFoundSuffixLen);
  44673. if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedClassName, '\\')) {
  44674. $className = substr($fullyQualifiedClassName, $namespaceSeparatorIndex + 1);
  44675. $namespacePrefix = substr($fullyQualifiedClassName, 0, $namespaceSeparatorIndex);
  44676. $message = sprintf('Attempted to load %s "%s" from namespace "%s".', $typeName, $className, $namespacePrefix);
  44677. $tail = ' for another namespace?';
  44678. } else {
  44679. $className = $fullyQualifiedClassName;
  44680. $message = sprintf('Attempted to load %s "%s" from the global namespace.', $typeName, $className);
  44681. $tail = '?';
  44682. }
  44683. if ($candidates = $this->getClassCandidates($className)) {
  44684. $tail = array_pop($candidates).'"?';
  44685. if ($candidates) {
  44686. $tail = ' for e.g. "'.implode('", "', $candidates).'" or "'.$tail;
  44687. } else {
  44688. $tail = ' for "'.$tail;
  44689. }
  44690. }
  44691. $message .= "\nDid you forget a \"use\" statement".$tail;
  44692. return new ClassNotFoundException($message, $exception);
  44693. }
  44694. }
  44695. private function getClassCandidates($class)
  44696. {
  44697. if (!\is_array($functions = spl_autoload_functions())) {
  44698. return array();
  44699. }
  44700. $classes = array();
  44701. foreach ($functions as $function) {
  44702. if (!\is_array($function)) {
  44703. continue;
  44704. }
  44705. if ($function[0] instanceof DebugClassLoader) {
  44706. $function = $function[0]->getClassLoader();
  44707. if (\is_object($function)) {
  44708. $function = array($function);
  44709. }
  44710. if (!\is_array($function)) {
  44711. continue;
  44712. }
  44713. }
  44714. if ($function[0] instanceof ComposerClassLoader || $function[0] instanceof SymfonyClassLoader || $function[0] instanceof SymfonyUniversalClassLoader) {
  44715. foreach ($function[0]->getPrefixes() as $prefix => $paths) {
  44716. foreach ($paths as $path) {
  44717. $classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix));
  44718. }
  44719. }
  44720. }
  44721. if ($function[0] instanceof ComposerClassLoader) {
  44722. foreach ($function[0]->getPrefixesPsr4() as $prefix => $paths) {
  44723. foreach ($paths as $path) {
  44724. $classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix));
  44725. }
  44726. }
  44727. }
  44728. }
  44729. return array_unique($classes);
  44730. }
  44731. private function findClassInPath($path, $class, $prefix)
  44732. {
  44733. if (!$path = realpath($path.'/'.strtr($prefix, '\\_', '//')) ?: realpath($path.'/'.\dirname(strtr($prefix, '\\_', '//'))) ?: realpath($path)) {
  44734. return array();
  44735. }
  44736. $classes = array();
  44737. $filename = $class.'.php';
  44738. foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
  44739. if ($filename == $file->getFileName() && $class = $this->convertFileToClass($path, $file->getPathName(), $prefix)) {
  44740. $classes[] = $class;
  44741. }
  44742. }
  44743. return $classes;
  44744. }
  44745. private function convertFileToClass($path, $file, $prefix)
  44746. {
  44747. $candidates = array(
  44748. $namespacedClass = str_replace(array($path.\DIRECTORY_SEPARATOR, '.php', '/'), array('', '', '\\'), $file),
  44749. $prefix.$namespacedClass,
  44750. $prefix.'\\'.$namespacedClass,
  44751. str_replace('\\', '_', $namespacedClass),
  44752. str_replace('\\', '_', $prefix.$namespacedClass),
  44753. str_replace('\\', '_', $prefix.'\\'.$namespacedClass),
  44754. );
  44755. if ($prefix) {
  44756. $candidates = array_filter($candidates, function ($candidate) use ($prefix) { return 0 === strpos($candidate, $prefix); });
  44757. }
  44758. foreach ($candidates as $candidate) {
  44759. if ($this->classExists($candidate)) {
  44760. return $candidate;
  44761. }
  44762. }
  44763. require_once $file;
  44764. foreach ($candidates as $candidate) {
  44765. if ($this->classExists($candidate)) {
  44766. return $candidate;
  44767. }
  44768. }
  44769. }
  44770. private function classExists($class)
  44771. {
  44772. return class_exists($class, false) || interface_exists($class, false) || (\function_exists('trait_exists') && trait_exists($class, false));
  44773. }
  44774. }
  44775. <?php
  44776. namespace Symfony\Component\Debug\FatalErrorHandler;
  44777. use Symfony\Component\Debug\Exception\FatalErrorException;
  44778. interface FatalErrorHandlerInterface
  44779. {
  44780. public function handleError(array $error, FatalErrorException $exception);
  44781. }
  44782. <?php
  44783. namespace Symfony\Component\Debug\FatalErrorHandler;
  44784. use Symfony\Component\Debug\Exception\FatalErrorException;
  44785. use Symfony\Component\Debug\Exception\UndefinedFunctionException;
  44786. class UndefinedFunctionFatalErrorHandler implements FatalErrorHandlerInterface
  44787. {
  44788. public function handleError(array $error, FatalErrorException $exception)
  44789. {
  44790. $messageLen = \strlen($error['message']);
  44791. $notFoundSuffix = '()';
  44792. $notFoundSuffixLen = \strlen($notFoundSuffix);
  44793. if ($notFoundSuffixLen > $messageLen) {
  44794. return;
  44795. }
  44796. if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) {
  44797. return;
  44798. }
  44799. $prefix = 'Call to undefined function ';
  44800. $prefixLen = \strlen($prefix);
  44801. if (0 !== strpos($error['message'], $prefix)) {
  44802. return;
  44803. }
  44804. $fullyQualifiedFunctionName = substr($error['message'], $prefixLen, -$notFoundSuffixLen);
  44805. if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedFunctionName, '\\')) {
  44806. $functionName = substr($fullyQualifiedFunctionName, $namespaceSeparatorIndex + 1);
  44807. $namespacePrefix = substr($fullyQualifiedFunctionName, 0, $namespaceSeparatorIndex);
  44808. $message = sprintf('Attempted to call function "%s" from namespace "%s".', $functionName, $namespacePrefix);
  44809. } else {
  44810. $functionName = $fullyQualifiedFunctionName;
  44811. $message = sprintf('Attempted to call function "%s" from the global namespace.', $functionName);
  44812. }
  44813. $candidates = array();
  44814. foreach (get_defined_functions() as $type => $definedFunctionNames) {
  44815. foreach ($definedFunctionNames as $definedFunctionName) {
  44816. if (false !== $namespaceSeparatorIndex = strrpos($definedFunctionName, '\\')) {
  44817. $definedFunctionNameBasename = substr($definedFunctionName, $namespaceSeparatorIndex + 1);
  44818. } else {
  44819. $definedFunctionNameBasename = $definedFunctionName;
  44820. }
  44821. if ($definedFunctionNameBasename === $functionName) {
  44822. $candidates[] = '\\'.$definedFunctionName;
  44823. }
  44824. }
  44825. }
  44826. if ($candidates) {
  44827. sort($candidates);
  44828. $last = array_pop($candidates).'"?';
  44829. if ($candidates) {
  44830. $candidates = 'e.g. "'.implode('", "', $candidates).'" or "'.$last;
  44831. } else {
  44832. $candidates = '"'.$last;
  44833. }
  44834. $message .= "\nDid you mean to call ".$candidates;
  44835. }
  44836. return new UndefinedFunctionException($message, $exception);
  44837. }
  44838. }
  44839. <?php
  44840. namespace Symfony\Component\Debug\FatalErrorHandler;
  44841. use Symfony\Component\Debug\Exception\FatalErrorException;
  44842. use Symfony\Component\Debug\Exception\UndefinedMethodException;
  44843. class UndefinedMethodFatalErrorHandler implements FatalErrorHandlerInterface
  44844. {
  44845. public function handleError(array $error, FatalErrorException $exception)
  44846. {
  44847. preg_match('/^Call to undefined method (.*)::(.*)\(\)$/', $error['message'], $matches);
  44848. if (!$matches) {
  44849. return;
  44850. }
  44851. $className = $matches[1];
  44852. $methodName = $matches[2];
  44853. $message = sprintf('Attempted to call an undefined method named "%s" of class "%s".', $methodName, $className);
  44854. if (!class_exists($className) || null === $methods = get_class_methods($className)) {
  44855. return new UndefinedMethodException($message, $exception);
  44856. }
  44857. $candidates = array();
  44858. foreach ($methods as $definedMethodName) {
  44859. $lev = levenshtein($methodName, $definedMethodName);
  44860. if ($lev <= \strlen($methodName) / 3 || false !== strpos($definedMethodName, $methodName)) {
  44861. $candidates[] = $definedMethodName;
  44862. }
  44863. }
  44864. if ($candidates) {
  44865. sort($candidates);
  44866. $last = array_pop($candidates).'"?';
  44867. if ($candidates) {
  44868. $candidates = 'e.g. "'.implode('", "', $candidates).'" or "'.$last;
  44869. } else {
  44870. $candidates = '"'.$last;
  44871. }
  44872. $message .= "\nDid you mean to call ".$candidates;
  44873. }
  44874. return new UndefinedMethodException($message, $exception);
  44875. }
  44876. }
  44877. Copyright (c) 2004-2018 Fabien Potencier
  44878. Permission is hereby granted, free of charge, to any person obtaining a copy
  44879. of this software and associated documentation files (the "Software"), to deal
  44880. in the Software without restriction, including without limitation the rights
  44881. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  44882. copies of the Software, and to permit persons to whom the Software is furnished
  44883. to do so, subject to the following conditions:
  44884. The above copyright notice and this permission notice shall be included in all
  44885. copies or substantial portions of the Software.
  44886. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  44887. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  44888. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  44889. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  44890. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  44891. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  44892. THE SOFTWARE.
  44893. <?php
  44894. namespace Symfony\Component\Filesystem\Exception;
  44895. interface ExceptionInterface
  44896. {
  44897. }
  44898. <?php
  44899. namespace Symfony\Component\Filesystem\Exception;
  44900. class FileNotFoundException extends IOException
  44901. {
  44902. public function __construct($message = null, $code = 0, \Exception $previous = null, $path = null)
  44903. {
  44904. if (null === $message) {
  44905. if (null === $path) {
  44906. $message = 'File could not be found.';
  44907. } else {
  44908. $message = sprintf('File "%s" could not be found.', $path);
  44909. }
  44910. }
  44911. parent::__construct($message, $code, $previous, $path);
  44912. }
  44913. }
  44914. <?php
  44915. namespace Symfony\Component\Filesystem\Exception;
  44916. class IOException extends \RuntimeException implements IOExceptionInterface
  44917. {
  44918. private $path;
  44919. public function __construct($message, $code = 0, \Exception $previous = null, $path = null)
  44920. {
  44921. $this->path = $path;
  44922. parent::__construct($message, $code, $previous);
  44923. }
  44924. public function getPath()
  44925. {
  44926. return $this->path;
  44927. }
  44928. }
  44929. <?php
  44930. namespace Symfony\Component\Filesystem\Exception;
  44931. interface IOExceptionInterface extends ExceptionInterface
  44932. {
  44933. public function getPath();
  44934. }
  44935. <?php
  44936. namespace Symfony\Component\Filesystem;
  44937. use Symfony\Component\Filesystem\Exception\FileNotFoundException;
  44938. use Symfony\Component\Filesystem\Exception\IOException;
  44939. class Filesystem
  44940. {
  44941. private static $lastError;
  44942. public function copy($originFile, $targetFile, $overwriteNewerFiles = false)
  44943. {
  44944. $originIsLocal = stream_is_local($originFile) || 0 === stripos($originFile, 'file://');
  44945. if ($originIsLocal && !is_file($originFile)) {
  44946. throw new FileNotFoundException(sprintf('Failed to copy "%s" because file does not exist.', $originFile), 0, null, $originFile);
  44947. }
  44948. $this->mkdir(\dirname($targetFile));
  44949. $doCopy = true;
  44950. if (!$overwriteNewerFiles && null === parse_url($originFile, PHP_URL_HOST) && is_file($targetFile)) {
  44951. $doCopy = filemtime($originFile) > filemtime($targetFile);
  44952. }
  44953. if ($doCopy) {
  44954. if (false === $source = @fopen($originFile, 'r')) {
  44955. throw new IOException(sprintf('Failed to copy "%s" to "%s" because source file could not be opened for reading.', $originFile, $targetFile), 0, null, $originFile);
  44956. }
  44957. if (false === $target = @fopen($targetFile, 'w', null, stream_context_create(array('ftp' => array('overwrite' => true))))) {
  44958. throw new IOException(sprintf('Failed to copy "%s" to "%s" because target file could not be opened for writing.', $originFile, $targetFile), 0, null, $originFile);
  44959. }
  44960. $bytesCopied = stream_copy_to_stream($source, $target);
  44961. fclose($source);
  44962. fclose($target);
  44963. unset($source, $target);
  44964. if (!is_file($targetFile)) {
  44965. throw new IOException(sprintf('Failed to copy "%s" to "%s".', $originFile, $targetFile), 0, null, $originFile);
  44966. }
  44967. if ($originIsLocal) {
  44968. @chmod($targetFile, fileperms($targetFile) | (fileperms($originFile) & 0111));
  44969. if ($bytesCopied !== $bytesOrigin = filesize($originFile)) {
  44970. 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);
  44971. }
  44972. }
  44973. }
  44974. }
  44975. public function mkdir($dirs, $mode = 0777)
  44976. {
  44977. foreach ($this->toIterator($dirs) as $dir) {
  44978. if (is_dir($dir)) {
  44979. continue;
  44980. }
  44981. if (!self::box('mkdir', $dir, $mode, true)) {
  44982. if (!is_dir($dir)) {
  44983. if (self::$lastError) {
  44984. throw new IOException(sprintf('Failed to create "%s": %s.', $dir, self::$lastError), 0, null, $dir);
  44985. }
  44986. throw new IOException(sprintf('Failed to create "%s"', $dir), 0, null, $dir);
  44987. }
  44988. }
  44989. }
  44990. }
  44991. public function exists($files)
  44992. {
  44993. $maxPathLength = PHP_MAXPATHLEN - 2;
  44994. foreach ($this->toIterator($files) as $file) {
  44995. if (\strlen($file) > $maxPathLength) {
  44996. throw new IOException(sprintf('Could not check if file exist because path length exceeds %d characters.', $maxPathLength), 0, null, $file);
  44997. }
  44998. if (!file_exists($file)) {
  44999. return false;
  45000. }
  45001. }
  45002. return true;
  45003. }
  45004. public function touch($files, $time = null, $atime = null)
  45005. {
  45006. foreach ($this->toIterator($files) as $file) {
  45007. $touch = $time ? @touch($file, $time, $atime) : @touch($file);
  45008. if (true !== $touch) {
  45009. throw new IOException(sprintf('Failed to touch "%s".', $file), 0, null, $file);
  45010. }
  45011. }
  45012. }
  45013. public function remove($files)
  45014. {
  45015. if ($files instanceof \Traversable) {
  45016. $files = iterator_to_array($files, false);
  45017. } elseif (!\is_array($files)) {
  45018. $files = array($files);
  45019. }
  45020. $files = array_reverse($files);
  45021. foreach ($files as $file) {
  45022. if (is_link($file)) {
  45023. if (!(self::box('unlink', $file) || '\\' !== \DIRECTORY_SEPARATOR || self::box('rmdir', $file)) && file_exists($file)) {
  45024. throw new IOException(sprintf('Failed to remove symlink "%s": %s.', $file, self::$lastError));
  45025. }
  45026. } elseif (is_dir($file)) {
  45027. $this->remove(new \FilesystemIterator($file, \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS));
  45028. if (!self::box('rmdir', $file) && file_exists($file)) {
  45029. throw new IOException(sprintf('Failed to remove directory "%s": %s.', $file, self::$lastError));
  45030. }
  45031. } elseif (!self::box('unlink', $file) && file_exists($file)) {
  45032. throw new IOException(sprintf('Failed to remove file "%s": %s.', $file, self::$lastError));
  45033. }
  45034. }
  45035. }
  45036. public function chmod($files, $mode, $umask = 0000, $recursive = false)
  45037. {
  45038. foreach ($this->toIterator($files) as $file) {
  45039. if (true !== @chmod($file, $mode & ~$umask)) {
  45040. throw new IOException(sprintf('Failed to chmod file "%s".', $file), 0, null, $file);
  45041. }
  45042. if ($recursive && is_dir($file) && !is_link($file)) {
  45043. $this->chmod(new \FilesystemIterator($file), $mode, $umask, true);
  45044. }
  45045. }
  45046. }
  45047. public function chown($files, $user, $recursive = false)
  45048. {
  45049. foreach ($this->toIterator($files) as $file) {
  45050. if ($recursive && is_dir($file) && !is_link($file)) {
  45051. $this->chown(new \FilesystemIterator($file), $user, true);
  45052. }
  45053. if (is_link($file) && \function_exists('lchown')) {
  45054. if (true !== @lchown($file, $user)) {
  45055. throw new IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
  45056. }
  45057. } else {
  45058. if (true !== @chown($file, $user)) {
  45059. throw new IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
  45060. }
  45061. }
  45062. }
  45063. }
  45064. public function chgrp($files, $group, $recursive = false)
  45065. {
  45066. foreach ($this->toIterator($files) as $file) {
  45067. if ($recursive && is_dir($file) && !is_link($file)) {
  45068. $this->chgrp(new \FilesystemIterator($file), $group, true);
  45069. }
  45070. if (is_link($file) && \function_exists('lchgrp')) {
  45071. if (true !== @lchgrp($file, $group) || (\defined('HHVM_VERSION') && !posix_getgrnam($group))) {
  45072. throw new IOException(sprintf('Failed to chgrp file "%s".', $file), 0, null, $file);
  45073. }
  45074. } else {
  45075. if (true !== @chgrp($file, $group)) {
  45076. throw new IOException(sprintf('Failed to chgrp file "%s".', $file), 0, null, $file);
  45077. }
  45078. }
  45079. }
  45080. }
  45081. public function rename($origin, $target, $overwrite = false)
  45082. {
  45083. if (!$overwrite && $this->isReadable($target)) {
  45084. throw new IOException(sprintf('Cannot rename because the target "%s" already exists.', $target), 0, null, $target);
  45085. }
  45086. if (true !== @rename($origin, $target)) {
  45087. if (is_dir($origin)) {
  45088. $this->mirror($origin, $target, null, array('override' => $overwrite, 'delete' => $overwrite));
  45089. $this->remove($origin);
  45090. return;
  45091. }
  45092. throw new IOException(sprintf('Cannot rename "%s" to "%s".', $origin, $target), 0, null, $target);
  45093. }
  45094. }
  45095. private function isReadable($filename)
  45096. {
  45097. $maxPathLength = PHP_MAXPATHLEN - 2;
  45098. if (\strlen($filename) > $maxPathLength) {
  45099. throw new IOException(sprintf('Could not check if file is readable because path length exceeds %d characters.', $maxPathLength), 0, null, $filename);
  45100. }
  45101. return is_readable($filename);
  45102. }
  45103. public function symlink($originDir, $targetDir, $copyOnWindows = false)
  45104. {
  45105. if ('\\' === \DIRECTORY_SEPARATOR) {
  45106. $originDir = strtr($originDir, '/', '\\');
  45107. $targetDir = strtr($targetDir, '/', '\\');
  45108. if ($copyOnWindows) {
  45109. $this->mirror($originDir, $targetDir);
  45110. return;
  45111. }
  45112. }
  45113. $this->mkdir(\dirname($targetDir));
  45114. if (is_link($targetDir)) {
  45115. if (readlink($targetDir) === $originDir) {
  45116. return;
  45117. }
  45118. $this->remove($targetDir);
  45119. }
  45120. if (!self::box('symlink', $originDir, $targetDir)) {
  45121. if (null !== self::$lastError) {
  45122. if ('\\' === \DIRECTORY_SEPARATOR && false !== strpos(self::$lastError, 'error code(1314)')) {
  45123. 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);
  45124. }
  45125. }
  45126. throw new IOException(sprintf('Failed to create symbolic link from "%s" to "%s".', $originDir, $targetDir), 0, null, $targetDir);
  45127. }
  45128. }
  45129. public function makePathRelative($endPath, $startPath)
  45130. {
  45131. if ('\\' === \DIRECTORY_SEPARATOR) {
  45132. $endPath = str_replace('\\', '/', $endPath);
  45133. $startPath = str_replace('\\', '/', $startPath);
  45134. }
  45135. $stripDriveLetter = function ($path) {
  45136. if (\strlen($path) > 2 && ':' === $path[1] && '/' === $path[2] && ctype_alpha($path[0])) {
  45137. return substr($path, 2);
  45138. }
  45139. return $path;
  45140. };
  45141. $endPath = $stripDriveLetter($endPath);
  45142. $startPath = $stripDriveLetter($startPath);
  45143. $startPathArr = explode('/', trim($startPath, '/'));
  45144. $endPathArr = explode('/', trim($endPath, '/'));
  45145. $normalizePathArray = function ($pathSegments, $absolute) {
  45146. $result = array();
  45147. foreach ($pathSegments as $segment) {
  45148. if ('..' === $segment && ($absolute || \count($result))) {
  45149. array_pop($result);
  45150. } elseif ('.' !== $segment) {
  45151. $result[] = $segment;
  45152. }
  45153. }
  45154. return $result;
  45155. };
  45156. $startPathArr = $normalizePathArray($startPathArr, static::isAbsolutePath($startPath));
  45157. $endPathArr = $normalizePathArray($endPathArr, static::isAbsolutePath($endPath));
  45158. $index = 0;
  45159. while (isset($startPathArr[$index]) && isset($endPathArr[$index]) && $startPathArr[$index] === $endPathArr[$index]) {
  45160. ++$index;
  45161. }
  45162. if (1 === \count($startPathArr) && '' === $startPathArr[0]) {
  45163. $depth = 0;
  45164. } else {
  45165. $depth = \count($startPathArr) - $index;
  45166. }
  45167. $traverser = str_repeat('../', $depth);
  45168. $endPathRemainder = implode('/', \array_slice($endPathArr, $index));
  45169. $relativePath = $traverser.('' !== $endPathRemainder ? $endPathRemainder.'/' : '');
  45170. return '' === $relativePath ? './' : $relativePath;
  45171. }
  45172. public function mirror($originDir, $targetDir, \Traversable $iterator = null, $options = array())
  45173. {
  45174. $targetDir = rtrim($targetDir, '/\\');
  45175. $originDir = rtrim($originDir, '/\\');
  45176. $originDirLen = \strlen($originDir);
  45177. if ($this->exists($targetDir) && isset($options['delete']) && $options['delete']) {
  45178. $deleteIterator = $iterator;
  45179. if (null === $deleteIterator) {
  45180. $flags = \FilesystemIterator::SKIP_DOTS;
  45181. $deleteIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($targetDir, $flags), \RecursiveIteratorIterator::CHILD_FIRST);
  45182. }
  45183. $targetDirLen = \strlen($targetDir);
  45184. foreach ($deleteIterator as $file) {
  45185. $origin = $originDir.substr($file->getPathname(), $targetDirLen);
  45186. if (!$this->exists($origin)) {
  45187. $this->remove($file);
  45188. }
  45189. }
  45190. }
  45191. $copyOnWindows = false;
  45192. if (isset($options['copy_on_windows'])) {
  45193. $copyOnWindows = $options['copy_on_windows'];
  45194. }
  45195. if (null === $iterator) {
  45196. $flags = $copyOnWindows ? \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS : \FilesystemIterator::SKIP_DOTS;
  45197. $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($originDir, $flags), \RecursiveIteratorIterator::SELF_FIRST);
  45198. }
  45199. if ($this->exists($originDir)) {
  45200. $this->mkdir($targetDir);
  45201. }
  45202. foreach ($iterator as $file) {
  45203. $target = $targetDir.substr($file->getPathname(), $originDirLen);
  45204. if ($copyOnWindows) {
  45205. if (is_file($file)) {
  45206. $this->copy($file, $target, isset($options['override']) ? $options['override'] : false);
  45207. } elseif (is_dir($file)) {
  45208. $this->mkdir($target);
  45209. } else {
  45210. throw new IOException(sprintf('Unable to guess "%s" file type.', $file), 0, null, $file);
  45211. }
  45212. } else {
  45213. if (is_link($file)) {
  45214. $this->symlink($file->getLinkTarget(), $target);
  45215. } elseif (is_dir($file)) {
  45216. $this->mkdir($target);
  45217. } elseif (is_file($file)) {
  45218. $this->copy($file, $target, isset($options['override']) ? $options['override'] : false);
  45219. } else {
  45220. throw new IOException(sprintf('Unable to guess "%s" file type.', $file), 0, null, $file);
  45221. }
  45222. }
  45223. }
  45224. }
  45225. public function isAbsolutePath($file)
  45226. {
  45227. return strspn($file, '/\\', 0, 1)
  45228. || (\strlen($file) > 3 && ctype_alpha($file[0])
  45229. && ':' === substr($file, 1, 1)
  45230. && strspn($file, '/\\', 2, 1)
  45231. )
  45232. || null !== parse_url($file, PHP_URL_SCHEME)
  45233. ;
  45234. }
  45235. public function tempnam($dir, $prefix)
  45236. {
  45237. list($scheme, $hierarchy) = $this->getSchemeAndHierarchy($dir);
  45238. if (null === $scheme || 'file' === $scheme || 'gs' === $scheme) {
  45239. $tmpFile = @tempnam($hierarchy, $prefix);
  45240. if (false !== $tmpFile) {
  45241. if (null !== $scheme && 'gs' !== $scheme) {
  45242. return $scheme.'://'.$tmpFile;
  45243. }
  45244. return $tmpFile;
  45245. }
  45246. throw new IOException('A temporary file could not be created.');
  45247. }
  45248. for ($i = 0; $i < 10; ++$i) {
  45249. $tmpFile = $dir.'/'.$prefix.uniqid(mt_rand(), true);
  45250. $handle = @fopen($tmpFile, 'x+');
  45251. if (false === $handle) {
  45252. continue;
  45253. }
  45254. @fclose($handle);
  45255. return $tmpFile;
  45256. }
  45257. throw new IOException('A temporary file could not be created.');
  45258. }
  45259. public function dumpFile($filename, $content, $mode = 0666)
  45260. {
  45261. $dir = \dirname($filename);
  45262. if (!is_dir($dir)) {
  45263. $this->mkdir($dir);
  45264. }
  45265. if (!is_writable($dir)) {
  45266. throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir);
  45267. }
  45268. $tmpFile = $this->tempnam($dir, basename($filename));
  45269. if (false === @file_put_contents($tmpFile, $content)) {
  45270. throw new IOException(sprintf('Failed to write file "%s".', $filename), 0, null, $filename);
  45271. }
  45272. if (null !== $mode) {
  45273. if (\func_num_args() > 2) {
  45274. @trigger_error('Support for modifying file permissions is deprecated since Symfony 2.3.12 and will be removed in 3.0.', E_USER_DEPRECATED);
  45275. }
  45276. $this->chmod($tmpFile, $mode);
  45277. } elseif (file_exists($filename)) {
  45278. @chmod($tmpFile, fileperms($filename));
  45279. }
  45280. $this->rename($tmpFile, $filename, true);
  45281. }
  45282. private function toIterator($files)
  45283. {
  45284. if (!$files instanceof \Traversable) {
  45285. $files = new \ArrayObject(\is_array($files) ? $files : array($files));
  45286. }
  45287. return $files;
  45288. }
  45289. private function getSchemeAndHierarchy($filename)
  45290. {
  45291. $components = explode('://', $filename, 2);
  45292. return 2 === \count($components) ? array($components[0], $components[1]) : array(null, $components[0]);
  45293. }
  45294. private static function box($func)
  45295. {
  45296. self::$lastError = null;
  45297. \set_error_handler(__CLASS__.'::handleError');
  45298. try {
  45299. $result = \call_user_func_array($func, \array_slice(\func_get_args(), 1));
  45300. \restore_error_handler();
  45301. return $result;
  45302. } catch (\Throwable $e) {
  45303. } catch (\Exception $e) {
  45304. }
  45305. \restore_error_handler();
  45306. throw $e;
  45307. }
  45308. public static function handleError($type, $msg)
  45309. {
  45310. self::$lastError = $msg;
  45311. }
  45312. }
  45313. Copyright (c) 2004-2018 Fabien Potencier
  45314. Permission is hereby granted, free of charge, to any person obtaining a copy
  45315. of this software and associated documentation files (the "Software"), to deal
  45316. in the Software without restriction, including without limitation the rights
  45317. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  45318. copies of the Software, and to permit persons to whom the Software is furnished
  45319. to do so, subject to the following conditions:
  45320. The above copyright notice and this permission notice shall be included in all
  45321. copies or substantial portions of the Software.
  45322. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  45323. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  45324. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  45325. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  45326. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  45327. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  45328. THE SOFTWARE.
  45329. <?php
  45330. namespace Symfony\Component\Filesystem;
  45331. use Symfony\Component\Filesystem\Exception\IOException;
  45332. class LockHandler
  45333. {
  45334. private $file;
  45335. private $handle;
  45336. public function __construct($name, $lockPath = null)
  45337. {
  45338. $lockPath = $lockPath ?: sys_get_temp_dir();
  45339. if (!is_dir($lockPath)) {
  45340. $fs = new Filesystem();
  45341. $fs->mkdir($lockPath);
  45342. }
  45343. if (!is_writable($lockPath)) {
  45344. throw new IOException(sprintf('The directory "%s" is not writable.', $lockPath), 0, null, $lockPath);
  45345. }
  45346. $this->file = sprintf('%s/sf.%s.%s.lock', $lockPath, preg_replace('/[^a-z0-9\._-]+/i', '-', $name), hash('sha256', $name));
  45347. }
  45348. public function lock($blocking = false)
  45349. {
  45350. if ($this->handle) {
  45351. return true;
  45352. }
  45353. $error = null;
  45354. set_error_handler(function ($errno, $msg) use (&$error) {
  45355. $error = $msg;
  45356. });
  45357. if (!$this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r')) {
  45358. if ($this->handle = fopen($this->file, 'x')) {
  45359. chmod($this->file, 0666);
  45360. } elseif (!$this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r')) {
  45361. usleep(100);
  45362. $this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r');
  45363. }
  45364. }
  45365. restore_error_handler();
  45366. if (!$this->handle) {
  45367. throw new IOException($error, 0, null, $this->file);
  45368. }
  45369. if (!flock($this->handle, LOCK_EX | ($blocking ? 0 : LOCK_NB))) {
  45370. fclose($this->handle);
  45371. $this->handle = null;
  45372. return false;
  45373. }
  45374. return true;
  45375. }
  45376. public function release()
  45377. {
  45378. if ($this->handle) {
  45379. flock($this->handle, LOCK_UN | LOCK_NB);
  45380. fclose($this->handle);
  45381. $this->handle = null;
  45382. }
  45383. }
  45384. }
  45385. <?php
  45386. namespace Symfony\Component\Finder\Adapter;
  45387. @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);
  45388. abstract class AbstractAdapter implements AdapterInterface
  45389. {
  45390. protected $followLinks = false;
  45391. protected $mode = 0;
  45392. protected $minDepth = 0;
  45393. protected $maxDepth = PHP_INT_MAX;
  45394. protected $exclude = array();
  45395. protected $names = array();
  45396. protected $notNames = array();
  45397. protected $contains = array();
  45398. protected $notContains = array();
  45399. protected $sizes = array();
  45400. protected $dates = array();
  45401. protected $filters = array();
  45402. protected $sort = false;
  45403. protected $paths = array();
  45404. protected $notPaths = array();
  45405. protected $ignoreUnreadableDirs = false;
  45406. private static $areSupported = array();
  45407. public function isSupported()
  45408. {
  45409. $name = $this->getName();
  45410. if (!array_key_exists($name, self::$areSupported)) {
  45411. self::$areSupported[$name] = $this->canBeUsed();
  45412. }
  45413. return self::$areSupported[$name];
  45414. }
  45415. public function setFollowLinks($followLinks)
  45416. {
  45417. $this->followLinks = $followLinks;
  45418. return $this;
  45419. }
  45420. public function setMode($mode)
  45421. {
  45422. $this->mode = $mode;
  45423. return $this;
  45424. }
  45425. public function setDepths(array $depths)
  45426. {
  45427. $this->minDepth = 0;
  45428. $this->maxDepth = PHP_INT_MAX;
  45429. foreach ($depths as $comparator) {
  45430. switch ($comparator->getOperator()) {
  45431. case '>':
  45432. $this->minDepth = $comparator->getTarget() + 1;
  45433. break;
  45434. case '>=':
  45435. $this->minDepth = $comparator->getTarget();
  45436. break;
  45437. case '<':
  45438. $this->maxDepth = $comparator->getTarget() - 1;
  45439. break;
  45440. case '<=':
  45441. $this->maxDepth = $comparator->getTarget();
  45442. break;
  45443. default:
  45444. $this->minDepth = $this->maxDepth = $comparator->getTarget();
  45445. }
  45446. }
  45447. return $this;
  45448. }
  45449. public function setExclude(array $exclude)
  45450. {
  45451. $this->exclude = $exclude;
  45452. return $this;
  45453. }
  45454. public function setNames(array $names)
  45455. {
  45456. $this->names = $names;
  45457. return $this;
  45458. }
  45459. public function setNotNames(array $notNames)
  45460. {
  45461. $this->notNames = $notNames;
  45462. return $this;
  45463. }
  45464. public function setContains(array $contains)
  45465. {
  45466. $this->contains = $contains;
  45467. return $this;
  45468. }
  45469. public function setNotContains(array $notContains)
  45470. {
  45471. $this->notContains = $notContains;
  45472. return $this;
  45473. }
  45474. public function setSizes(array $sizes)
  45475. {
  45476. $this->sizes = $sizes;
  45477. return $this;
  45478. }
  45479. public function setDates(array $dates)
  45480. {
  45481. $this->dates = $dates;
  45482. return $this;
  45483. }
  45484. public function setFilters(array $filters)
  45485. {
  45486. $this->filters = $filters;
  45487. return $this;
  45488. }
  45489. public function setSort($sort)
  45490. {
  45491. $this->sort = $sort;
  45492. return $this;
  45493. }
  45494. public function setPath(array $paths)
  45495. {
  45496. $this->paths = $paths;
  45497. return $this;
  45498. }
  45499. public function setNotPath(array $notPaths)
  45500. {
  45501. $this->notPaths = $notPaths;
  45502. return $this;
  45503. }
  45504. public function ignoreUnreadableDirs($ignore = true)
  45505. {
  45506. $this->ignoreUnreadableDirs = (bool) $ignore;
  45507. return $this;
  45508. }
  45509. abstract protected function canBeUsed();
  45510. }
  45511. <?php
  45512. namespace Symfony\Component\Finder\Adapter;
  45513. @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);
  45514. use Symfony\Component\Finder\Comparator\DateComparator;
  45515. use Symfony\Component\Finder\Comparator\NumberComparator;
  45516. use Symfony\Component\Finder\Exception\AccessDeniedException;
  45517. use Symfony\Component\Finder\Expression\Expression;
  45518. use Symfony\Component\Finder\Iterator;
  45519. use Symfony\Component\Finder\Shell\Command;
  45520. use Symfony\Component\Finder\Shell\Shell;
  45521. abstract class AbstractFindAdapter extends AbstractAdapter
  45522. {
  45523. protected $shell;
  45524. public function __construct()
  45525. {
  45526. $this->shell = new Shell();
  45527. }
  45528. public function searchInDirectory($dir)
  45529. {
  45530. $dir = realpath($dir);
  45531. if (Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES === $this->mode && ($this->contains || $this->notContains)) {
  45532. return new Iterator\FilePathsIterator(array(), $dir);
  45533. }
  45534. $command = Command::create();
  45535. $find = $this->buildFindCommand($command, $dir);
  45536. if ($this->followLinks) {
  45537. $find->add('-follow');
  45538. }
  45539. $find->add('-mindepth')->add($this->minDepth + 1);
  45540. if (PHP_INT_MAX !== $this->maxDepth) {
  45541. $find->add('-maxdepth')->add($this->maxDepth + 1);
  45542. }
  45543. if (Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES === $this->mode) {
  45544. $find->add('-type d');
  45545. } elseif (Iterator\FileTypeFilterIterator::ONLY_FILES === $this->mode) {
  45546. $find->add('-type f');
  45547. }
  45548. $this->buildNamesFiltering($find, $this->names);
  45549. $this->buildNamesFiltering($find, $this->notNames, true);
  45550. $this->buildPathsFiltering($find, $dir, $this->paths);
  45551. $this->buildPathsFiltering($find, $dir, $this->notPaths, true);
  45552. $this->buildSizesFiltering($find, $this->sizes);
  45553. $this->buildDatesFiltering($find, $this->dates);
  45554. $useGrep = $this->shell->testCommand('grep') && $this->shell->testCommand('xargs');
  45555. $useSort = \is_int($this->sort) && $this->shell->testCommand('sort') && $this->shell->testCommand('cut');
  45556. if ($useGrep && ($this->contains || $this->notContains)) {
  45557. $grep = $command->ins('grep');
  45558. $this->buildContentFiltering($grep, $this->contains);
  45559. $this->buildContentFiltering($grep, $this->notContains, true);
  45560. }
  45561. if ($useSort) {
  45562. $this->buildSorting($command, $this->sort);
  45563. }
  45564. $command->setErrorHandler(
  45565. $this->ignoreUnreadableDirs
  45566. ? function ($stderr) { }
  45567. : function ($stderr) { throw new AccessDeniedException($stderr); }
  45568. );
  45569. $paths = $this->shell->testCommand('uniq') ? $command->add('| uniq')->execute() : array_unique($command->execute());
  45570. $iterator = new Iterator\FilePathsIterator($paths, $dir);
  45571. if ($this->exclude) {
  45572. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  45573. }
  45574. if (!$useGrep && ($this->contains || $this->notContains)) {
  45575. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  45576. }
  45577. if ($this->filters) {
  45578. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  45579. }
  45580. if (!$useSort && $this->sort) {
  45581. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  45582. $iterator = $iteratorAggregate->getIterator();
  45583. }
  45584. return $iterator;
  45585. }
  45586. protected function canBeUsed()
  45587. {
  45588. return $this->shell->testCommand('find');
  45589. }
  45590. protected function buildFindCommand(Command $command, $dir)
  45591. {
  45592. return $command
  45593. ->ins('find')
  45594. ->add('find ')
  45595. ->arg($dir)
  45596. ->add('-noleaf');
  45597. }
  45598. private function buildNamesFiltering(Command $command, array $names, $not = false)
  45599. {
  45600. if (0 === \count($names)) {
  45601. return;
  45602. }
  45603. $command->add($not ? '-not' : null)->cmd('(');
  45604. foreach ($names as $i => $name) {
  45605. $expr = Expression::create($name);
  45606. if ($expr->isGlob() && $expr->getGlob()->isExpandable()) {
  45607. $expr = Expression::create($expr->getGlob()->toRegex(false));
  45608. }
  45609. if ($expr->isRegex()) {
  45610. $regex = $expr->getRegex();
  45611. $regex->prepend($regex->hasStartFlag() ? '/' : '/[^/]*')
  45612. ->setStartFlag(false)
  45613. ->setStartJoker(true)
  45614. ->replaceJokers('[^/]');
  45615. if (!$regex->hasEndFlag() || $regex->hasEndJoker()) {
  45616. $regex->setEndJoker(false)->append('[^/]*');
  45617. }
  45618. }
  45619. $command
  45620. ->add($i > 0 ? '-or' : null)
  45621. ->add($expr->isRegex()
  45622. ? ($expr->isCaseSensitive() ? '-regex' : '-iregex')
  45623. : ($expr->isCaseSensitive() ? '-name' : '-iname')
  45624. )
  45625. ->arg($expr->renderPattern());
  45626. }
  45627. $command->cmd(')');
  45628. }
  45629. private function buildPathsFiltering(Command $command, $dir, array $paths, $not = false)
  45630. {
  45631. if (0 === \count($paths)) {
  45632. return;
  45633. }
  45634. $command->add($not ? '-not' : null)->cmd('(');
  45635. foreach ($paths as $i => $path) {
  45636. $expr = Expression::create($path);
  45637. if ($expr->isGlob() && $expr->getGlob()->isExpandable()) {
  45638. $expr = Expression::create($expr->getGlob()->toRegex(false));
  45639. }
  45640. if ($expr->isRegex()) {
  45641. $regex = $expr->getRegex();
  45642. $regex->prepend($regex->hasStartFlag() ? preg_quote($dir).\DIRECTORY_SEPARATOR : '.*')->setEndJoker(!$regex->hasEndFlag());
  45643. } else {
  45644. $expr->prepend('*')->append('*');
  45645. }
  45646. $command
  45647. ->add($i > 0 ? '-or' : null)
  45648. ->add($expr->isRegex()
  45649. ? ($expr->isCaseSensitive() ? '-regex' : '-iregex')
  45650. : ($expr->isCaseSensitive() ? '-path' : '-ipath')
  45651. )
  45652. ->arg($expr->renderPattern());
  45653. }
  45654. $command->cmd(')');
  45655. }
  45656. private function buildSizesFiltering(Command $command, array $sizes)
  45657. {
  45658. foreach ($sizes as $i => $size) {
  45659. $command->add($i > 0 ? '-and' : null);
  45660. switch ($size->getOperator()) {
  45661. case '<=':
  45662. $command->add('-size -'.($size->getTarget() + 1).'c');
  45663. break;
  45664. case '>=':
  45665. $command->add('-size +'.($size->getTarget() - 1).'c');
  45666. break;
  45667. case '>':
  45668. $command->add('-size +'.$size->getTarget().'c');
  45669. break;
  45670. case '!=':
  45671. $command->add('-size -'.$size->getTarget().'c');
  45672. $command->add('-size +'.$size->getTarget().'c');
  45673. break;
  45674. case '<':
  45675. default:
  45676. $command->add('-size -'.$size->getTarget().'c');
  45677. }
  45678. }
  45679. }
  45680. private function buildDatesFiltering(Command $command, array $dates)
  45681. {
  45682. foreach ($dates as $i => $date) {
  45683. $command->add($i > 0 ? '-and' : null);
  45684. $mins = (int) round((time() - $date->getTarget()) / 60);
  45685. if (0 > $mins) {
  45686. $command->add(' -mmin -0');
  45687. return;
  45688. }
  45689. switch ($date->getOperator()) {
  45690. case '<=':
  45691. $command->add('-mmin +'.($mins - 1));
  45692. break;
  45693. case '>=':
  45694. $command->add('-mmin -'.($mins + 1));
  45695. break;
  45696. case '>':
  45697. $command->add('-mmin -'.$mins);
  45698. break;
  45699. case '!=':
  45700. $command->add('-mmin +'.$mins.' -or -mmin -'.$mins);
  45701. break;
  45702. case '<':
  45703. default:
  45704. $command->add('-mmin +'.$mins);
  45705. }
  45706. }
  45707. }
  45708. private function buildSorting(Command $command, $sort)
  45709. {
  45710. $this->buildFormatSorting($command, $sort);
  45711. }
  45712. abstract protected function buildFormatSorting(Command $command, $sort);
  45713. abstract protected function buildContentFiltering(Command $command, array $contains, $not = false);
  45714. }
  45715. <?php
  45716. namespace Symfony\Component\Finder\Adapter;
  45717. interface AdapterInterface
  45718. {
  45719. public function setFollowLinks($followLinks);
  45720. public function setMode($mode);
  45721. public function setExclude(array $exclude);
  45722. public function setDepths(array $depths);
  45723. public function setNames(array $names);
  45724. public function setNotNames(array $notNames);
  45725. public function setContains(array $contains);
  45726. public function setNotContains(array $notContains);
  45727. public function setSizes(array $sizes);
  45728. public function setDates(array $dates);
  45729. public function setFilters(array $filters);
  45730. public function setSort($sort);
  45731. public function setPath(array $paths);
  45732. public function setNotPath(array $notPaths);
  45733. public function ignoreUnreadableDirs($ignore = true);
  45734. public function searchInDirectory($dir);
  45735. public function isSupported();
  45736. public function getName();
  45737. }
  45738. <?php
  45739. namespace Symfony\Component\Finder\Adapter;
  45740. @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);
  45741. use Symfony\Component\Finder\Expression\Expression;
  45742. use Symfony\Component\Finder\Iterator\SortableIterator;
  45743. use Symfony\Component\Finder\Shell\Command;
  45744. use Symfony\Component\Finder\Shell\Shell;
  45745. class BsdFindAdapter extends AbstractFindAdapter
  45746. {
  45747. public function getName()
  45748. {
  45749. return 'bsd_find';
  45750. }
  45751. protected function canBeUsed()
  45752. {
  45753. return \in_array($this->shell->getType(), array(Shell::TYPE_BSD, Shell::TYPE_DARWIN)) && parent::canBeUsed();
  45754. }
  45755. protected function buildFormatSorting(Command $command, $sort)
  45756. {
  45757. switch ($sort) {
  45758. case SortableIterator::SORT_BY_NAME:
  45759. $command->ins('sort')->add('| sort');
  45760. return;
  45761. case SortableIterator::SORT_BY_TYPE:
  45762. $format = '%HT';
  45763. break;
  45764. case SortableIterator::SORT_BY_ACCESSED_TIME:
  45765. $format = '%a';
  45766. break;
  45767. case SortableIterator::SORT_BY_CHANGED_TIME:
  45768. $format = '%c';
  45769. break;
  45770. case SortableIterator::SORT_BY_MODIFIED_TIME:
  45771. $format = '%m';
  45772. break;
  45773. default:
  45774. throw new \InvalidArgumentException(sprintf('Unknown sort options: %s.', $sort));
  45775. }
  45776. $command
  45777. ->add('-print0 | xargs -0 stat -f')
  45778. ->arg($format.'%t%N')
  45779. ->add('| sort | cut -f 2');
  45780. }
  45781. protected function buildFindCommand(Command $command, $dir)
  45782. {
  45783. parent::buildFindCommand($command, $dir)->addAtIndex('-E', 1);
  45784. return $command;
  45785. }
  45786. protected function buildContentFiltering(Command $command, array $contains, $not = false)
  45787. {
  45788. foreach ($contains as $contain) {
  45789. $expr = Expression::create($contain);
  45790. $command
  45791. ->add('| grep -v \'^$\'')
  45792. ->add('| xargs -I{} grep -I')
  45793. ->add($expr->isCaseSensitive() ? null : '-i')
  45794. ->add($not ? '-L' : '-l')
  45795. ->add('-Ee')->arg($expr->renderPattern())
  45796. ->add('{}')
  45797. ;
  45798. }
  45799. }
  45800. }
  45801. <?php
  45802. namespace Symfony\Component\Finder\Adapter;
  45803. @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);
  45804. use Symfony\Component\Finder\Expression\Expression;
  45805. use Symfony\Component\Finder\Iterator\SortableIterator;
  45806. use Symfony\Component\Finder\Shell\Command;
  45807. use Symfony\Component\Finder\Shell\Shell;
  45808. class GnuFindAdapter extends AbstractFindAdapter
  45809. {
  45810. public function getName()
  45811. {
  45812. return 'gnu_find';
  45813. }
  45814. protected function buildFormatSorting(Command $command, $sort)
  45815. {
  45816. switch ($sort) {
  45817. case SortableIterator::SORT_BY_NAME:
  45818. $command->ins('sort')->add('| sort');
  45819. return;
  45820. case SortableIterator::SORT_BY_TYPE:
  45821. $format = '%y';
  45822. break;
  45823. case SortableIterator::SORT_BY_ACCESSED_TIME:
  45824. $format = '%A@';
  45825. break;
  45826. case SortableIterator::SORT_BY_CHANGED_TIME:
  45827. $format = '%C@';
  45828. break;
  45829. case SortableIterator::SORT_BY_MODIFIED_TIME:
  45830. $format = '%T@';
  45831. break;
  45832. default:
  45833. throw new \InvalidArgumentException(sprintf('Unknown sort options: %s.', $sort));
  45834. }
  45835. $command
  45836. ->get('find')
  45837. ->add('-printf')
  45838. ->arg($format.' %h/%f\\n')
  45839. ->add('| sort | cut')
  45840. ->arg('-d ')
  45841. ->arg('-f2-')
  45842. ;
  45843. }
  45844. protected function canBeUsed()
  45845. {
  45846. return Shell::TYPE_UNIX === $this->shell->getType() && parent::canBeUsed();
  45847. }
  45848. protected function buildFindCommand(Command $command, $dir)
  45849. {
  45850. return parent::buildFindCommand($command, $dir)->add('-regextype posix-extended');
  45851. }
  45852. protected function buildContentFiltering(Command $command, array $contains, $not = false)
  45853. {
  45854. foreach ($contains as $contain) {
  45855. $expr = Expression::create($contain);
  45856. $command
  45857. ->add('| xargs -I{} -r grep -I')
  45858. ->add($expr->isCaseSensitive() ? null : '-i')
  45859. ->add($not ? '-L' : '-l')
  45860. ->add('-Ee')->arg($expr->renderPattern())
  45861. ->add('{}')
  45862. ;
  45863. }
  45864. }
  45865. }
  45866. <?php
  45867. namespace Symfony\Component\Finder\Adapter;
  45868. @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);
  45869. use Symfony\Component\Finder\Iterator;
  45870. class PhpAdapter extends AbstractAdapter
  45871. {
  45872. public function searchInDirectory($dir)
  45873. {
  45874. $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
  45875. if ($this->followLinks) {
  45876. $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
  45877. }
  45878. $iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
  45879. if ($this->exclude) {
  45880. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  45881. }
  45882. $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
  45883. if ($this->minDepth > 0 || $this->maxDepth < PHP_INT_MAX) {
  45884. $iterator = new Iterator\DepthRangeFilterIterator($iterator, $this->minDepth, $this->maxDepth);
  45885. }
  45886. if ($this->mode) {
  45887. $iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
  45888. }
  45889. if ($this->names || $this->notNames) {
  45890. $iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
  45891. }
  45892. if ($this->contains || $this->notContains) {
  45893. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  45894. }
  45895. if ($this->sizes) {
  45896. $iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
  45897. }
  45898. if ($this->dates) {
  45899. $iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
  45900. }
  45901. if ($this->filters) {
  45902. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  45903. }
  45904. if ($this->paths || $this->notPaths) {
  45905. $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
  45906. }
  45907. if ($this->sort) {
  45908. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  45909. $iterator = $iteratorAggregate->getIterator();
  45910. }
  45911. return $iterator;
  45912. }
  45913. public function getName()
  45914. {
  45915. return 'php';
  45916. }
  45917. protected function canBeUsed()
  45918. {
  45919. return true;
  45920. }
  45921. }
  45922. <?php
  45923. namespace Symfony\Component\Finder\Comparator;
  45924. class Comparator
  45925. {
  45926. private $target;
  45927. private $operator = '==';
  45928. public function getTarget()
  45929. {
  45930. return $this->target;
  45931. }
  45932. public function setTarget($target)
  45933. {
  45934. $this->target = $target;
  45935. }
  45936. public function getOperator()
  45937. {
  45938. return $this->operator;
  45939. }
  45940. public function setOperator($operator)
  45941. {
  45942. if (!$operator) {
  45943. $operator = '==';
  45944. }
  45945. if (!\in_array($operator, array('>', '<', '>=', '<=', '==', '!='))) {
  45946. throw new \InvalidArgumentException(sprintf('Invalid operator "%s".', $operator));
  45947. }
  45948. $this->operator = $operator;
  45949. }
  45950. public function test($test)
  45951. {
  45952. switch ($this->operator) {
  45953. case '>':
  45954. return $test > $this->target;
  45955. case '>=':
  45956. return $test >= $this->target;
  45957. case '<':
  45958. return $test < $this->target;
  45959. case '<=':
  45960. return $test <= $this->target;
  45961. case '!=':
  45962. return $test != $this->target;
  45963. }
  45964. return $test == $this->target;
  45965. }
  45966. }
  45967. <?php
  45968. namespace Symfony\Component\Finder\Comparator;
  45969. class DateComparator extends Comparator
  45970. {
  45971. public function __construct($test)
  45972. {
  45973. if (!preg_match('#^\s*(==|!=|[<>]=?|after|since|before|until)?\s*(.+?)\s*$#i', $test, $matches)) {
  45974. throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a date test.', $test));
  45975. }
  45976. try {
  45977. $date = new \DateTime($matches[2]);
  45978. $target = $date->format('U');
  45979. } catch (\Exception $e) {
  45980. throw new \InvalidArgumentException(sprintf('"%s" is not a valid date.', $matches[2]));
  45981. }
  45982. $operator = isset($matches[1]) ? $matches[1] : '==';
  45983. if ('since' === $operator || 'after' === $operator) {
  45984. $operator = '>';
  45985. }
  45986. if ('until' === $operator || 'before' === $operator) {
  45987. $operator = '<';
  45988. }
  45989. $this->setOperator($operator);
  45990. $this->setTarget($target);
  45991. }
  45992. }
  45993. <?php
  45994. namespace Symfony\Component\Finder\Comparator;
  45995. class NumberComparator extends Comparator
  45996. {
  45997. public function __construct($test)
  45998. {
  45999. if (!preg_match('#^\s*(==|!=|[<>]=?)?\s*([0-9\.]+)\s*([kmg]i?)?\s*$#i', $test, $matches)) {
  46000. throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a number test.', $test));
  46001. }
  46002. $target = $matches[2];
  46003. if (!is_numeric($target)) {
  46004. throw new \InvalidArgumentException(sprintf('Invalid number "%s".', $target));
  46005. }
  46006. if (isset($matches[3])) {
  46007. switch (strtolower($matches[3])) {
  46008. case 'k':
  46009. $target *= 1000;
  46010. break;
  46011. case 'ki':
  46012. $target *= 1024;
  46013. break;
  46014. case 'm':
  46015. $target *= 1000000;
  46016. break;
  46017. case 'mi':
  46018. $target *= 1024 * 1024;
  46019. break;
  46020. case 'g':
  46021. $target *= 1000000000;
  46022. break;
  46023. case 'gi':
  46024. $target *= 1024 * 1024 * 1024;
  46025. break;
  46026. }
  46027. }
  46028. $this->setTarget($target);
  46029. $this->setOperator(isset($matches[1]) ? $matches[1] : '==');
  46030. }
  46031. }
  46032. <?php
  46033. namespace Symfony\Component\Finder\Exception;
  46034. class AccessDeniedException extends \UnexpectedValueException
  46035. {
  46036. }
  46037. <?php
  46038. namespace Symfony\Component\Finder\Exception;
  46039. @trigger_error('The '.__NAMESPACE__.'\AdapterFailureException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  46040. use Symfony\Component\Finder\Adapter\AdapterInterface;
  46041. class AdapterFailureException extends \RuntimeException implements ExceptionInterface
  46042. {
  46043. private $adapter;
  46044. public function __construct(AdapterInterface $adapter, $message = null, \Exception $previous = null)
  46045. {
  46046. $this->adapter = $adapter;
  46047. parent::__construct($message ?: 'Search failed with "'.$adapter->getName().'" adapter.', $previous);
  46048. }
  46049. public function getAdapter()
  46050. {
  46051. return $this->adapter;
  46052. }
  46053. }
  46054. <?php
  46055. namespace Symfony\Component\Finder\Exception;
  46056. interface ExceptionInterface
  46057. {
  46058. public function getAdapter();
  46059. }
  46060. <?php
  46061. namespace Symfony\Component\Finder\Exception;
  46062. @trigger_error('The '.__NAMESPACE__.'\OperationNotPermitedException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  46063. class OperationNotPermitedException extends AdapterFailureException
  46064. {
  46065. }
  46066. <?php
  46067. namespace Symfony\Component\Finder\Exception;
  46068. @trigger_error('The '.__NAMESPACE__.'\ShellCommandFailureException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  46069. use Symfony\Component\Finder\Adapter\AdapterInterface;
  46070. use Symfony\Component\Finder\Shell\Command;
  46071. class ShellCommandFailureException extends AdapterFailureException
  46072. {
  46073. private $command;
  46074. public function __construct(AdapterInterface $adapter, Command $command, \Exception $previous = null)
  46075. {
  46076. $this->command = $command;
  46077. parent::__construct($adapter, 'Shell command failed: "'.$command->join().'".', $previous);
  46078. }
  46079. public function getCommand()
  46080. {
  46081. return $this->command;
  46082. }
  46083. }
  46084. <?php
  46085. namespace Symfony\Component\Finder\Expression;
  46086. @trigger_error('The '.__NAMESPACE__.'\Expression class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  46087. class Expression implements ValueInterface
  46088. {
  46089. const TYPE_REGEX = 1;
  46090. const TYPE_GLOB = 2;
  46091. private $value;
  46092. public static function create($expr)
  46093. {
  46094. return new self($expr);
  46095. }
  46096. public function __construct($expr)
  46097. {
  46098. try {
  46099. $this->value = Regex::create($expr);
  46100. } catch (\InvalidArgumentException $e) {
  46101. $this->value = new Glob($expr);
  46102. }
  46103. }
  46104. public function __toString()
  46105. {
  46106. return $this->render();
  46107. }
  46108. public function render()
  46109. {
  46110. return $this->value->render();
  46111. }
  46112. public function renderPattern()
  46113. {
  46114. return $this->value->renderPattern();
  46115. }
  46116. public function isCaseSensitive()
  46117. {
  46118. return $this->value->isCaseSensitive();
  46119. }
  46120. public function getType()
  46121. {
  46122. return $this->value->getType();
  46123. }
  46124. public function prepend($expr)
  46125. {
  46126. $this->value->prepend($expr);
  46127. return $this;
  46128. }
  46129. public function append($expr)
  46130. {
  46131. $this->value->append($expr);
  46132. return $this;
  46133. }
  46134. public function isRegex()
  46135. {
  46136. return self::TYPE_REGEX === $this->value->getType();
  46137. }
  46138. public function isGlob()
  46139. {
  46140. return self::TYPE_GLOB === $this->value->getType();
  46141. }
  46142. public function getGlob()
  46143. {
  46144. if (self::TYPE_GLOB !== $this->value->getType()) {
  46145. throw new \LogicException('Regex can\'t be transformed to glob.');
  46146. }
  46147. return $this->value;
  46148. }
  46149. public function getRegex()
  46150. {
  46151. return self::TYPE_REGEX === $this->value->getType() ? $this->value : $this->value->toRegex();
  46152. }
  46153. }
  46154. <?php
  46155. namespace Symfony\Component\Finder\Expression;
  46156. @trigger_error('The '.__NAMESPACE__.'\Glob class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  46157. use Symfony\Component\Finder\Glob as FinderGlob;
  46158. class Glob implements ValueInterface
  46159. {
  46160. private $pattern;
  46161. public function __construct($pattern)
  46162. {
  46163. $this->pattern = $pattern;
  46164. }
  46165. public function render()
  46166. {
  46167. return $this->pattern;
  46168. }
  46169. public function renderPattern()
  46170. {
  46171. return $this->pattern;
  46172. }
  46173. public function getType()
  46174. {
  46175. return Expression::TYPE_GLOB;
  46176. }
  46177. public function isCaseSensitive()
  46178. {
  46179. return true;
  46180. }
  46181. public function prepend($expr)
  46182. {
  46183. $this->pattern = $expr.$this->pattern;
  46184. return $this;
  46185. }
  46186. public function append($expr)
  46187. {
  46188. $this->pattern .= $expr;
  46189. return $this;
  46190. }
  46191. public function isExpandable()
  46192. {
  46193. return false !== strpos($this->pattern, '{')
  46194. && false !== strpos($this->pattern, '}');
  46195. }
  46196. public function toRegex($strictLeadingDot = true, $strictWildcardSlash = true)
  46197. {
  46198. $regex = FinderGlob::toRegex($this->pattern, $strictLeadingDot, $strictWildcardSlash, '');
  46199. return new Regex($regex);
  46200. }
  46201. }
  46202. <?php
  46203. namespace Symfony\Component\Finder\Expression;
  46204. @trigger_error('The '.__NAMESPACE__.'\Regex class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  46205. class Regex implements ValueInterface
  46206. {
  46207. const START_FLAG = '^';
  46208. const END_FLAG = '$';
  46209. const BOUNDARY = '~';
  46210. const JOKER = '.*';
  46211. const ESCAPING = '\\';
  46212. private $pattern;
  46213. private $options;
  46214. private $startFlag;
  46215. private $endFlag;
  46216. private $startJoker;
  46217. private $endJoker;
  46218. public static function create($expr)
  46219. {
  46220. if (preg_match('/^(.{3,}?)([imsxuADU]*)$/', $expr, $m)) {
  46221. $start = substr($m[1], 0, 1);
  46222. $end = substr($m[1], -1);
  46223. if (
  46224. ($start === $end && !preg_match('/[*?[:alnum:] \\\\]/', $start))
  46225. || ('{' === $start && '}' === $end)
  46226. || ('(' === $start && ')' === $end)
  46227. ) {
  46228. return new self(substr($m[1], 1, -1), $m[2], $end);
  46229. }
  46230. }
  46231. throw new \InvalidArgumentException('Given expression is not a regex.');
  46232. }
  46233. public function __construct($pattern, $options = '', $delimiter = null)
  46234. {
  46235. if (null !== $delimiter) {
  46236. $pattern = str_replace('\\'.$delimiter, $delimiter, $pattern);
  46237. }
  46238. $this->parsePattern($pattern);
  46239. $this->options = $options;
  46240. }
  46241. public function __toString()
  46242. {
  46243. return $this->render();
  46244. }
  46245. public function render()
  46246. {
  46247. return self::BOUNDARY
  46248. .$this->renderPattern()
  46249. .self::BOUNDARY
  46250. .$this->options;
  46251. }
  46252. public function renderPattern()
  46253. {
  46254. return ($this->startFlag ? self::START_FLAG : '')
  46255. .($this->startJoker ? self::JOKER : '')
  46256. .str_replace(self::BOUNDARY, '\\'.self::BOUNDARY, $this->pattern)
  46257. .($this->endJoker ? self::JOKER : '')
  46258. .($this->endFlag ? self::END_FLAG : '');
  46259. }
  46260. public function isCaseSensitive()
  46261. {
  46262. return !$this->hasOption('i');
  46263. }
  46264. public function getType()
  46265. {
  46266. return Expression::TYPE_REGEX;
  46267. }
  46268. public function prepend($expr)
  46269. {
  46270. $this->pattern = $expr.$this->pattern;
  46271. return $this;
  46272. }
  46273. public function append($expr)
  46274. {
  46275. $this->pattern .= $expr;
  46276. return $this;
  46277. }
  46278. public function hasOption($option)
  46279. {
  46280. return false !== strpos($this->options, $option);
  46281. }
  46282. public function addOption($option)
  46283. {
  46284. if (!$this->hasOption($option)) {
  46285. $this->options .= $option;
  46286. }
  46287. return $this;
  46288. }
  46289. public function removeOption($option)
  46290. {
  46291. $this->options = str_replace($option, '', $this->options);
  46292. return $this;
  46293. }
  46294. public function setStartFlag($startFlag)
  46295. {
  46296. $this->startFlag = $startFlag;
  46297. return $this;
  46298. }
  46299. public function hasStartFlag()
  46300. {
  46301. return $this->startFlag;
  46302. }
  46303. public function setEndFlag($endFlag)
  46304. {
  46305. $this->endFlag = (bool) $endFlag;
  46306. return $this;
  46307. }
  46308. public function hasEndFlag()
  46309. {
  46310. return $this->endFlag;
  46311. }
  46312. public function setStartJoker($startJoker)
  46313. {
  46314. $this->startJoker = $startJoker;
  46315. return $this;
  46316. }
  46317. public function hasStartJoker()
  46318. {
  46319. return $this->startJoker;
  46320. }
  46321. public function setEndJoker($endJoker)
  46322. {
  46323. $this->endJoker = (bool) $endJoker;
  46324. return $this;
  46325. }
  46326. public function hasEndJoker()
  46327. {
  46328. return $this->endJoker;
  46329. }
  46330. public function replaceJokers($replacement)
  46331. {
  46332. $replace = function ($subject) use ($replacement) {
  46333. $subject = $subject[0];
  46334. $replace = 0 === substr_count($subject, '\\') % 2;
  46335. return $replace ? str_replace('.', $replacement, $subject) : $subject;
  46336. };
  46337. $this->pattern = preg_replace_callback('~[\\\\]*\\.~', $replace, $this->pattern);
  46338. return $this;
  46339. }
  46340. private function parsePattern($pattern)
  46341. {
  46342. if ($this->startFlag = self::START_FLAG === substr($pattern, 0, 1)) {
  46343. $pattern = substr($pattern, 1);
  46344. }
  46345. if ($this->startJoker = self::JOKER === substr($pattern, 0, 2)) {
  46346. $pattern = substr($pattern, 2);
  46347. }
  46348. if ($this->endFlag = (self::END_FLAG === substr($pattern, -1) && self::ESCAPING !== substr($pattern, -2, -1))) {
  46349. $pattern = substr($pattern, 0, -1);
  46350. }
  46351. if ($this->endJoker = (self::JOKER === substr($pattern, -2) && self::ESCAPING !== substr($pattern, -3, -2))) {
  46352. $pattern = substr($pattern, 0, -2);
  46353. }
  46354. $this->pattern = $pattern;
  46355. }
  46356. }
  46357. <?php
  46358. namespace Symfony\Component\Finder\Expression;
  46359. @trigger_error('The '.__NAMESPACE__.'\ValueInterface interface is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  46360. interface ValueInterface
  46361. {
  46362. public function render();
  46363. public function renderPattern();
  46364. public function isCaseSensitive();
  46365. public function getType();
  46366. public function prepend($expr);
  46367. public function append($expr);
  46368. }
  46369. <?php
  46370. namespace Symfony\Component\Finder;
  46371. use Symfony\Component\Finder\Adapter\AdapterInterface;
  46372. use Symfony\Component\Finder\Adapter\BsdFindAdapter;
  46373. use Symfony\Component\Finder\Adapter\GnuFindAdapter;
  46374. use Symfony\Component\Finder\Adapter\PhpAdapter;
  46375. use Symfony\Component\Finder\Comparator\DateComparator;
  46376. use Symfony\Component\Finder\Comparator\NumberComparator;
  46377. use Symfony\Component\Finder\Exception\ExceptionInterface;
  46378. use Symfony\Component\Finder\Iterator\CustomFilterIterator;
  46379. use Symfony\Component\Finder\Iterator\DateRangeFilterIterator;
  46380. use Symfony\Component\Finder\Iterator\DepthRangeFilterIterator;
  46381. use Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator;
  46382. use Symfony\Component\Finder\Iterator\FilecontentFilterIterator;
  46383. use Symfony\Component\Finder\Iterator\FilenameFilterIterator;
  46384. use Symfony\Component\Finder\Iterator\SizeRangeFilterIterator;
  46385. use Symfony\Component\Finder\Iterator\SortableIterator;
  46386. class Finder implements \IteratorAggregate, \Countable
  46387. {
  46388. const IGNORE_VCS_FILES = 1;
  46389. const IGNORE_DOT_FILES = 2;
  46390. private $mode = 0;
  46391. private $names = array();
  46392. private $notNames = array();
  46393. private $exclude = array();
  46394. private $filters = array();
  46395. private $depths = array();
  46396. private $sizes = array();
  46397. private $followLinks = false;
  46398. private $sort = false;
  46399. private $ignore = 0;
  46400. private $dirs = array();
  46401. private $dates = array();
  46402. private $iterators = array();
  46403. private $contains = array();
  46404. private $notContains = array();
  46405. private $adapters = null;
  46406. private $paths = array();
  46407. private $notPaths = array();
  46408. private $ignoreUnreadableDirs = false;
  46409. private static $vcsPatterns = array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg');
  46410. public function __construct()
  46411. {
  46412. $this->ignore = static::IGNORE_VCS_FILES | static::IGNORE_DOT_FILES;
  46413. }
  46414. public static function create()
  46415. {
  46416. return new static();
  46417. }
  46418. public function addAdapter(AdapterInterface $adapter, $priority = 0)
  46419. {
  46420. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  46421. $this->initDefaultAdapters();
  46422. $this->adapters[$adapter->getName()] = array(
  46423. 'adapter' => $adapter,
  46424. 'priority' => $priority,
  46425. 'selected' => false,
  46426. );
  46427. return $this->sortAdapters();
  46428. }
  46429. public function useBestAdapter()
  46430. {
  46431. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  46432. $this->initDefaultAdapters();
  46433. $this->resetAdapterSelection();
  46434. return $this->sortAdapters();
  46435. }
  46436. public function setAdapter($name)
  46437. {
  46438. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  46439. $this->initDefaultAdapters();
  46440. if (!isset($this->adapters[$name])) {
  46441. throw new \InvalidArgumentException(sprintf('Adapter "%s" does not exist.', $name));
  46442. }
  46443. $this->resetAdapterSelection();
  46444. $this->adapters[$name]['selected'] = true;
  46445. return $this->sortAdapters();
  46446. }
  46447. public function removeAdapters()
  46448. {
  46449. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  46450. $this->adapters = array();
  46451. return $this;
  46452. }
  46453. public function getAdapters()
  46454. {
  46455. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  46456. $this->initDefaultAdapters();
  46457. return array_values(array_map(function (array $adapter) {
  46458. return $adapter['adapter'];
  46459. }, $this->adapters));
  46460. }
  46461. public function directories()
  46462. {
  46463. $this->mode = Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES;
  46464. return $this;
  46465. }
  46466. public function files()
  46467. {
  46468. $this->mode = Iterator\FileTypeFilterIterator::ONLY_FILES;
  46469. return $this;
  46470. }
  46471. public function depth($level)
  46472. {
  46473. $this->depths[] = new Comparator\NumberComparator($level);
  46474. return $this;
  46475. }
  46476. public function date($date)
  46477. {
  46478. $this->dates[] = new Comparator\DateComparator($date);
  46479. return $this;
  46480. }
  46481. public function name($pattern)
  46482. {
  46483. $this->names[] = $pattern;
  46484. return $this;
  46485. }
  46486. public function notName($pattern)
  46487. {
  46488. $this->notNames[] = $pattern;
  46489. return $this;
  46490. }
  46491. public function contains($pattern)
  46492. {
  46493. $this->contains[] = $pattern;
  46494. return $this;
  46495. }
  46496. public function notContains($pattern)
  46497. {
  46498. $this->notContains[] = $pattern;
  46499. return $this;
  46500. }
  46501. public function path($pattern)
  46502. {
  46503. $this->paths[] = $pattern;
  46504. return $this;
  46505. }
  46506. public function notPath($pattern)
  46507. {
  46508. $this->notPaths[] = $pattern;
  46509. return $this;
  46510. }
  46511. public function size($size)
  46512. {
  46513. $this->sizes[] = new Comparator\NumberComparator($size);
  46514. return $this;
  46515. }
  46516. public function exclude($dirs)
  46517. {
  46518. $this->exclude = array_merge($this->exclude, (array) $dirs);
  46519. return $this;
  46520. }
  46521. public function ignoreDotFiles($ignoreDotFiles)
  46522. {
  46523. if ($ignoreDotFiles) {
  46524. $this->ignore |= static::IGNORE_DOT_FILES;
  46525. } else {
  46526. $this->ignore &= ~static::IGNORE_DOT_FILES;
  46527. }
  46528. return $this;
  46529. }
  46530. public function ignoreVCS($ignoreVCS)
  46531. {
  46532. if ($ignoreVCS) {
  46533. $this->ignore |= static::IGNORE_VCS_FILES;
  46534. } else {
  46535. $this->ignore &= ~static::IGNORE_VCS_FILES;
  46536. }
  46537. return $this;
  46538. }
  46539. public static function addVCSPattern($pattern)
  46540. {
  46541. foreach ((array) $pattern as $p) {
  46542. self::$vcsPatterns[] = $p;
  46543. }
  46544. self::$vcsPatterns = array_unique(self::$vcsPatterns);
  46545. }
  46546. public function sort(\Closure $closure)
  46547. {
  46548. $this->sort = $closure;
  46549. return $this;
  46550. }
  46551. public function sortByName()
  46552. {
  46553. $this->sort = Iterator\SortableIterator::SORT_BY_NAME;
  46554. return $this;
  46555. }
  46556. public function sortByType()
  46557. {
  46558. $this->sort = Iterator\SortableIterator::SORT_BY_TYPE;
  46559. return $this;
  46560. }
  46561. public function sortByAccessedTime()
  46562. {
  46563. $this->sort = Iterator\SortableIterator::SORT_BY_ACCESSED_TIME;
  46564. return $this;
  46565. }
  46566. public function sortByChangedTime()
  46567. {
  46568. $this->sort = Iterator\SortableIterator::SORT_BY_CHANGED_TIME;
  46569. return $this;
  46570. }
  46571. public function sortByModifiedTime()
  46572. {
  46573. $this->sort = Iterator\SortableIterator::SORT_BY_MODIFIED_TIME;
  46574. return $this;
  46575. }
  46576. public function filter(\Closure $closure)
  46577. {
  46578. $this->filters[] = $closure;
  46579. return $this;
  46580. }
  46581. public function followLinks()
  46582. {
  46583. $this->followLinks = true;
  46584. return $this;
  46585. }
  46586. public function ignoreUnreadableDirs($ignore = true)
  46587. {
  46588. $this->ignoreUnreadableDirs = (bool) $ignore;
  46589. return $this;
  46590. }
  46591. public function in($dirs)
  46592. {
  46593. $resolvedDirs = array();
  46594. foreach ((array) $dirs as $dir) {
  46595. if (is_dir($dir)) {
  46596. $resolvedDirs[] = $this->normalizeDir($dir);
  46597. } elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? GLOB_BRACE : 0) | GLOB_ONLYDIR)) {
  46598. $resolvedDirs = array_merge($resolvedDirs, array_map(array($this, 'normalizeDir'), $glob));
  46599. } else {
  46600. throw new \InvalidArgumentException(sprintf('The "%s" directory does not exist.', $dir));
  46601. }
  46602. }
  46603. $this->dirs = array_merge($this->dirs, $resolvedDirs);
  46604. return $this;
  46605. }
  46606. public function getIterator()
  46607. {
  46608. if (0 === \count($this->dirs) && 0 === \count($this->iterators)) {
  46609. throw new \LogicException('You must call one of in() or append() methods before iterating over a Finder.');
  46610. }
  46611. if (1 === \count($this->dirs) && 0 === \count($this->iterators)) {
  46612. return $this->searchInDirectory($this->dirs[0]);
  46613. }
  46614. $iterator = new \AppendIterator();
  46615. foreach ($this->dirs as $dir) {
  46616. $iterator->append($this->searchInDirectory($dir));
  46617. }
  46618. foreach ($this->iterators as $it) {
  46619. $iterator->append($it);
  46620. }
  46621. return $iterator;
  46622. }
  46623. public function append($iterator)
  46624. {
  46625. if ($iterator instanceof \IteratorAggregate) {
  46626. $this->iterators[] = $iterator->getIterator();
  46627. } elseif ($iterator instanceof \Iterator) {
  46628. $this->iterators[] = $iterator;
  46629. } elseif ($iterator instanceof \Traversable || \is_array($iterator)) {
  46630. $it = new \ArrayIterator();
  46631. foreach ($iterator as $file) {
  46632. $it->append($file instanceof \SplFileInfo ? $file : new \SplFileInfo($file));
  46633. }
  46634. $this->iterators[] = $it;
  46635. } else {
  46636. throw new \InvalidArgumentException('Finder::append() method wrong argument type.');
  46637. }
  46638. return $this;
  46639. }
  46640. public function count()
  46641. {
  46642. return iterator_count($this->getIterator());
  46643. }
  46644. private function sortAdapters()
  46645. {
  46646. uasort($this->adapters, function (array $a, array $b) {
  46647. if ($a['selected'] || $b['selected']) {
  46648. return $a['selected'] ? -1 : 1;
  46649. }
  46650. return $a['priority'] > $b['priority'] ? -1 : 1;
  46651. });
  46652. return $this;
  46653. }
  46654. private function searchInDirectory($dir)
  46655. {
  46656. if (static::IGNORE_VCS_FILES === (static::IGNORE_VCS_FILES & $this->ignore)) {
  46657. $this->exclude = array_merge($this->exclude, self::$vcsPatterns);
  46658. }
  46659. if (static::IGNORE_DOT_FILES === (static::IGNORE_DOT_FILES & $this->ignore)) {
  46660. $this->notPaths[] = '#(^|/)\..+(/|$)#';
  46661. }
  46662. if ($this->adapters) {
  46663. foreach ($this->adapters as $adapter) {
  46664. if ($adapter['adapter']->isSupported()) {
  46665. try {
  46666. return $this
  46667. ->buildAdapter($adapter['adapter'])
  46668. ->searchInDirectory($dir);
  46669. } catch (ExceptionInterface $e) {
  46670. }
  46671. }
  46672. }
  46673. }
  46674. $minDepth = 0;
  46675. $maxDepth = PHP_INT_MAX;
  46676. foreach ($this->depths as $comparator) {
  46677. switch ($comparator->getOperator()) {
  46678. case '>':
  46679. $minDepth = $comparator->getTarget() + 1;
  46680. break;
  46681. case '>=':
  46682. $minDepth = $comparator->getTarget();
  46683. break;
  46684. case '<':
  46685. $maxDepth = $comparator->getTarget() - 1;
  46686. break;
  46687. case '<=':
  46688. $maxDepth = $comparator->getTarget();
  46689. break;
  46690. default:
  46691. $minDepth = $maxDepth = $comparator->getTarget();
  46692. }
  46693. }
  46694. $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
  46695. if ($this->followLinks) {
  46696. $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
  46697. }
  46698. $iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
  46699. if ($this->exclude) {
  46700. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  46701. }
  46702. $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
  46703. if ($minDepth > 0 || $maxDepth < PHP_INT_MAX) {
  46704. $iterator = new Iterator\DepthRangeFilterIterator($iterator, $minDepth, $maxDepth);
  46705. }
  46706. if ($this->mode) {
  46707. $iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
  46708. }
  46709. if ($this->names || $this->notNames) {
  46710. $iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
  46711. }
  46712. if ($this->contains || $this->notContains) {
  46713. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  46714. }
  46715. if ($this->sizes) {
  46716. $iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
  46717. }
  46718. if ($this->dates) {
  46719. $iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
  46720. }
  46721. if ($this->filters) {
  46722. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  46723. }
  46724. if ($this->paths || $this->notPaths) {
  46725. $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
  46726. }
  46727. if ($this->sort) {
  46728. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  46729. $iterator = $iteratorAggregate->getIterator();
  46730. }
  46731. return $iterator;
  46732. }
  46733. private function buildAdapter(AdapterInterface $adapter)
  46734. {
  46735. return $adapter
  46736. ->setFollowLinks($this->followLinks)
  46737. ->setDepths($this->depths)
  46738. ->setMode($this->mode)
  46739. ->setExclude($this->exclude)
  46740. ->setNames($this->names)
  46741. ->setNotNames($this->notNames)
  46742. ->setContains($this->contains)
  46743. ->setNotContains($this->notContains)
  46744. ->setSizes($this->sizes)
  46745. ->setDates($this->dates)
  46746. ->setFilters($this->filters)
  46747. ->setSort($this->sort)
  46748. ->setPath($this->paths)
  46749. ->setNotPath($this->notPaths)
  46750. ->ignoreUnreadableDirs($this->ignoreUnreadableDirs);
  46751. }
  46752. private function resetAdapterSelection()
  46753. {
  46754. $this->adapters = array_map(function (array $properties) {
  46755. $properties['selected'] = false;
  46756. return $properties;
  46757. }, $this->adapters);
  46758. }
  46759. private function initDefaultAdapters()
  46760. {
  46761. if (null === $this->adapters) {
  46762. $this->adapters = array();
  46763. $this
  46764. ->addAdapter(new GnuFindAdapter())
  46765. ->addAdapter(new BsdFindAdapter())
  46766. ->addAdapter(new PhpAdapter(), -50)
  46767. ->setAdapter('php')
  46768. ;
  46769. }
  46770. }
  46771. private function normalizeDir($dir)
  46772. {
  46773. return rtrim($dir, '/'.\DIRECTORY_SEPARATOR);
  46774. }
  46775. }
  46776. <?php
  46777. namespace Symfony\Component\Finder;
  46778. class Glob
  46779. {
  46780. public static function toRegex($glob, $strictLeadingDot = true, $strictWildcardSlash = true, $delimiter = '#')
  46781. {
  46782. $firstByte = true;
  46783. $escaping = false;
  46784. $inCurlies = 0;
  46785. $regex = '';
  46786. $sizeGlob = \strlen($glob);
  46787. for ($i = 0; $i < $sizeGlob; ++$i) {
  46788. $car = $glob[$i];
  46789. if ($firstByte) {
  46790. if ($strictLeadingDot && '.' !== $car) {
  46791. $regex .= '(?=[^\.])';
  46792. }
  46793. $firstByte = false;
  46794. }
  46795. if ('/' === $car) {
  46796. $firstByte = true;
  46797. }
  46798. if ($delimiter === $car || '.' === $car || '(' === $car || ')' === $car || '|' === $car || '+' === $car || '^' === $car || '$' === $car) {
  46799. $regex .= "\\$car";
  46800. } elseif ('*' === $car) {
  46801. $regex .= $escaping ? '\\*' : ($strictWildcardSlash ? '[^/]*' : '.*');
  46802. } elseif ('?' === $car) {
  46803. $regex .= $escaping ? '\\?' : ($strictWildcardSlash ? '[^/]' : '.');
  46804. } elseif ('{' === $car) {
  46805. $regex .= $escaping ? '\\{' : '(';
  46806. if (!$escaping) {
  46807. ++$inCurlies;
  46808. }
  46809. } elseif ('}' === $car && $inCurlies) {
  46810. $regex .= $escaping ? '}' : ')';
  46811. if (!$escaping) {
  46812. --$inCurlies;
  46813. }
  46814. } elseif (',' === $car && $inCurlies) {
  46815. $regex .= $escaping ? ',' : '|';
  46816. } elseif ('\\' === $car) {
  46817. if ($escaping) {
  46818. $regex .= '\\\\';
  46819. $escaping = false;
  46820. } else {
  46821. $escaping = true;
  46822. }
  46823. continue;
  46824. } else {
  46825. $regex .= $car;
  46826. }
  46827. $escaping = false;
  46828. }
  46829. return $delimiter.'^'.$regex.'$'.$delimiter;
  46830. }
  46831. }
  46832. <?php
  46833. namespace Symfony\Component\Finder\Iterator;
  46834. class CustomFilterIterator extends FilterIterator
  46835. {
  46836. private $filters = array();
  46837. public function __construct(\Iterator $iterator, array $filters)
  46838. {
  46839. foreach ($filters as $filter) {
  46840. if (!\is_callable($filter)) {
  46841. throw new \InvalidArgumentException('Invalid PHP callback.');
  46842. }
  46843. }
  46844. $this->filters = $filters;
  46845. parent::__construct($iterator);
  46846. }
  46847. public function accept()
  46848. {
  46849. $fileinfo = $this->current();
  46850. foreach ($this->filters as $filter) {
  46851. if (false === \call_user_func($filter, $fileinfo)) {
  46852. return false;
  46853. }
  46854. }
  46855. return true;
  46856. }
  46857. }
  46858. <?php
  46859. namespace Symfony\Component\Finder\Iterator;
  46860. use Symfony\Component\Finder\Comparator\DateComparator;
  46861. class DateRangeFilterIterator extends FilterIterator
  46862. {
  46863. private $comparators = array();
  46864. public function __construct(\Iterator $iterator, array $comparators)
  46865. {
  46866. $this->comparators = $comparators;
  46867. parent::__construct($iterator);
  46868. }
  46869. public function accept()
  46870. {
  46871. $fileinfo = $this->current();
  46872. if (!file_exists($fileinfo->getPathname())) {
  46873. return false;
  46874. }
  46875. $filedate = $fileinfo->getMTime();
  46876. foreach ($this->comparators as $compare) {
  46877. if (!$compare->test($filedate)) {
  46878. return false;
  46879. }
  46880. }
  46881. return true;
  46882. }
  46883. }
  46884. <?php
  46885. namespace Symfony\Component\Finder\Iterator;
  46886. class DepthRangeFilterIterator extends FilterIterator
  46887. {
  46888. private $minDepth = 0;
  46889. public function __construct(\RecursiveIteratorIterator $iterator, $minDepth = 0, $maxDepth = PHP_INT_MAX)
  46890. {
  46891. $this->minDepth = $minDepth;
  46892. $iterator->setMaxDepth(PHP_INT_MAX === $maxDepth ? -1 : $maxDepth);
  46893. parent::__construct($iterator);
  46894. }
  46895. public function accept()
  46896. {
  46897. return $this->getInnerIterator()->getDepth() >= $this->minDepth;
  46898. }
  46899. }
  46900. <?php
  46901. namespace Symfony\Component\Finder\Iterator;
  46902. class ExcludeDirectoryFilterIterator extends FilterIterator implements \RecursiveIterator
  46903. {
  46904. private $iterator;
  46905. private $isRecursive;
  46906. private $excludedDirs = array();
  46907. private $excludedPattern;
  46908. public function __construct(\Iterator $iterator, array $directories)
  46909. {
  46910. $this->iterator = $iterator;
  46911. $this->isRecursive = $iterator instanceof \RecursiveIterator;
  46912. $patterns = array();
  46913. foreach ($directories as $directory) {
  46914. $directory = rtrim($directory, '/');
  46915. if (!$this->isRecursive || false !== strpos($directory, '/')) {
  46916. $patterns[] = preg_quote($directory, '#');
  46917. } else {
  46918. $this->excludedDirs[$directory] = true;
  46919. }
  46920. }
  46921. if ($patterns) {
  46922. $this->excludedPattern = '#(?:^|/)(?:'.implode('|', $patterns).')(?:/|$)#';
  46923. }
  46924. parent::__construct($iterator);
  46925. }
  46926. public function accept()
  46927. {
  46928. if ($this->isRecursive && isset($this->excludedDirs[$this->getFilename()]) && $this->isDir()) {
  46929. return false;
  46930. }
  46931. if ($this->excludedPattern) {
  46932. $path = $this->isDir() ? $this->current()->getRelativePathname() : $this->current()->getRelativePath();
  46933. $path = str_replace('\\', '/', $path);
  46934. return !preg_match($this->excludedPattern, $path);
  46935. }
  46936. return true;
  46937. }
  46938. public function hasChildren()
  46939. {
  46940. return $this->isRecursive && $this->iterator->hasChildren();
  46941. }
  46942. public function getChildren()
  46943. {
  46944. $children = new self($this->iterator->getChildren(), array());
  46945. $children->excludedDirs = $this->excludedDirs;
  46946. $children->excludedPattern = $this->excludedPattern;
  46947. return $children;
  46948. }
  46949. }
  46950. <?php
  46951. namespace Symfony\Component\Finder\Iterator;
  46952. @trigger_error('The '.__NAMESPACE__.'\FilePathsIterator class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  46953. use Symfony\Component\Finder\SplFileInfo;
  46954. class FilePathsIterator extends \ArrayIterator
  46955. {
  46956. private $baseDir;
  46957. private $baseDirLength;
  46958. private $subPath;
  46959. private $subPathname;
  46960. private $current;
  46961. public function __construct(array $paths, $baseDir)
  46962. {
  46963. $this->baseDir = $baseDir;
  46964. $this->baseDirLength = \strlen($baseDir);
  46965. parent::__construct($paths);
  46966. }
  46967. public function __call($name, array $arguments)
  46968. {
  46969. return \call_user_func_array(array($this->current(), $name), $arguments);
  46970. }
  46971. public function current()
  46972. {
  46973. return $this->current;
  46974. }
  46975. public function key()
  46976. {
  46977. return $this->current->getPathname();
  46978. }
  46979. public function next()
  46980. {
  46981. parent::next();
  46982. $this->buildProperties();
  46983. }
  46984. public function rewind()
  46985. {
  46986. parent::rewind();
  46987. $this->buildProperties();
  46988. }
  46989. public function getSubPath()
  46990. {
  46991. return $this->subPath;
  46992. }
  46993. public function getSubPathname()
  46994. {
  46995. return $this->subPathname;
  46996. }
  46997. private function buildProperties()
  46998. {
  46999. $absolutePath = parent::current();
  47000. if ($this->baseDir === substr($absolutePath, 0, $this->baseDirLength)) {
  47001. $this->subPathname = ltrim(substr($absolutePath, $this->baseDirLength), '/\\');
  47002. $dir = \dirname($this->subPathname);
  47003. $this->subPath = '.' === $dir ? '' : $dir;
  47004. } else {
  47005. $this->subPath = $this->subPathname = '';
  47006. }
  47007. $this->current = new SplFileInfo(parent::current(), $this->subPath, $this->subPathname);
  47008. }
  47009. }
  47010. <?php
  47011. namespace Symfony\Component\Finder\Iterator;
  47012. class FileTypeFilterIterator extends FilterIterator
  47013. {
  47014. const ONLY_FILES = 1;
  47015. const ONLY_DIRECTORIES = 2;
  47016. private $mode;
  47017. public function __construct(\Iterator $iterator, $mode)
  47018. {
  47019. $this->mode = $mode;
  47020. parent::__construct($iterator);
  47021. }
  47022. public function accept()
  47023. {
  47024. $fileinfo = $this->current();
  47025. if (self::ONLY_DIRECTORIES === (self::ONLY_DIRECTORIES & $this->mode) && $fileinfo->isFile()) {
  47026. return false;
  47027. } elseif (self::ONLY_FILES === (self::ONLY_FILES & $this->mode) && $fileinfo->isDir()) {
  47028. return false;
  47029. }
  47030. return true;
  47031. }
  47032. }
  47033. <?php
  47034. namespace Symfony\Component\Finder\Iterator;
  47035. class FilecontentFilterIterator extends MultiplePcreFilterIterator
  47036. {
  47037. public function accept()
  47038. {
  47039. if (!$this->matchRegexps && !$this->noMatchRegexps) {
  47040. return true;
  47041. }
  47042. $fileinfo = $this->current();
  47043. if ($fileinfo->isDir() || !$fileinfo->isReadable()) {
  47044. return false;
  47045. }
  47046. $content = $fileinfo->getContents();
  47047. if (!$content) {
  47048. return false;
  47049. }
  47050. return $this->isAccepted($content);
  47051. }
  47052. protected function toRegex($str)
  47053. {
  47054. return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
  47055. }
  47056. }
  47057. <?php
  47058. namespace Symfony\Component\Finder\Iterator;
  47059. use Symfony\Component\Finder\Glob;
  47060. class FilenameFilterIterator extends MultiplePcreFilterIterator
  47061. {
  47062. public function accept()
  47063. {
  47064. return $this->isAccepted($this->current()->getFilename());
  47065. }
  47066. protected function toRegex($str)
  47067. {
  47068. return $this->isRegex($str) ? $str : Glob::toRegex($str);
  47069. }
  47070. }
  47071. <?php
  47072. namespace Symfony\Component\Finder\Iterator;
  47073. abstract class FilterIterator extends \FilterIterator
  47074. {
  47075. public function rewind()
  47076. {
  47077. if (\PHP_VERSION_ID > 50607 || (\PHP_VERSION_ID > 50523 && \PHP_VERSION_ID < 50600)) {
  47078. parent::rewind();
  47079. return;
  47080. }
  47081. $iterator = $this;
  47082. while ($iterator instanceof \OuterIterator) {
  47083. $innerIterator = $iterator->getInnerIterator();
  47084. if ($innerIterator instanceof RecursiveDirectoryIterator) {
  47085. if ($innerIterator->isRewindable()) {
  47086. $innerIterator->next();
  47087. $innerIterator->rewind();
  47088. }
  47089. } elseif ($innerIterator instanceof \FilesystemIterator) {
  47090. $innerIterator->next();
  47091. $innerIterator->rewind();
  47092. }
  47093. $iterator = $innerIterator;
  47094. }
  47095. parent::rewind();
  47096. }
  47097. }
  47098. <?php
  47099. namespace Symfony\Component\Finder\Iterator;
  47100. abstract class MultiplePcreFilterIterator extends FilterIterator
  47101. {
  47102. protected $matchRegexps = array();
  47103. protected $noMatchRegexps = array();
  47104. public function __construct(\Iterator $iterator, array $matchPatterns, array $noMatchPatterns)
  47105. {
  47106. foreach ($matchPatterns as $pattern) {
  47107. $this->matchRegexps[] = $this->toRegex($pattern);
  47108. }
  47109. foreach ($noMatchPatterns as $pattern) {
  47110. $this->noMatchRegexps[] = $this->toRegex($pattern);
  47111. }
  47112. parent::__construct($iterator);
  47113. }
  47114. protected function isAccepted($string)
  47115. {
  47116. foreach ($this->noMatchRegexps as $regex) {
  47117. if (preg_match($regex, $string)) {
  47118. return false;
  47119. }
  47120. }
  47121. if ($this->matchRegexps) {
  47122. foreach ($this->matchRegexps as $regex) {
  47123. if (preg_match($regex, $string)) {
  47124. return true;
  47125. }
  47126. }
  47127. return false;
  47128. }
  47129. return true;
  47130. }
  47131. protected function isRegex($str)
  47132. {
  47133. if (preg_match('/^(.{3,}?)[imsxuADU]*$/', $str, $m)) {
  47134. $start = substr($m[1], 0, 1);
  47135. $end = substr($m[1], -1);
  47136. if ($start === $end) {
  47137. return !preg_match('/[*?[:alnum:] \\\\]/', $start);
  47138. }
  47139. foreach (array(array('{', '}'), array('(', ')'), array('[', ']'), array('<', '>')) as $delimiters) {
  47140. if ($start === $delimiters[0] && $end === $delimiters[1]) {
  47141. return true;
  47142. }
  47143. }
  47144. }
  47145. return false;
  47146. }
  47147. abstract protected function toRegex($str);
  47148. }
  47149. <?php
  47150. namespace Symfony\Component\Finder\Iterator;
  47151. class PathFilterIterator extends MultiplePcreFilterIterator
  47152. {
  47153. public function accept()
  47154. {
  47155. $filename = $this->current()->getRelativePathname();
  47156. if ('\\' === \DIRECTORY_SEPARATOR) {
  47157. $filename = str_replace('\\', '/', $filename);
  47158. }
  47159. return $this->isAccepted($filename);
  47160. }
  47161. protected function toRegex($str)
  47162. {
  47163. return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
  47164. }
  47165. }
  47166. <?php
  47167. namespace Symfony\Component\Finder\Iterator;
  47168. use Symfony\Component\Finder\Exception\AccessDeniedException;
  47169. use Symfony\Component\Finder\SplFileInfo;
  47170. class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
  47171. {
  47172. private $ignoreUnreadableDirs;
  47173. private $rewindable;
  47174. private $rootPath;
  47175. private $subPath;
  47176. private $directorySeparator = '/';
  47177. public function __construct($path, $flags, $ignoreUnreadableDirs = false)
  47178. {
  47179. if ($flags & (self::CURRENT_AS_PATHNAME | self::CURRENT_AS_SELF)) {
  47180. throw new \RuntimeException('This iterator only support returning current as fileinfo.');
  47181. }
  47182. parent::__construct($path, $flags);
  47183. $this->ignoreUnreadableDirs = $ignoreUnreadableDirs;
  47184. $this->rootPath = (string) $path;
  47185. if ('/' !== \DIRECTORY_SEPARATOR && !($flags & self::UNIX_PATHS)) {
  47186. $this->directorySeparator = \DIRECTORY_SEPARATOR;
  47187. }
  47188. }
  47189. public function current()
  47190. {
  47191. if (null === $subPathname = $this->subPath) {
  47192. $subPathname = $this->subPath = (string) $this->getSubPath();
  47193. }
  47194. if ('' !== $subPathname) {
  47195. $subPathname .= $this->directorySeparator;
  47196. }
  47197. $subPathname .= $this->getFilename();
  47198. return new SplFileInfo($this->rootPath.$this->directorySeparator.$subPathname, $this->subPath, $subPathname);
  47199. }
  47200. public function getChildren()
  47201. {
  47202. try {
  47203. $children = parent::getChildren();
  47204. if ($children instanceof self) {
  47205. $children->ignoreUnreadableDirs = $this->ignoreUnreadableDirs;
  47206. $children->rewindable = &$this->rewindable;
  47207. $children->rootPath = $this->rootPath;
  47208. }
  47209. return $children;
  47210. } catch (\UnexpectedValueException $e) {
  47211. if ($this->ignoreUnreadableDirs) {
  47212. return new \RecursiveArrayIterator(array());
  47213. } else {
  47214. throw new AccessDeniedException($e->getMessage(), $e->getCode(), $e);
  47215. }
  47216. }
  47217. }
  47218. public function rewind()
  47219. {
  47220. if (false === $this->isRewindable()) {
  47221. return;
  47222. }
  47223. if (\PHP_VERSION_ID < 50523 || \PHP_VERSION_ID >= 50600 && \PHP_VERSION_ID < 50607) {
  47224. parent::next();
  47225. }
  47226. parent::rewind();
  47227. }
  47228. public function isRewindable()
  47229. {
  47230. if (null !== $this->rewindable) {
  47231. return $this->rewindable;
  47232. }
  47233. if ('' === $this->getPath()) {
  47234. return $this->rewindable = false;
  47235. }
  47236. if (false !== $stream = @opendir($this->getPath())) {
  47237. $infos = stream_get_meta_data($stream);
  47238. closedir($stream);
  47239. if ($infos['seekable']) {
  47240. return $this->rewindable = true;
  47241. }
  47242. }
  47243. return $this->rewindable = false;
  47244. }
  47245. }
  47246. <?php
  47247. namespace Symfony\Component\Finder\Iterator;
  47248. use Symfony\Component\Finder\Comparator\NumberComparator;
  47249. class SizeRangeFilterIterator extends FilterIterator
  47250. {
  47251. private $comparators = array();
  47252. public function __construct(\Iterator $iterator, array $comparators)
  47253. {
  47254. $this->comparators = $comparators;
  47255. parent::__construct($iterator);
  47256. }
  47257. public function accept()
  47258. {
  47259. $fileinfo = $this->current();
  47260. if (!$fileinfo->isFile()) {
  47261. return true;
  47262. }
  47263. $filesize = $fileinfo->getSize();
  47264. foreach ($this->comparators as $compare) {
  47265. if (!$compare->test($filesize)) {
  47266. return false;
  47267. }
  47268. }
  47269. return true;
  47270. }
  47271. }
  47272. <?php
  47273. namespace Symfony\Component\Finder\Iterator;
  47274. class SortableIterator implements \IteratorAggregate
  47275. {
  47276. const SORT_BY_NAME = 1;
  47277. const SORT_BY_TYPE = 2;
  47278. const SORT_BY_ACCESSED_TIME = 3;
  47279. const SORT_BY_CHANGED_TIME = 4;
  47280. const SORT_BY_MODIFIED_TIME = 5;
  47281. private $iterator;
  47282. private $sort;
  47283. public function __construct(\Traversable $iterator, $sort)
  47284. {
  47285. $this->iterator = $iterator;
  47286. if (self::SORT_BY_NAME === $sort) {
  47287. $this->sort = function ($a, $b) {
  47288. return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
  47289. };
  47290. } elseif (self::SORT_BY_TYPE === $sort) {
  47291. $this->sort = function ($a, $b) {
  47292. if ($a->isDir() && $b->isFile()) {
  47293. return -1;
  47294. } elseif ($a->isFile() && $b->isDir()) {
  47295. return 1;
  47296. }
  47297. return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
  47298. };
  47299. } elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
  47300. $this->sort = function ($a, $b) {
  47301. return $a->getATime() - $b->getATime();
  47302. };
  47303. } elseif (self::SORT_BY_CHANGED_TIME === $sort) {
  47304. $this->sort = function ($a, $b) {
  47305. return $a->getCTime() - $b->getCTime();
  47306. };
  47307. } elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
  47308. $this->sort = function ($a, $b) {
  47309. return $a->getMTime() - $b->getMTime();
  47310. };
  47311. } elseif (\is_callable($sort)) {
  47312. $this->sort = $sort;
  47313. } else {
  47314. throw new \InvalidArgumentException('The SortableIterator takes a PHP callable or a valid built-in sort algorithm as an argument.');
  47315. }
  47316. }
  47317. public function getIterator()
  47318. {
  47319. $array = iterator_to_array($this->iterator, true);
  47320. uasort($array, $this->sort);
  47321. return new \ArrayIterator($array);
  47322. }
  47323. }
  47324. Copyright (c) 2004-2018 Fabien Potencier
  47325. Permission is hereby granted, free of charge, to any person obtaining a copy
  47326. of this software and associated documentation files (the "Software"), to deal
  47327. in the Software without restriction, including without limitation the rights
  47328. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  47329. copies of the Software, and to permit persons to whom the Software is furnished
  47330. to do so, subject to the following conditions:
  47331. The above copyright notice and this permission notice shall be included in all
  47332. copies or substantial portions of the Software.
  47333. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  47334. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  47335. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  47336. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  47337. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  47338. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  47339. THE SOFTWARE.
  47340. <?php
  47341. namespace Symfony\Component\Finder\Shell;
  47342. @trigger_error('The '.__NAMESPACE__.'\Command class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  47343. class Command
  47344. {
  47345. private $parent;
  47346. private $bits = array();
  47347. private $labels = array();
  47348. private $errorHandler;
  47349. public function __construct(Command $parent = null)
  47350. {
  47351. $this->parent = $parent;
  47352. }
  47353. public function __toString()
  47354. {
  47355. return $this->join();
  47356. }
  47357. public static function create(Command $parent = null)
  47358. {
  47359. return new self($parent);
  47360. }
  47361. public static function escape($input)
  47362. {
  47363. return escapeshellcmd($input);
  47364. }
  47365. public static function quote($input)
  47366. {
  47367. return escapeshellarg($input);
  47368. }
  47369. public function add($bit)
  47370. {
  47371. $this->bits[] = $bit;
  47372. return $this;
  47373. }
  47374. public function top($bit)
  47375. {
  47376. array_unshift($this->bits, $bit);
  47377. foreach ($this->labels as $label => $index) {
  47378. ++$this->labels[$label];
  47379. }
  47380. return $this;
  47381. }
  47382. public function arg($arg)
  47383. {
  47384. $this->bits[] = self::quote($arg);
  47385. return $this;
  47386. }
  47387. public function cmd($esc)
  47388. {
  47389. $this->bits[] = self::escape($esc);
  47390. return $this;
  47391. }
  47392. public function ins($label)
  47393. {
  47394. if (isset($this->labels[$label])) {
  47395. throw new \RuntimeException(sprintf('Label "%s" already exists.', $label));
  47396. }
  47397. $this->bits[] = self::create($this);
  47398. $this->labels[$label] = \count($this->bits) - 1;
  47399. return $this->bits[$this->labels[$label]];
  47400. }
  47401. public function get($label)
  47402. {
  47403. if (!isset($this->labels[$label])) {
  47404. throw new \RuntimeException(sprintf('Label "%s" does not exist.', $label));
  47405. }
  47406. return $this->bits[$this->labels[$label]];
  47407. }
  47408. public function end()
  47409. {
  47410. if (null === $this->parent) {
  47411. throw new \RuntimeException('Calling end on root command doesn\'t make sense.');
  47412. }
  47413. return $this->parent;
  47414. }
  47415. public function length()
  47416. {
  47417. return \count($this->bits);
  47418. }
  47419. public function setErrorHandler(\Closure $errorHandler)
  47420. {
  47421. $this->errorHandler = $errorHandler;
  47422. return $this;
  47423. }
  47424. public function getErrorHandler()
  47425. {
  47426. return $this->errorHandler;
  47427. }
  47428. public function execute()
  47429. {
  47430. if (null === $errorHandler = $this->errorHandler) {
  47431. exec($this->join(), $output);
  47432. } else {
  47433. $process = proc_open($this->join(), array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes);
  47434. $output = preg_split('~(\r\n|\r|\n)~', stream_get_contents($pipes[1]), -1, PREG_SPLIT_NO_EMPTY);
  47435. if ($error = stream_get_contents($pipes[2])) {
  47436. $errorHandler($error);
  47437. }
  47438. proc_close($process);
  47439. }
  47440. return $output ?: array();
  47441. }
  47442. public function join()
  47443. {
  47444. return implode(' ', array_filter(
  47445. array_map(function ($bit) {
  47446. return $bit instanceof Command ? $bit->join() : ($bit ?: null);
  47447. }, $this->bits),
  47448. function ($bit) { return null !== $bit; }
  47449. ));
  47450. }
  47451. public function addAtIndex($bit, $index)
  47452. {
  47453. array_splice($this->bits, $index, 0, $bit instanceof self ? array($bit) : $bit);
  47454. return $this;
  47455. }
  47456. }
  47457. <?php
  47458. namespace Symfony\Component\Finder\Shell;
  47459. @trigger_error('The '.__NAMESPACE__.'\Shell class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  47460. class Shell
  47461. {
  47462. const TYPE_UNIX = 1;
  47463. const TYPE_DARWIN = 2;
  47464. const TYPE_CYGWIN = 3;
  47465. const TYPE_WINDOWS = 4;
  47466. const TYPE_BSD = 5;
  47467. private $type;
  47468. public function getType()
  47469. {
  47470. if (null === $this->type) {
  47471. $this->type = $this->guessType();
  47472. }
  47473. return $this->type;
  47474. }
  47475. public function testCommand($command)
  47476. {
  47477. if (!\function_exists('exec')) {
  47478. return false;
  47479. }
  47480. $testCommand = 'which ';
  47481. if (self::TYPE_WINDOWS === $this->type) {
  47482. $testCommand = 'where ';
  47483. }
  47484. $command = escapeshellcmd($command);
  47485. exec($testCommand.$command, $output, $code);
  47486. return 0 === $code && \count($output) > 0;
  47487. }
  47488. private function guessType()
  47489. {
  47490. $os = strtolower(PHP_OS);
  47491. if (false !== strpos($os, 'cygwin')) {
  47492. return self::TYPE_CYGWIN;
  47493. }
  47494. if (false !== strpos($os, 'darwin')) {
  47495. return self::TYPE_DARWIN;
  47496. }
  47497. if (false !== strpos($os, 'bsd')) {
  47498. return self::TYPE_BSD;
  47499. }
  47500. if (0 === strpos($os, 'win')) {
  47501. return self::TYPE_WINDOWS;
  47502. }
  47503. return self::TYPE_UNIX;
  47504. }
  47505. }
  47506. <?php
  47507. namespace Symfony\Component\Finder;
  47508. class SplFileInfo extends \SplFileInfo
  47509. {
  47510. private $relativePath;
  47511. private $relativePathname;
  47512. public function __construct($file, $relativePath, $relativePathname)
  47513. {
  47514. parent::__construct($file);
  47515. $this->relativePath = $relativePath;
  47516. $this->relativePathname = $relativePathname;
  47517. }
  47518. public function getRelativePath()
  47519. {
  47520. return $this->relativePath;
  47521. }
  47522. public function getRelativePathname()
  47523. {
  47524. return $this->relativePathname;
  47525. }
  47526. public function getContents()
  47527. {
  47528. set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
  47529. $content = file_get_contents($this->getPathname());
  47530. restore_error_handler();
  47531. if (false === $content) {
  47532. throw new \RuntimeException($error);
  47533. }
  47534. return $content;
  47535. }
  47536. }
  47537. <?php
  47538. namespace Symfony\Polyfill\Ctype;
  47539. final class Ctype
  47540. {
  47541. public static function ctype_alnum($text)
  47542. {
  47543. $text = self::convert_int_to_char_for_ctype($text);
  47544. return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z0-9]/', $text);
  47545. }
  47546. public static function ctype_alpha($text)
  47547. {
  47548. $text = self::convert_int_to_char_for_ctype($text);
  47549. return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z]/', $text);
  47550. }
  47551. public static function ctype_cntrl($text)
  47552. {
  47553. $text = self::convert_int_to_char_for_ctype($text);
  47554. return \is_string($text) && '' !== $text && !preg_match('/[^\x00-\x1f\x7f]/', $text);
  47555. }
  47556. public static function ctype_digit($text)
  47557. {
  47558. $text = self::convert_int_to_char_for_ctype($text);
  47559. return \is_string($text) && '' !== $text && !preg_match('/[^0-9]/', $text);
  47560. }
  47561. public static function ctype_graph($text)
  47562. {
  47563. $text = self::convert_int_to_char_for_ctype($text);
  47564. return \is_string($text) && '' !== $text && !preg_match('/[^!-~]/', $text);
  47565. }
  47566. public static function ctype_lower($text)
  47567. {
  47568. $text = self::convert_int_to_char_for_ctype($text);
  47569. return \is_string($text) && '' !== $text && !preg_match('/[^a-z]/', $text);
  47570. }
  47571. public static function ctype_print($text)
  47572. {
  47573. $text = self::convert_int_to_char_for_ctype($text);
  47574. return \is_string($text) && '' !== $text && !preg_match('/[^ -~]/', $text);
  47575. }
  47576. public static function ctype_punct($text)
  47577. {
  47578. $text = self::convert_int_to_char_for_ctype($text);
  47579. return \is_string($text) && '' !== $text && !preg_match('/[^!-\/\:-@\[-`\{-~]/', $text);
  47580. }
  47581. public static function ctype_space($text)
  47582. {
  47583. $text = self::convert_int_to_char_for_ctype($text);
  47584. return \is_string($text) && '' !== $text && !preg_match('/[^\s]/', $text);
  47585. }
  47586. public static function ctype_upper($text)
  47587. {
  47588. $text = self::convert_int_to_char_for_ctype($text);
  47589. return \is_string($text) && '' !== $text && !preg_match('/[^A-Z]/', $text);
  47590. }
  47591. public static function ctype_xdigit($text)
  47592. {
  47593. $text = self::convert_int_to_char_for_ctype($text);
  47594. return \is_string($text) && '' !== $text && !preg_match('/[^A-Fa-f0-9]/', $text);
  47595. }
  47596. private static function convert_int_to_char_for_ctype($int)
  47597. {
  47598. if (!\is_int($int)) {
  47599. return $int;
  47600. }
  47601. if ($int < -128 || $int > 255) {
  47602. return (string) $int;
  47603. }
  47604. if ($int < 0) {
  47605. $int += 256;
  47606. }
  47607. return \chr($int);
  47608. }
  47609. }
  47610. Copyright (c) 2018-2019 Fabien Potencier
  47611. Permission is hereby granted, free of charge, to any person obtaining a copy
  47612. of this software and associated documentation files (the "Software"), to deal
  47613. in the Software without restriction, including without limitation the rights
  47614. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  47615. copies of the Software, and to permit persons to whom the Software is furnished
  47616. to do so, subject to the following conditions:
  47617. The above copyright notice and this permission notice shall be included in all
  47618. copies or substantial portions of the Software.
  47619. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  47620. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  47621. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  47622. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  47623. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  47624. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  47625. THE SOFTWARE.
  47626. <?php
  47627. use Symfony\Polyfill\Ctype as p;
  47628. if (!function_exists('ctype_alnum')) {
  47629. function ctype_alnum($text) { return p\Ctype::ctype_alnum($text); }
  47630. }
  47631. if (!function_exists('ctype_alpha')) {
  47632. function ctype_alpha($text) { return p\Ctype::ctype_alpha($text); }
  47633. }
  47634. if (!function_exists('ctype_cntrl')) {
  47635. function ctype_cntrl($text) { return p\Ctype::ctype_cntrl($text); }
  47636. }
  47637. if (!function_exists('ctype_digit')) {
  47638. function ctype_digit($text) { return p\Ctype::ctype_digit($text); }
  47639. }
  47640. if (!function_exists('ctype_graph')) {
  47641. function ctype_graph($text) { return p\Ctype::ctype_graph($text); }
  47642. }
  47643. if (!function_exists('ctype_lower')) {
  47644. function ctype_lower($text) { return p\Ctype::ctype_lower($text); }
  47645. }
  47646. if (!function_exists('ctype_print')) {
  47647. function ctype_print($text) { return p\Ctype::ctype_print($text); }
  47648. }
  47649. if (!function_exists('ctype_punct')) {
  47650. function ctype_punct($text) { return p\Ctype::ctype_punct($text); }
  47651. }
  47652. if (!function_exists('ctype_space')) {
  47653. function ctype_space($text) { return p\Ctype::ctype_space($text); }
  47654. }
  47655. if (!function_exists('ctype_upper')) {
  47656. function ctype_upper($text) { return p\Ctype::ctype_upper($text); }
  47657. }
  47658. if (!function_exists('ctype_xdigit')) {
  47659. function ctype_xdigit($text) { return p\Ctype::ctype_xdigit($text); }
  47660. }
  47661. Copyright (c) 2015-2019 Fabien Potencier
  47662. Permission is hereby granted, free of charge, to any person obtaining a copy
  47663. of this software and associated documentation files (the "Software"), to deal
  47664. in the Software without restriction, including without limitation the rights
  47665. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  47666. copies of the Software, and to permit persons to whom the Software is furnished
  47667. to do so, subject to the following conditions:
  47668. The above copyright notice and this permission notice shall be included in all
  47669. copies or substantial portions of the Software.
  47670. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  47671. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  47672. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  47673. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  47674. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  47675. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  47676. THE SOFTWARE.
  47677. <?php
  47678. namespace Symfony\Polyfill\Mbstring;
  47679. final class Mbstring
  47680. {
  47681. const MB_CASE_FOLD = PHP_INT_MAX;
  47682. private static $encodingList = array('ASCII', 'UTF-8');
  47683. private static $language = 'neutral';
  47684. private static $internalEncoding = 'UTF-8';
  47685. private static $caseFold = array(
  47686. array('µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"),
  47687. array('μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', '�', 'ε', "\xE1\xB9\xA1", 'ι'),
  47688. );
  47689. public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
  47690. {
  47691. if (\is_array($fromEncoding) || false !== strpos($fromEncoding, ',')) {
  47692. $fromEncoding = self::mb_detect_encoding($s, $fromEncoding);
  47693. } else {
  47694. $fromEncoding = self::getEncoding($fromEncoding);
  47695. }
  47696. $toEncoding = self::getEncoding($toEncoding);
  47697. if ('BASE64' === $fromEncoding) {
  47698. $s = base64_decode($s);
  47699. $fromEncoding = $toEncoding;
  47700. }
  47701. if ('BASE64' === $toEncoding) {
  47702. return base64_encode($s);
  47703. }
  47704. if ('HTML-ENTITIES' === $toEncoding || 'HTML' === $toEncoding) {
  47705. if ('HTML-ENTITIES' === $fromEncoding || 'HTML' === $fromEncoding) {
  47706. $fromEncoding = 'Windows-1252';
  47707. }
  47708. if ('UTF-8' !== $fromEncoding) {
  47709. $s = iconv($fromEncoding, 'UTF-8//IGNORE', $s);
  47710. }
  47711. return preg_replace_callback('/[\x80-\xFF]+/', array(__CLASS__, 'html_encoding_callback'), $s);
  47712. }
  47713. if ('HTML-ENTITIES' === $fromEncoding) {
  47714. $s = html_entity_decode($s, ENT_COMPAT, 'UTF-8');
  47715. $fromEncoding = 'UTF-8';
  47716. }
  47717. return iconv($fromEncoding, $toEncoding.'//IGNORE', $s);
  47718. }
  47719. public static function mb_convert_variables($toEncoding, $fromEncoding, &$a = null, &$b = null, &$c = null, &$d = null, &$e = null, &$f = null)
  47720. {
  47721. $vars = array(&$a, &$b, &$c, &$d, &$e, &$f);
  47722. $ok = true;
  47723. array_walk_recursive($vars, function (&$v) use (&$ok, $toEncoding, $fromEncoding) {
  47724. if (false === $v = Mbstring::mb_convert_encoding($v, $toEncoding, $fromEncoding)) {
  47725. $ok = false;
  47726. }
  47727. });
  47728. return $ok ? $fromEncoding : false;
  47729. }
  47730. public static function mb_decode_mimeheader($s)
  47731. {
  47732. return iconv_mime_decode($s, 2, self::$internalEncoding);
  47733. }
  47734. public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null)
  47735. {
  47736. trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', E_USER_WARNING);
  47737. }
  47738. public static function mb_decode_numericentity($s, $convmap, $encoding = null)
  47739. {
  47740. if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
  47741. trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING);
  47742. return null;
  47743. }
  47744. if (!\is_array($convmap) || !$convmap) {
  47745. return false;
  47746. }
  47747. if (null !== $encoding && !\is_scalar($encoding)) {
  47748. trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING);
  47749. return '';
  47750. }
  47751. $s = (string) $s;
  47752. if ('' === $s) {
  47753. return '';
  47754. }
  47755. $encoding = self::getEncoding($encoding);
  47756. if ('UTF-8' === $encoding) {
  47757. $encoding = null;
  47758. if (!preg_match('//u', $s)) {
  47759. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  47760. }
  47761. } else {
  47762. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  47763. }
  47764. $cnt = floor(\count($convmap) / 4) * 4;
  47765. for ($i = 0; $i < $cnt; $i += 4) {
  47766. $convmap[$i] += $convmap[$i + 2];
  47767. $convmap[$i + 1] += $convmap[$i + 2];
  47768. }
  47769. $s = preg_replace_callback('/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))(?!&);?/', function (array $m) use ($cnt, $convmap) {
  47770. $c = isset($m[2]) ? (int) hexdec($m[2]) : $m[1];
  47771. for ($i = 0; $i < $cnt; $i += 4) {
  47772. if ($c >= $convmap[$i] && $c <= $convmap[$i + 1]) {
  47773. return Mbstring::mb_chr($c - $convmap[$i + 2]);
  47774. }
  47775. }
  47776. return $m[0];
  47777. }, $s);
  47778. if (null === $encoding) {
  47779. return $s;
  47780. }
  47781. return iconv('UTF-8', $encoding.'//IGNORE', $s);
  47782. }
  47783. public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false)
  47784. {
  47785. if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
  47786. trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING);
  47787. return null;
  47788. }
  47789. if (!\is_array($convmap) || !$convmap) {
  47790. return false;
  47791. }
  47792. if (null !== $encoding && !\is_scalar($encoding)) {
  47793. trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING);
  47794. return null;
  47795. }
  47796. if (null !== $is_hex && !\is_scalar($is_hex)) {
  47797. trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.\gettype($s).' given', E_USER_WARNING);
  47798. return null;
  47799. }
  47800. $s = (string) $s;
  47801. if ('' === $s) {
  47802. return '';
  47803. }
  47804. $encoding = self::getEncoding($encoding);
  47805. if ('UTF-8' === $encoding) {
  47806. $encoding = null;
  47807. if (!preg_match('//u', $s)) {
  47808. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  47809. }
  47810. } else {
  47811. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  47812. }
  47813. static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
  47814. $cnt = floor(\count($convmap) / 4) * 4;
  47815. $i = 0;
  47816. $len = \strlen($s);
  47817. $result = '';
  47818. while ($i < $len) {
  47819. $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
  47820. $uchr = substr($s, $i, $ulen);
  47821. $i += $ulen;
  47822. $c = self::mb_ord($uchr);
  47823. for ($j = 0; $j < $cnt; $j += 4) {
  47824. if ($c >= $convmap[$j] && $c <= $convmap[$j + 1]) {
  47825. $cOffset = ($c + $convmap[$j + 2]) & $convmap[$j + 3];
  47826. $result .= $is_hex ? sprintf('&#x%X;', $cOffset) : '&#'.$cOffset.';';
  47827. continue 2;
  47828. }
  47829. }
  47830. $result .= $uchr;
  47831. }
  47832. if (null === $encoding) {
  47833. return $result;
  47834. }
  47835. return iconv('UTF-8', $encoding.'//IGNORE', $result);
  47836. }
  47837. public static function mb_convert_case($s, $mode, $encoding = null)
  47838. {
  47839. $s = (string) $s;
  47840. if ('' === $s) {
  47841. return '';
  47842. }
  47843. $encoding = self::getEncoding($encoding);
  47844. if ('UTF-8' === $encoding) {
  47845. $encoding = null;
  47846. if (!preg_match('//u', $s)) {
  47847. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  47848. }
  47849. } else {
  47850. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  47851. }
  47852. if (MB_CASE_TITLE == $mode) {
  47853. static $titleRegexp = null;
  47854. if (null === $titleRegexp) {
  47855. $titleRegexp = self::getData('titleCaseRegexp');
  47856. }
  47857. $s = preg_replace_callback($titleRegexp, array(__CLASS__, 'title_case'), $s);
  47858. } else {
  47859. if (MB_CASE_UPPER == $mode) {
  47860. static $upper = null;
  47861. if (null === $upper) {
  47862. $upper = self::getData('upperCase');
  47863. }
  47864. $map = $upper;
  47865. } else {
  47866. if (self::MB_CASE_FOLD === $mode) {
  47867. $s = str_replace(self::$caseFold[0], self::$caseFold[1], $s);
  47868. }
  47869. static $lower = null;
  47870. if (null === $lower) {
  47871. $lower = self::getData('lowerCase');
  47872. }
  47873. $map = $lower;
  47874. }
  47875. static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
  47876. $i = 0;
  47877. $len = \strlen($s);
  47878. while ($i < $len) {
  47879. $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
  47880. $uchr = substr($s, $i, $ulen);
  47881. $i += $ulen;
  47882. if (isset($map[$uchr])) {
  47883. $uchr = $map[$uchr];
  47884. $nlen = \strlen($uchr);
  47885. if ($nlen == $ulen) {
  47886. $nlen = $i;
  47887. do {
  47888. $s[--$nlen] = $uchr[--$ulen];
  47889. } while ($ulen);
  47890. } else {
  47891. $s = substr_replace($s, $uchr, $i - $ulen, $ulen);
  47892. $len += $nlen - $ulen;
  47893. $i += $nlen - $ulen;
  47894. }
  47895. }
  47896. }
  47897. }
  47898. if (null === $encoding) {
  47899. return $s;
  47900. }
  47901. return iconv('UTF-8', $encoding.'//IGNORE', $s);
  47902. }
  47903. public static function mb_internal_encoding($encoding = null)
  47904. {
  47905. if (null === $encoding) {
  47906. return self::$internalEncoding;
  47907. }
  47908. $encoding = self::getEncoding($encoding);
  47909. if ('UTF-8' === $encoding || false !== @iconv($encoding, $encoding, ' ')) {
  47910. self::$internalEncoding = $encoding;
  47911. return true;
  47912. }
  47913. return false;
  47914. }
  47915. public static function mb_language($lang = null)
  47916. {
  47917. if (null === $lang) {
  47918. return self::$language;
  47919. }
  47920. switch ($lang = strtolower($lang)) {
  47921. case 'uni':
  47922. case 'neutral':
  47923. self::$language = $lang;
  47924. return true;
  47925. }
  47926. return false;
  47927. }
  47928. public static function mb_list_encodings()
  47929. {
  47930. return array('UTF-8');
  47931. }
  47932. public static function mb_encoding_aliases($encoding)
  47933. {
  47934. switch (strtoupper($encoding)) {
  47935. case 'UTF8':
  47936. case 'UTF-8':
  47937. return array('utf8');
  47938. }
  47939. return false;
  47940. }
  47941. public static function mb_check_encoding($var = null, $encoding = null)
  47942. {
  47943. if (null === $encoding) {
  47944. if (null === $var) {
  47945. return false;
  47946. }
  47947. $encoding = self::$internalEncoding;
  47948. }
  47949. return self::mb_detect_encoding($var, array($encoding)) || false !== @iconv($encoding, $encoding, $var);
  47950. }
  47951. public static function mb_detect_encoding($str, $encodingList = null, $strict = false)
  47952. {
  47953. if (null === $encodingList) {
  47954. $encodingList = self::$encodingList;
  47955. } else {
  47956. if (!\is_array($encodingList)) {
  47957. $encodingList = array_map('trim', explode(',', $encodingList));
  47958. }
  47959. $encodingList = array_map('strtoupper', $encodingList);
  47960. }
  47961. foreach ($encodingList as $enc) {
  47962. switch ($enc) {
  47963. case 'ASCII':
  47964. if (!preg_match('/[\x80-\xFF]/', $str)) {
  47965. return $enc;
  47966. }
  47967. break;
  47968. case 'UTF8':
  47969. case 'UTF-8':
  47970. if (preg_match('//u', $str)) {
  47971. return 'UTF-8';
  47972. }
  47973. break;
  47974. default:
  47975. if (0 === strncmp($enc, 'ISO-8859-', 9)) {
  47976. return $enc;
  47977. }
  47978. }
  47979. }
  47980. return false;
  47981. }
  47982. public static function mb_detect_order($encodingList = null)
  47983. {
  47984. if (null === $encodingList) {
  47985. return self::$encodingList;
  47986. }
  47987. if (!\is_array($encodingList)) {
  47988. $encodingList = array_map('trim', explode(',', $encodingList));
  47989. }
  47990. $encodingList = array_map('strtoupper', $encodingList);
  47991. foreach ($encodingList as $enc) {
  47992. switch ($enc) {
  47993. default:
  47994. if (strncmp($enc, 'ISO-8859-', 9)) {
  47995. return false;
  47996. }
  47997. case 'ASCII':
  47998. case 'UTF8':
  47999. case 'UTF-8':
  48000. }
  48001. }
  48002. self::$encodingList = $encodingList;
  48003. return true;
  48004. }
  48005. public static function mb_strlen($s, $encoding = null)
  48006. {
  48007. $encoding = self::getEncoding($encoding);
  48008. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  48009. return \strlen($s);
  48010. }
  48011. return @iconv_strlen($s, $encoding);
  48012. }
  48013. public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null)
  48014. {
  48015. $encoding = self::getEncoding($encoding);
  48016. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  48017. return strpos($haystack, $needle, $offset);
  48018. }
  48019. $needle = (string) $needle;
  48020. if ('' === $needle) {
  48021. trigger_error(__METHOD__.': Empty delimiter', E_USER_WARNING);
  48022. return false;
  48023. }
  48024. return iconv_strpos($haystack, $needle, $offset, $encoding);
  48025. }
  48026. public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null)
  48027. {
  48028. $encoding = self::getEncoding($encoding);
  48029. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  48030. return strrpos($haystack, $needle, $offset);
  48031. }
  48032. if ($offset != (int) $offset) {
  48033. $offset = 0;
  48034. } elseif ($offset = (int) $offset) {
  48035. if ($offset < 0) {
  48036. if (0 > $offset += self::mb_strlen($needle)) {
  48037. $haystack = self::mb_substr($haystack, 0, $offset, $encoding);
  48038. }
  48039. $offset = 0;
  48040. } else {
  48041. $haystack = self::mb_substr($haystack, $offset, 2147483647, $encoding);
  48042. }
  48043. }
  48044. $pos = iconv_strrpos($haystack, $needle, $encoding);
  48045. return false !== $pos ? $offset + $pos : false;
  48046. }
  48047. public static function mb_str_split($string, $split_length = 1, $encoding = null)
  48048. {
  48049. if (null !== $string && !\is_scalar($string) && !(\is_object($string) && \method_exists($string, '__toString'))) {
  48050. trigger_error('mb_str_split() expects parameter 1 to be string, '.\gettype($string).' given', E_USER_WARNING);
  48051. return null;
  48052. }
  48053. if (1 > $split_length = (int) $split_length) {
  48054. trigger_error('The length of each segment must be greater than zero', E_USER_WARNING);
  48055. return false;
  48056. }
  48057. if (null === $encoding) {
  48058. $encoding = mb_internal_encoding();
  48059. }
  48060. if ('UTF-8' === $encoding = self::getEncoding($encoding)) {
  48061. $rx = '/(';
  48062. while (65535 < $split_length) {
  48063. $rx .= '.{65535}';
  48064. $split_length -= 65535;
  48065. }
  48066. $rx .= '.{'.$split_length.'})/us';
  48067. return preg_split($rx, $string, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
  48068. }
  48069. $result = array();
  48070. $length = mb_strlen($string, $encoding);
  48071. for ($i = 0; $i < $length; $i += $split_length) {
  48072. $result[] = mb_substr($string, $i, $split_length, $encoding);
  48073. }
  48074. return $result;
  48075. }
  48076. public static function mb_strtolower($s, $encoding = null)
  48077. {
  48078. return self::mb_convert_case($s, MB_CASE_LOWER, $encoding);
  48079. }
  48080. public static function mb_strtoupper($s, $encoding = null)
  48081. {
  48082. return self::mb_convert_case($s, MB_CASE_UPPER, $encoding);
  48083. }
  48084. public static function mb_substitute_character($c = null)
  48085. {
  48086. if (0 === strcasecmp($c, 'none')) {
  48087. return true;
  48088. }
  48089. return null !== $c ? false : 'none';
  48090. }
  48091. public static function mb_substr($s, $start, $length = null, $encoding = null)
  48092. {
  48093. $encoding = self::getEncoding($encoding);
  48094. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  48095. return (string) substr($s, $start, null === $length ? 2147483647 : $length);
  48096. }
  48097. if ($start < 0) {
  48098. $start = iconv_strlen($s, $encoding) + $start;
  48099. if ($start < 0) {
  48100. $start = 0;
  48101. }
  48102. }
  48103. if (null === $length) {
  48104. $length = 2147483647;
  48105. } elseif ($length < 0) {
  48106. $length = iconv_strlen($s, $encoding) + $length - $start;
  48107. if ($length < 0) {
  48108. return '';
  48109. }
  48110. }
  48111. return (string) iconv_substr($s, $start, $length, $encoding);
  48112. }
  48113. public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null)
  48114. {
  48115. $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
  48116. $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
  48117. return self::mb_strpos($haystack, $needle, $offset, $encoding);
  48118. }
  48119. public static function mb_stristr($haystack, $needle, $part = false, $encoding = null)
  48120. {
  48121. $pos = self::mb_stripos($haystack, $needle, 0, $encoding);
  48122. return self::getSubpart($pos, $part, $haystack, $encoding);
  48123. }
  48124. public static function mb_strrchr($haystack, $needle, $part = false, $encoding = null)
  48125. {
  48126. $encoding = self::getEncoding($encoding);
  48127. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  48128. return strrchr($haystack, $needle, $part);
  48129. }
  48130. $needle = self::mb_substr($needle, 0, 1, $encoding);
  48131. $pos = iconv_strrpos($haystack, $needle, $encoding);
  48132. return self::getSubpart($pos, $part, $haystack, $encoding);
  48133. }
  48134. public static function mb_strrichr($haystack, $needle, $part = false, $encoding = null)
  48135. {
  48136. $needle = self::mb_substr($needle, 0, 1, $encoding);
  48137. $pos = self::mb_strripos($haystack, $needle, $encoding);
  48138. return self::getSubpart($pos, $part, $haystack, $encoding);
  48139. }
  48140. public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null)
  48141. {
  48142. $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
  48143. $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
  48144. return self::mb_strrpos($haystack, $needle, $offset, $encoding);
  48145. }
  48146. public static function mb_strstr($haystack, $needle, $part = false, $encoding = null)
  48147. {
  48148. $pos = strpos($haystack, $needle);
  48149. if (false === $pos) {
  48150. return false;
  48151. }
  48152. if ($part) {
  48153. return substr($haystack, 0, $pos);
  48154. }
  48155. return substr($haystack, $pos);
  48156. }
  48157. public static function mb_get_info($type = 'all')
  48158. {
  48159. $info = array(
  48160. 'internal_encoding' => self::$internalEncoding,
  48161. 'http_output' => 'pass',
  48162. 'http_output_conv_mimetypes' => '^(text/|application/xhtml\+xml)',
  48163. 'func_overload' => 0,
  48164. 'func_overload_list' => 'no overload',
  48165. 'mail_charset' => 'UTF-8',
  48166. 'mail_header_encoding' => 'BASE64',
  48167. 'mail_body_encoding' => 'BASE64',
  48168. 'illegal_chars' => 0,
  48169. 'encoding_translation' => 'Off',
  48170. 'language' => self::$language,
  48171. 'detect_order' => self::$encodingList,
  48172. 'substitute_character' => 'none',
  48173. 'strict_detection' => 'Off',
  48174. );
  48175. if ('all' === $type) {
  48176. return $info;
  48177. }
  48178. if (isset($info[$type])) {
  48179. return $info[$type];
  48180. }
  48181. return false;
  48182. }
  48183. public static function mb_http_input($type = '')
  48184. {
  48185. return false;
  48186. }
  48187. public static function mb_http_output($encoding = null)
  48188. {
  48189. return null !== $encoding ? 'pass' === $encoding : 'pass';
  48190. }
  48191. public static function mb_strwidth($s, $encoding = null)
  48192. {
  48193. $encoding = self::getEncoding($encoding);
  48194. if ('UTF-8' !== $encoding) {
  48195. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  48196. }
  48197. $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);
  48198. return ($wide << 1) + iconv_strlen($s, 'UTF-8');
  48199. }
  48200. public static function mb_substr_count($haystack, $needle, $encoding = null)
  48201. {
  48202. return substr_count($haystack, $needle);
  48203. }
  48204. public static function mb_output_handler($contents, $status)
  48205. {
  48206. return $contents;
  48207. }
  48208. public static function mb_chr($code, $encoding = null)
  48209. {
  48210. if (0x80 > $code %= 0x200000) {
  48211. $s = \chr($code);
  48212. } elseif (0x800 > $code) {
  48213. $s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
  48214. } elseif (0x10000 > $code) {
  48215. $s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  48216. } else {
  48217. $s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  48218. }
  48219. if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
  48220. $s = mb_convert_encoding($s, $encoding, 'UTF-8');
  48221. }
  48222. return $s;
  48223. }
  48224. public static function mb_ord($s, $encoding = null)
  48225. {
  48226. if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
  48227. $s = mb_convert_encoding($s, 'UTF-8', $encoding);
  48228. }
  48229. if (1 === \strlen($s)) {
  48230. return \ord($s);
  48231. }
  48232. $code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
  48233. if (0xF0 <= $code) {
  48234. return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80;
  48235. }
  48236. if (0xE0 <= $code) {
  48237. return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80;
  48238. }
  48239. if (0xC0 <= $code) {
  48240. return (($code - 0xC0) << 6) + $s[2] - 0x80;
  48241. }
  48242. return $code;
  48243. }
  48244. private static function getSubpart($pos, $part, $haystack, $encoding)
  48245. {
  48246. if (false === $pos) {
  48247. return false;
  48248. }
  48249. if ($part) {
  48250. return self::mb_substr($haystack, 0, $pos, $encoding);
  48251. }
  48252. return self::mb_substr($haystack, $pos, null, $encoding);
  48253. }
  48254. private static function html_encoding_callback(array $m)
  48255. {
  48256. $i = 1;
  48257. $entities = '';
  48258. $m = unpack('C*', htmlentities($m[0], ENT_COMPAT, 'UTF-8'));
  48259. while (isset($m[$i])) {
  48260. if (0x80 > $m[$i]) {
  48261. $entities .= \chr($m[$i++]);
  48262. continue;
  48263. }
  48264. if (0xF0 <= $m[$i]) {
  48265. $c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
  48266. } elseif (0xE0 <= $m[$i]) {
  48267. $c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
  48268. } else {
  48269. $c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80;
  48270. }
  48271. $entities .= '&#'.$c.';';
  48272. }
  48273. return $entities;
  48274. }
  48275. private static function title_case(array $s)
  48276. {
  48277. return self::mb_convert_case($s[1], MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], MB_CASE_LOWER, 'UTF-8');
  48278. }
  48279. private static function getData($file)
  48280. {
  48281. if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) {
  48282. return require $file;
  48283. }
  48284. return false;
  48285. }
  48286. private static function getEncoding($encoding)
  48287. {
  48288. if (null === $encoding) {
  48289. return self::$internalEncoding;
  48290. }
  48291. if ('UTF-8' === $encoding) {
  48292. return 'UTF-8';
  48293. }
  48294. $encoding = strtoupper($encoding);
  48295. if ('8BIT' === $encoding || 'BINARY' === $encoding) {
  48296. return 'CP850';
  48297. }
  48298. if ('UTF8' === $encoding) {
  48299. return 'UTF-8';
  48300. }
  48301. return $encoding;
  48302. }
  48303. }
  48304. <?php
  48305. return array (
  48306. 'A' => 'a',
  48307. 'B' => 'b',
  48308. 'C' => 'c',
  48309. 'D' => 'd',
  48310. 'E' => 'e',
  48311. 'F' => 'f',
  48312. 'G' => 'g',
  48313. 'H' => 'h',
  48314. 'I' => 'i',
  48315. 'J' => 'j',
  48316. 'K' => 'k',
  48317. 'L' => 'l',
  48318. 'M' => 'm',
  48319. 'N' => 'n',
  48320. 'O' => 'o',
  48321. 'P' => 'p',
  48322. 'Q' => 'q',
  48323. 'R' => 'r',
  48324. 'S' => 's',
  48325. 'T' => 't',
  48326. 'U' => 'u',
  48327. 'V' => 'v',
  48328. 'W' => 'w',
  48329. 'X' => 'x',
  48330. 'Y' => 'y',
  48331. 'Z' => 'z',
  48332. 'À' => 'à',
  48333. '�' => 'á',
  48334. 'Â' => 'â',
  48335. 'Ã' => 'ã',
  48336. 'Ä' => 'ä',
  48337. 'Ã…' => 'Ã¥',
  48338. 'Æ' => 'æ',
  48339. 'Ç' => 'ç',
  48340. 'È' => 'è',
  48341. 'É' => 'é',
  48342. 'Ê' => 'ê',
  48343. 'Ë' => 'ë',
  48344. 'Ì' => 'ì',
  48345. '�' => 'í',
  48346. 'Î' => 'î',
  48347. '�' => 'ï',
  48348. '�' => 'ð',
  48349. 'Ñ' => 'ñ',
  48350. 'Ò' => 'ò',
  48351. 'Ó' => 'ó',
  48352. 'Ô' => 'ô',
  48353. 'Õ' => 'õ',
  48354. 'Ö' => 'ö',
  48355. 'Ø' => 'ø',
  48356. 'Ù' => 'ù',
  48357. 'Ú' => 'ú',
  48358. 'Û' => 'û',
  48359. 'Ü' => 'ü',
  48360. '�' => 'ý',
  48361. 'Þ' => 'þ',
  48362. 'Ā' => '�',
  48363. 'Ă' => 'ă',
  48364. 'Ä„' => 'Ä…',
  48365. 'Ć' => 'ć',
  48366. 'Ĉ' => 'ĉ',
  48367. 'ÄŠ' => 'Ä‹',
  48368. 'Č' => '�',
  48369. 'Ď' => '�',
  48370. '�' => 'đ',
  48371. 'Ä’' => 'Ä“',
  48372. 'Ä”' => 'Ä•',
  48373. 'Ä–' => 'Ä—',
  48374. 'Ę' => 'ę',
  48375. 'Äš' => 'Ä›',
  48376. 'Ĝ' => '�',
  48377. 'Äž' => 'ÄŸ',
  48378. 'Ä ' => 'Ä¡',
  48379. 'Ä¢' => 'Ä£',
  48380. 'Ĥ' => 'ĥ',
  48381. 'Ħ' => 'ħ',
  48382. 'Ĩ' => 'ĩ',
  48383. 'Ī' => 'ī',
  48384. 'Ĭ' => 'ĭ',
  48385. 'Į' => 'į',
  48386. 'İ' => 'i',
  48387. 'IJ' => 'ij',
  48388. 'Ĵ' => 'ĵ',
  48389. 'Ķ' => 'ķ',
  48390. 'Ĺ' => 'ĺ',
  48391. 'Ļ' => 'ļ',
  48392. 'Ľ' => 'ľ',
  48393. 'Ä¿' => 'Å€',
  48394. '�' => 'ł',
  48395. 'Ń' => 'ń',
  48396. 'Ņ' => 'ņ',
  48397. 'Ň' => 'ň',
  48398. 'ÅŠ' => 'Å‹',
  48399. 'Ō' => '�',
  48400. 'Ŏ' => '�',
  48401. '�' => 'ő',
  48402. 'Å’' => 'Å“',
  48403. 'Å”' => 'Å•',
  48404. 'Å–' => 'Å—',
  48405. 'Ř' => 'ř',
  48406. 'Åš' => 'Å›',
  48407. 'Ŝ' => '�',
  48408. 'Åž' => 'ÅŸ',
  48409. 'Å ' => 'Å¡',
  48410. 'Å¢' => 'Å£',
  48411. 'Ť' => 'ť',
  48412. 'Ŧ' => 'ŧ',
  48413. 'Ũ' => 'ũ',
  48414. 'Ū' => 'ū',
  48415. 'Ŭ' => 'ŭ',
  48416. 'Ů' => 'ů',
  48417. 'Ű' => 'ű',
  48418. 'Ų' => 'ų',
  48419. 'Ŵ' => 'ŵ',
  48420. 'Ŷ' => 'ŷ',
  48421. 'Ÿ' => 'ÿ',
  48422. 'Ź' => 'ź',
  48423. 'Ż' => 'ż',
  48424. 'Ž' => 'ž',
  48425. '�' => 'ɓ',
  48426. 'Ƃ' => 'ƃ',
  48427. 'Æ„' => 'Æ…',
  48428. 'Ɔ' => 'ɔ',
  48429. 'Ƈ' => 'ƈ',
  48430. 'Ɖ' => 'ɖ',
  48431. 'ÆŠ' => 'É—',
  48432. 'Ƌ' => 'ƌ',
  48433. 'Ǝ' => '�',
  48434. '�' => 'ə',
  48435. '�' => 'ɛ',
  48436. 'Æ‘' => 'Æ’',
  48437. 'Æ“' => 'É ',
  48438. 'Æ”' => 'É£',
  48439. 'Æ–' => 'É©',
  48440. 'Ɨ' => 'ɨ',
  48441. 'Ƙ' => 'ƙ',
  48442. 'Ɯ' => 'ɯ',
  48443. '�' => 'ɲ',
  48444. 'Ɵ' => 'ɵ',
  48445. 'Æ ' => 'Æ¡',
  48446. 'Æ¢' => 'Æ£',
  48447. 'Ƥ' => 'ƥ',
  48448. 'Ʀ' => 'ʀ',
  48449. 'Ƨ' => 'ƨ',
  48450. 'Ʃ' => 'ʃ',
  48451. 'Ƭ' => 'ƭ',
  48452. 'Ʈ' => 'ʈ',
  48453. 'Ư' => 'ư',
  48454. 'Ʊ' => 'ʊ',
  48455. 'Ʋ' => 'ʋ',
  48456. 'Ƴ' => 'ƴ',
  48457. 'Ƶ' => 'ƶ',
  48458. 'Æ·' => 'Ê’',
  48459. 'Ƹ' => 'ƹ',
  48460. 'Ƽ' => 'ƽ',
  48461. 'DŽ' => 'dž',
  48462. 'Dž' => 'dž',
  48463. 'LJ' => 'lj',
  48464. 'Lj' => 'lj',
  48465. 'NJ' => 'nj',
  48466. 'Nj' => 'nj',
  48467. '�' => 'ǎ',
  48468. '�' => '�',
  48469. 'Ç‘' => 'Ç’',
  48470. 'Ç“' => 'Ç”',
  48471. 'Ç•' => 'Ç–',
  48472. 'Ǘ' => 'ǘ',
  48473. 'Ç™' => 'Çš',
  48474. 'Ǜ' => 'ǜ',
  48475. 'Çž' => 'ÇŸ',
  48476. 'Ç ' => 'Ç¡',
  48477. 'Ç¢' => 'Ç£',
  48478. 'Ǥ' => 'ǥ',
  48479. 'Ǧ' => 'ǧ',
  48480. 'Ǩ' => 'ǩ',
  48481. 'Ǫ' => 'ǫ',
  48482. 'Ǭ' => 'ǭ',
  48483. 'Ǯ' => 'ǯ',
  48484. 'DZ' => 'dz',
  48485. 'Dz' => 'dz',
  48486. 'Ǵ' => 'ǵ',
  48487. 'Ƕ' => 'ƕ',
  48488. 'Ç·' => 'Æ¿',
  48489. 'Ǹ' => 'ǹ',
  48490. 'Ǻ' => 'ǻ',
  48491. 'Ǽ' => 'ǽ',
  48492. 'Ǿ' => 'ǿ',
  48493. 'Ȁ' => '�',
  48494. 'Ȃ' => 'ȃ',
  48495. 'È„' => 'È…',
  48496. 'Ȇ' => 'ȇ',
  48497. 'Ȉ' => 'ȉ',
  48498. 'ÈŠ' => 'È‹',
  48499. 'Ȍ' => '�',
  48500. 'Ȏ' => '�',
  48501. '�' => 'ȑ',
  48502. 'È’' => 'È“',
  48503. 'È”' => 'È•',
  48504. 'È–' => 'È—',
  48505. 'Ș' => 'ș',
  48506. 'Èš' => 'È›',
  48507. 'Ȝ' => '�',
  48508. 'Èž' => 'ÈŸ',
  48509. 'È ' => 'Æž',
  48510. 'È¢' => 'È£',
  48511. 'Ȥ' => 'ȥ',
  48512. 'Ȧ' => 'ȧ',
  48513. 'Ȩ' => 'ȩ',
  48514. 'Ȫ' => 'ȫ',
  48515. 'Ȭ' => 'ȭ',
  48516. 'Ȯ' => 'ȯ',
  48517. 'Ȱ' => 'ȱ',
  48518. 'Ȳ' => 'ȳ',
  48519. 'Ⱥ' => 'ⱥ',
  48520. 'Ȼ' => 'ȼ',
  48521. 'Ƚ' => 'ƚ',
  48522. 'Ⱦ' => 'ⱦ',
  48523. '�' => 'ɂ',
  48524. 'Ƀ' => 'ƀ',
  48525. 'Ʉ' => 'ʉ',
  48526. 'Ʌ' => 'ʌ',
  48527. 'Ɇ' => 'ɇ',
  48528. 'Ɉ' => 'ɉ',
  48529. 'ÉŠ' => 'É‹',
  48530. 'Ɍ' => '�',
  48531. 'Ɏ' => '�',
  48532. 'Ͱ' => 'ͱ',
  48533. 'Ͳ' => 'ͳ',
  48534. 'Ͷ' => 'ͷ',
  48535. 'Ϳ' => 'ϳ',
  48536. 'Ά' => 'ά',
  48537. 'Έ' => 'έ',
  48538. 'Ή' => 'ή',
  48539. 'Ί' => 'ί',
  48540. 'Ό' => 'ό',
  48541. 'Ύ' => '�',
  48542. '�' => 'ώ',
  48543. 'Α' => 'α',
  48544. 'Β' => 'β',
  48545. 'Γ' => 'γ',
  48546. 'Δ' => 'δ',
  48547. 'Ε' => 'ε',
  48548. 'Ζ' => 'ζ',
  48549. 'Η' => 'η',
  48550. 'Θ' => 'θ',
  48551. 'Ι' => 'ι',
  48552. 'Κ' => 'κ',
  48553. 'Λ' => 'λ',
  48554. 'Μ' => 'μ',
  48555. '�' => 'ν',
  48556. 'Ξ' => 'ξ',
  48557. 'Ο' => 'ο',
  48558. 'Π' => 'π',
  48559. 'Ρ' => '�',
  48560. 'Σ' => 'σ',
  48561. 'Τ' => 'τ',
  48562. 'Î¥' => 'Ï…',
  48563. 'Φ' => 'φ',
  48564. 'Χ' => 'χ',
  48565. 'Ψ' => 'ψ',
  48566. 'Ω' => 'ω',
  48567. 'Ϊ' => 'ϊ',
  48568. 'Ϋ' => 'ϋ',
  48569. '�' => 'ϗ',
  48570. 'Ϙ' => 'ϙ',
  48571. 'Ïš' => 'Ï›',
  48572. 'Ϝ' => '�',
  48573. 'Ïž' => 'ÏŸ',
  48574. 'Ï ' => 'Ï¡',
  48575. 'Ï¢' => 'Ï£',
  48576. 'Ϥ' => 'ϥ',
  48577. 'Ϧ' => 'ϧ',
  48578. 'Ϩ' => 'ϩ',
  48579. 'Ϫ' => 'ϫ',
  48580. 'Ϭ' => 'ϭ',
  48581. 'Ϯ' => 'ϯ',
  48582. 'ϴ' => 'θ',
  48583. 'Ϸ' => 'ϸ',
  48584. 'Ϲ' => 'ϲ',
  48585. 'Ϻ' => 'ϻ',
  48586. 'Ͻ' => 'ͻ',
  48587. 'Ͼ' => 'ͼ',
  48588. 'Ͽ' => 'ͽ',
  48589. 'Ѐ' => '�',
  48590. '�' => 'ё',
  48591. 'Ђ' => 'ђ',
  48592. 'Ѓ' => 'ѓ',
  48593. 'Є' => 'є',
  48594. 'Ð…' => 'Ñ•',
  48595. 'І' => 'і',
  48596. 'Ї' => 'ї',
  48597. 'Ј' => 'ј',
  48598. 'Љ' => 'љ',
  48599. 'Њ' => 'њ',
  48600. 'Ћ' => 'ћ',
  48601. 'Ќ' => 'ќ',
  48602. '�' => '�',
  48603. 'ÐŽ' => 'Ñž',
  48604. '�' => 'џ',
  48605. '�' => 'а',
  48606. 'Б' => 'б',
  48607. 'В' => 'в',
  48608. 'Г' => 'г',
  48609. 'Д' => 'д',
  48610. 'Е' => 'е',
  48611. 'Ж' => 'ж',
  48612. 'З' => 'з',
  48613. 'И' => 'и',
  48614. 'Й' => 'й',
  48615. 'К' => 'к',
  48616. 'Л' => 'л',
  48617. 'М' => 'м',
  48618. '�' => 'н',
  48619. 'О' => 'о',
  48620. 'П' => 'п',
  48621. 'Р' => 'р',
  48622. 'С' => '�',
  48623. 'Т' => 'т',
  48624. 'У' => 'у',
  48625. 'Ф' => 'ф',
  48626. 'Ð¥' => 'Ñ…',
  48627. 'Ц' => 'ц',
  48628. 'Ч' => 'ч',
  48629. 'Ш' => 'ш',
  48630. 'Щ' => 'щ',
  48631. 'Ъ' => 'ъ',
  48632. 'Ы' => 'ы',
  48633. 'Ь' => 'ь',
  48634. 'Э' => '�',
  48635. 'Ю' => 'ю',
  48636. 'Я' => '�',
  48637. 'Ñ ' => 'Ñ¡',
  48638. 'Ñ¢' => 'Ñ£',
  48639. 'Ѥ' => 'ѥ',
  48640. 'Ѧ' => 'ѧ',
  48641. 'Ѩ' => 'ѩ',
  48642. 'Ѫ' => 'ѫ',
  48643. 'Ѭ' => 'ѭ',
  48644. 'Ѯ' => 'ѯ',
  48645. 'Ѱ' => 'ѱ',
  48646. 'Ѳ' => 'ѳ',
  48647. 'Ѵ' => 'ѵ',
  48648. 'Ѷ' => 'ѷ',
  48649. 'Ѹ' => 'ѹ',
  48650. 'Ѻ' => 'ѻ',
  48651. 'Ѽ' => 'ѽ',
  48652. 'Ѿ' => 'ѿ',
  48653. 'Ò€' => 'Ò�',
  48654. 'ÒŠ' => 'Ò‹',
  48655. 'Ҍ' => '�',
  48656. 'ÒŽ' => 'Ò�',
  48657. 'Ò�' => 'Ò‘',
  48658. 'Ò’' => 'Ò“',
  48659. 'Ò”' => 'Ò•',
  48660. 'Ò–' => 'Ò—',
  48661. 'Ò˜' => 'Ò™',
  48662. 'Òš' => 'Ò›',
  48663. 'Ҝ' => '�',
  48664. 'Òž' => 'ÒŸ',
  48665. 'Ò ' => 'Ò¡',
  48666. 'Ò¢' => 'Ò£',
  48667. 'Ò¤' => 'Ò¥',
  48668. 'Ò¦' => 'Ò§',
  48669. 'Ò¨' => 'Ò©',
  48670. 'Òª' => 'Ò«',
  48671. 'Ò¬' => 'Ò­',
  48672. 'Ò®' => 'Ò¯',
  48673. 'Ò°' => 'Ò±',
  48674. 'Ò²' => 'Ò³',
  48675. 'Ò´' => 'Òµ',
  48676. 'Ò¶' => 'Ò·',
  48677. 'Ò¸' => 'Ò¹',
  48678. 'Òº' => 'Ò»',
  48679. 'Ò¼' => 'Ò½',
  48680. 'Ò¾' => 'Ò¿',
  48681. 'Ó€' => 'Ó�',
  48682. 'Ó�' => 'Ó‚',
  48683. 'Óƒ' => 'Ó„',
  48684. 'Ó…' => 'Ó†',
  48685. 'Ó‡' => 'Óˆ',
  48686. 'Ó‰' => 'ÓŠ',
  48687. 'Ӌ' => 'ӌ',
  48688. 'Ó�' => 'ÓŽ',
  48689. 'Ó�' => 'Ó‘',
  48690. 'Ó’' => 'Ó“',
  48691. 'Ó”' => 'Ó•',
  48692. 'Ó–' => 'Ó—',
  48693. 'Ó˜' => 'Ó™',
  48694. 'Óš' => 'Ó›',
  48695. 'Ӝ' => '�',
  48696. 'Óž' => 'ÓŸ',
  48697. 'Ó ' => 'Ó¡',
  48698. 'Ó¢' => 'Ó£',
  48699. 'Ó¤' => 'Ó¥',
  48700. 'Ó¦' => 'Ó§',
  48701. 'Ó¨' => 'Ó©',
  48702. 'Óª' => 'Ó«',
  48703. 'Ó¬' => 'Ó­',
  48704. 'Ó®' => 'Ó¯',
  48705. 'Ó°' => 'Ó±',
  48706. 'Ó²' => 'Ó³',
  48707. 'Ó´' => 'Óµ',
  48708. 'Ó¶' => 'Ó·',
  48709. 'Ó¸' => 'Ó¹',
  48710. 'Óº' => 'Ó»',
  48711. 'Ó¼' => 'Ó½',
  48712. 'Ó¾' => 'Ó¿',
  48713. 'Ô€' => 'Ô�',
  48714. 'Ô‚' => 'Ôƒ',
  48715. 'Ô„' => 'Ô…',
  48716. 'Ô†' => 'Ô‡',
  48717. 'Ôˆ' => 'Ô‰',
  48718. 'ÔŠ' => 'Ô‹',
  48719. 'Ԍ' => '�',
  48720. 'ÔŽ' => 'Ô�',
  48721. 'Ô�' => 'Ô‘',
  48722. 'Ô’' => 'Ô“',
  48723. 'Ô”' => 'Ô•',
  48724. 'Ô–' => 'Ô—',
  48725. 'Ô˜' => 'Ô™',
  48726. 'Ôš' => 'Ô›',
  48727. 'Ԝ' => '�',
  48728. 'Ôž' => 'ÔŸ',
  48729. 'Ô ' => 'Ô¡',
  48730. 'Ô¢' => 'Ô£',
  48731. 'Ô¤' => 'Ô¥',
  48732. 'Ô¦' => 'Ô§',
  48733. 'Ô¨' => 'Ô©',
  48734. 'Ôª' => 'Ô«',
  48735. 'Ô¬' => 'Ô­',
  48736. 'Ô®' => 'Ô¯',
  48737. 'Ô±' => 'Õ¡',
  48738. 'Ô²' => 'Õ¢',
  48739. 'Ô³' => 'Õ£',
  48740. 'Ô´' => 'Õ¤',
  48741. 'Ôµ' => 'Õ¥',
  48742. 'Ô¶' => 'Õ¦',
  48743. 'Ô·' => 'Õ§',
  48744. 'Ô¸' => 'Õ¨',
  48745. 'Ô¹' => 'Õ©',
  48746. 'Ôº' => 'Õª',
  48747. 'Ô»' => 'Õ«',
  48748. 'Ô¼' => 'Õ¬',
  48749. 'Ô½' => 'Õ­',
  48750. 'Ô¾' => 'Õ®',
  48751. 'Ô¿' => 'Õ¯',
  48752. 'Õ€' => 'Õ°',
  48753. 'Õ�' => 'Õ±',
  48754. 'Õ‚' => 'Õ²',
  48755. 'Õƒ' => 'Õ³',
  48756. 'Õ„' => 'Õ´',
  48757. 'Õ…' => 'Õµ',
  48758. 'Õ†' => 'Õ¶',
  48759. 'Õ‡' => 'Õ·',
  48760. 'Õˆ' => 'Õ¸',
  48761. 'Õ‰' => 'Õ¹',
  48762. 'ÕŠ' => 'Õº',
  48763. 'Õ‹' => 'Õ»',
  48764. 'Ռ' => 'ռ',
  48765. 'Õ�' => 'Õ½',
  48766. 'ÕŽ' => 'Õ¾',
  48767. 'Õ�' => 'Õ¿',
  48768. 'Õ�' => 'Ö€',
  48769. 'Õ‘' => 'Ö�',
  48770. 'Õ’' => 'Ö‚',
  48771. 'Õ“' => 'Öƒ',
  48772. 'Õ”' => 'Ö„',
  48773. 'Õ•' => 'Ö…',
  48774. 'Õ–' => 'Ö†',
  48775. 'á‚ ' => 'â´€',
  48776. 'á‚¡' => 'â´�',
  48777. 'á‚¢' => 'â´‚',
  48778. 'á‚£' => 'â´ƒ',
  48779. 'Ⴄ' => 'ⴄ',
  48780. 'á‚¥' => 'â´…',
  48781. 'Ⴆ' => 'ⴆ',
  48782. 'á‚§' => 'â´‡',
  48783. 'Ⴈ' => 'ⴈ',
  48784. 'á‚©' => 'â´‰',
  48785. 'Ⴊ' => 'ⴊ',
  48786. 'á‚«' => 'â´‹',
  48787. 'Ⴌ' => 'ⴌ',
  48788. 'á‚­' => 'â´�',
  48789. 'á‚®' => 'â´Ž',
  48790. 'Ⴏ' => '�',
  48791. 'á‚°' => 'â´�',
  48792. 'Ⴑ' => 'ⴑ',
  48793. 'Ⴒ' => 'ⴒ',
  48794. 'Ⴓ' => 'ⴓ',
  48795. 'á‚´' => 'â´”',
  48796. 'Ⴕ' => 'ⴕ',
  48797. 'á‚¶' => 'â´–',
  48798. 'á‚·' => 'â´—',
  48799. 'Ⴘ' => 'ⴘ',
  48800. 'Ⴙ' => 'ⴙ',
  48801. 'Ⴚ' => 'ⴚ',
  48802. 'á‚»' => 'â´›',
  48803. 'Ⴜ' => 'ⴜ',
  48804. 'Ⴝ' => '�',
  48805. 'Ⴞ' => 'ⴞ',
  48806. 'á‚¿' => 'â´Ÿ',
  48807. 'Ⴠ' => 'ⴠ',
  48808. '�' => 'ⴡ',
  48809. 'Ⴢ' => 'ⴢ',
  48810. 'Ⴣ' => 'ⴣ',
  48811. 'Ⴤ' => 'ⴤ',
  48812. 'Ⴥ' => 'ⴥ',
  48813. 'Ⴧ' => 'ⴧ',
  48814. '�' => 'ⴭ',
  48815. 'Ꭰ' => 'ꭰ',
  48816. 'Ꭱ' => 'ꭱ',
  48817. 'Ꭲ' => 'ꭲ',
  48818. 'Ꭳ' => 'ꭳ',
  48819. 'Ꭴ' => 'ꭴ',
  48820. 'Ꭵ' => 'ꭵ',
  48821. 'Ꭶ' => 'ꭶ',
  48822. 'Ꭷ' => 'ꭷ',
  48823. 'Ꭸ' => 'ꭸ',
  48824. 'Ꭹ' => 'ꭹ',
  48825. 'Ꭺ' => 'ꭺ',
  48826. 'Ꭻ' => 'ꭻ',
  48827. 'Ꭼ' => 'ꭼ',
  48828. 'Ꭽ' => 'ꭽ',
  48829. 'Ꭾ' => 'ꭾ',
  48830. 'Ꭿ' => 'ꭿ',
  48831. 'Ꮀ' => 'ꮀ',
  48832. 'Ꮁ' => '�',
  48833. 'Ꮂ' => 'ꮂ',
  48834. 'Ꮃ' => 'ꮃ',
  48835. 'Ꮄ' => 'ꮄ',
  48836. 'Ꮅ' => 'ꮅ',
  48837. 'Ꮆ' => 'ꮆ',
  48838. 'Ꮇ' => 'ꮇ',
  48839. 'Ꮈ' => 'ꮈ',
  48840. 'Ꮉ' => 'ꮉ',
  48841. 'Ꮊ' => 'ꮊ',
  48842. 'Ꮋ' => 'ꮋ',
  48843. 'Ꮌ' => 'ꮌ',
  48844. 'Ꮍ' => '�',
  48845. 'Ꮎ' => 'ꮎ',
  48846. 'Ꮏ' => '�',
  48847. '�' => '�',
  48848. '�' => 'ꮑ',
  48849. '�' => 'ꮒ',
  48850. '�' => 'ꮓ',
  48851. '�' => 'ꮔ',
  48852. '�' => 'ꮕ',
  48853. '�' => 'ꮖ',
  48854. '�' => 'ꮗ',
  48855. '�' => 'ꮘ',
  48856. '�' => 'ꮙ',
  48857. '�' => 'ꮚ',
  48858. '�' => 'ꮛ',
  48859. '�' => 'ꮜ',
  48860. '�' => '�',
  48861. '�' => 'ꮞ',
  48862. '�' => 'ꮟ',
  48863. '�' => 'ꮠ',
  48864. '�' => 'ꮡ',
  48865. '�' => 'ꮢ',
  48866. '�' => 'ꮣ',
  48867. '�' => 'ꮤ',
  48868. '�' => 'ꮥ',
  48869. '�' => 'ꮦ',
  48870. '�' => 'ꮧ',
  48871. '�' => 'ꮨ',
  48872. '�' => 'ꮩ',
  48873. '�' => 'ꮪ',
  48874. '�' => 'ꮫ',
  48875. '�' => 'ꮬ',
  48876. '�' => 'ꮭ',
  48877. '�' => 'ꮮ',
  48878. '�' => 'ꮯ',
  48879. '�' => 'ꮰ',
  48880. '�' => 'ꮱ',
  48881. '�' => 'ꮲ',
  48882. '�' => 'ꮳ',
  48883. '�' => 'ꮴ',
  48884. '�' => 'ꮵ',
  48885. '�' => 'ꮶ',
  48886. '�' => 'ꮷ',
  48887. '�' => 'ꮸ',
  48888. '�' => 'ꮹ',
  48889. '�' => 'ꮺ',
  48890. '�' => 'ꮻ',
  48891. '�' => 'ꮼ',
  48892. '�' => 'ꮽ',
  48893. '�' => 'ꮾ',
  48894. '�' => 'ꮿ',
  48895. '�' => '�',
  48896. '�' => '�',
  48897. '�' => '�',
  48898. '�' => '�',
  48899. '�' => '�',
  48900. '�' => '�',
  48901. '�' => '�',
  48902. 'Ბ' => 'ბ',
  48903. 'Გ' => 'გ',
  48904. 'Დ' => 'დ',
  48905. 'Ე' => 'ე',
  48906. 'Ვ' => 'ვ',
  48907. 'Ზ' => 'ზ',
  48908. 'Თ' => 'თ',
  48909. 'Ი' => 'ი',
  48910. 'Კ' => 'კ',
  48911. 'Ლ' => 'ლ',
  48912. 'Მ' => 'მ',
  48913. 'Ნ' => 'ნ',
  48914. '�' => '�',
  48915. 'Პ' => 'პ',
  48916. 'Ჟ' => 'ჟ',
  48917. 'Რ' => 'რ',
  48918. 'Ს' => 'ს',
  48919. 'Ტ' => 'ტ',
  48920. 'Უ' => 'უ',
  48921. 'Ფ' => 'ფ',
  48922. 'Ქ' => 'ქ',
  48923. 'Ღ' => 'ღ',
  48924. 'Ყ' => 'ყ',
  48925. 'Შ' => 'შ',
  48926. 'Ჩ' => 'ჩ',
  48927. 'Ც' => 'ც',
  48928. 'Ძ' => 'ძ',
  48929. 'Წ' => 'წ',
  48930. 'Ჭ' => 'ჭ',
  48931. 'Ხ' => 'ხ',
  48932. 'Ჯ' => 'ჯ',
  48933. 'Ჰ' => 'ჰ',
  48934. 'Ჱ' => 'ჱ',
  48935. 'Ჲ' => 'ჲ',
  48936. 'Ჳ' => 'ჳ',
  48937. 'Ჴ' => 'ჴ',
  48938. 'Ჵ' => 'ჵ',
  48939. 'Ჶ' => 'ჶ',
  48940. 'Ჷ' => 'ჷ',
  48941. 'Ჸ' => 'ჸ',
  48942. 'Ჹ' => 'ჹ',
  48943. 'Ჺ' => 'ჺ',
  48944. 'Ჽ' => 'ჽ',
  48945. 'Ჾ' => 'ჾ',
  48946. 'Ჿ' => 'ჿ',
  48947. 'Ḁ' => '�',
  48948. 'Ḃ' => 'ḃ',
  48949. 'Ḅ' => 'ḅ',
  48950. 'Ḇ' => 'ḇ',
  48951. 'Ḉ' => 'ḉ',
  48952. 'Ḋ' => 'ḋ',
  48953. 'Ḍ' => '�',
  48954. 'Ḏ' => '�',
  48955. '�' => 'ḑ',
  48956. 'Ḓ' => 'ḓ',
  48957. 'Ḕ' => 'ḕ',
  48958. 'Ḗ' => 'ḗ',
  48959. 'Ḙ' => 'ḙ',
  48960. 'Ḛ' => 'ḛ',
  48961. 'Ḝ' => '�',
  48962. 'Ḟ' => 'ḟ',
  48963. 'Ḡ' => 'ḡ',
  48964. 'Ḣ' => 'ḣ',
  48965. 'Ḥ' => 'ḥ',
  48966. 'Ḧ' => 'ḧ',
  48967. 'Ḩ' => 'ḩ',
  48968. 'Ḫ' => 'ḫ',
  48969. 'Ḭ' => 'ḭ',
  48970. 'Ḯ' => 'ḯ',
  48971. 'Ḱ' => 'ḱ',
  48972. 'Ḳ' => 'ḳ',
  48973. 'Ḵ' => 'ḵ',
  48974. 'Ḷ' => 'ḷ',
  48975. 'Ḹ' => 'ḹ',
  48976. 'Ḻ' => 'ḻ',
  48977. 'Ḽ' => 'ḽ',
  48978. 'Ḿ' => 'ḿ',
  48979. 'Ṁ' => '�',
  48980. 'Ṃ' => 'ṃ',
  48981. 'Ṅ' => 'ṅ',
  48982. 'Ṇ' => 'ṇ',
  48983. 'Ṉ' => 'ṉ',
  48984. 'Ṋ' => 'ṋ',
  48985. 'Ṍ' => '�',
  48986. 'Ṏ' => '�',
  48987. '�' => 'ṑ',
  48988. 'Ṓ' => 'ṓ',
  48989. 'Ṕ' => 'ṕ',
  48990. 'á¹–' => 'á¹—',
  48991. 'Ṙ' => 'ṙ',
  48992. 'Ṛ' => 'ṛ',
  48993. 'Ṝ' => '�',
  48994. 'Ṟ' => 'ṟ',
  48995. 'Ṡ' => 'ṡ',
  48996. 'á¹¢' => 'á¹£',
  48997. 'Ṥ' => 'ṥ',
  48998. 'Ṧ' => 'ṧ',
  48999. 'Ṩ' => 'ṩ',
  49000. 'Ṫ' => 'ṫ',
  49001. 'Ṭ' => 'ṭ',
  49002. 'Ṯ' => 'ṯ',
  49003. 'á¹°' => 'á¹±',
  49004. 'á¹²' => 'á¹³',
  49005. 'á¹´' => 'á¹µ',
  49006. 'á¹¶' => 'á¹·',
  49007. 'Ṹ' => 'ṹ',
  49008. 'Ṻ' => 'ṻ',
  49009. 'á¹¼' => 'á¹½',
  49010. 'Ṿ' => 'ṿ',
  49011. 'Ẁ' => '�',
  49012. 'Ẃ' => 'ẃ',
  49013. 'Ẅ' => 'ẅ',
  49014. 'Ẇ' => 'ẇ',
  49015. 'Ẉ' => 'ẉ',
  49016. 'Ẋ' => 'ẋ',
  49017. 'Ẍ' => '�',
  49018. 'Ẏ' => '�',
  49019. '�' => 'ẑ',
  49020. 'Ẓ' => 'ẓ',
  49021. 'Ẕ' => 'ẕ',
  49022. 'ẞ' => 'ß',
  49023. 'Ạ' => 'ạ',
  49024. 'Ả' => 'ả',
  49025. 'Ấ' => 'ấ',
  49026. 'Ầ' => 'ầ',
  49027. 'Ẩ' => 'ẩ',
  49028. 'Ẫ' => 'ẫ',
  49029. 'Ậ' => 'ậ',
  49030. 'Ắ' => 'ắ',
  49031. 'Ằ' => 'ằ',
  49032. 'Ẳ' => 'ẳ',
  49033. 'Ẵ' => 'ẵ',
  49034. 'Ặ' => 'ặ',
  49035. 'Ẹ' => 'ẹ',
  49036. 'Ẻ' => 'ẻ',
  49037. 'Ẽ' => 'ẽ',
  49038. 'Ế' => 'ế',
  49039. 'Ề' => '�',
  49040. 'Ể' => 'ể',
  49041. 'Ễ' => 'ễ',
  49042. 'Ệ' => 'ệ',
  49043. 'Ỉ' => 'ỉ',
  49044. 'Ị' => 'ị',
  49045. 'Ọ' => '�',
  49046. 'Ỏ' => '�',
  49047. '�' => 'ố',
  49048. 'Ồ' => 'ồ',
  49049. 'Ổ' => 'ổ',
  49050. 'á»–' => 'á»—',
  49051. 'Ộ' => 'ộ',
  49052. 'Ớ' => 'ớ',
  49053. 'Ờ' => '�',
  49054. 'Ở' => 'ở',
  49055. 'Ỡ' => 'ỡ',
  49056. 'Ợ' => 'ợ',
  49057. 'Ụ' => 'ụ',
  49058. 'Ủ' => 'ủ',
  49059. 'Ứ' => 'ứ',
  49060. 'Ừ' => 'ừ',
  49061. 'Ử' => 'ử',
  49062. 'Ữ' => 'ữ',
  49063. 'á»°' => 'á»±',
  49064. 'Ỳ' => 'ỳ',
  49065. 'Ỵ' => 'ỵ',
  49066. 'á»¶' => 'á»·',
  49067. 'Ỹ' => 'ỹ',
  49068. 'Ỻ' => 'ỻ',
  49069. 'Ỽ' => 'ỽ',
  49070. 'Ỿ' => 'ỿ',
  49071. 'Ἀ' => 'ἀ',
  49072. 'Ἁ' => '�',
  49073. 'Ἂ' => 'ἂ',
  49074. 'Ἃ' => 'ἃ',
  49075. 'Ἄ' => 'ἄ',
  49076. '�' => 'ἅ',
  49077. 'Ἆ' => 'ἆ',
  49078. '�' => 'ἇ',
  49079. 'Ἐ' => '�',
  49080. 'Ἑ' => 'ἑ',
  49081. 'Ἒ' => 'ἒ',
  49082. 'Ἓ' => 'ἓ',
  49083. 'Ἔ' => 'ἔ',
  49084. '�' => 'ἕ',
  49085. 'Ἠ' => 'ἠ',
  49086. 'Ἡ' => 'ἡ',
  49087. 'Ἢ' => 'ἢ',
  49088. 'Ἣ' => 'ἣ',
  49089. 'Ἤ' => 'ἤ',
  49090. 'á¼­' => 'á¼¥',
  49091. 'Ἦ' => 'ἦ',
  49092. 'Ἧ' => 'ἧ',
  49093. 'Ἰ' => 'ἰ',
  49094. 'á¼¹' => 'á¼±',
  49095. 'Ἲ' => 'ἲ',
  49096. 'á¼»' => 'á¼³',
  49097. 'á¼¼' => 'á¼´',
  49098. 'á¼½' => 'á¼µ',
  49099. 'á¼¾' => 'á¼¶',
  49100. 'Ἷ' => 'ἷ',
  49101. 'Ὀ' => 'ὀ',
  49102. 'Ὁ' => '�',
  49103. 'Ὂ' => 'ὂ',
  49104. 'Ὃ' => 'ὃ',
  49105. 'Ὄ' => 'ὄ',
  49106. '�' => 'ὅ',
  49107. 'Ὑ' => 'ὑ',
  49108. 'Ὓ' => 'ὓ',
  49109. '�' => 'ὕ',
  49110. 'Ὗ' => 'ὗ',
  49111. 'Ὠ' => 'ὠ',
  49112. 'Ὡ' => 'ὡ',
  49113. 'Ὢ' => 'ὢ',
  49114. 'Ὣ' => 'ὣ',
  49115. 'Ὤ' => 'ὤ',
  49116. 'á½­' => 'á½¥',
  49117. 'Ὦ' => 'ὦ',
  49118. 'Ὧ' => 'ὧ',
  49119. 'ᾈ' => 'ᾀ',
  49120. 'ᾉ' => '�',
  49121. 'ᾊ' => 'ᾂ',
  49122. 'ᾋ' => 'ᾃ',
  49123. 'ᾌ' => 'ᾄ',
  49124. '�' => 'ᾅ',
  49125. 'ᾎ' => 'ᾆ',
  49126. '�' => 'ᾇ',
  49127. 'ᾘ' => '�',
  49128. 'ᾙ' => 'ᾑ',
  49129. 'ᾚ' => 'ᾒ',
  49130. 'ᾛ' => 'ᾓ',
  49131. 'ᾜ' => 'ᾔ',
  49132. '�' => 'ᾕ',
  49133. 'ᾞ' => 'ᾖ',
  49134. 'ᾟ' => 'ᾗ',
  49135. 'ᾨ' => 'ᾠ',
  49136. 'ᾩ' => 'ᾡ',
  49137. 'ᾪ' => 'ᾢ',
  49138. 'ᾫ' => 'ᾣ',
  49139. 'ᾬ' => 'ᾤ',
  49140. 'á¾­' => 'á¾¥',
  49141. 'ᾮ' => 'ᾦ',
  49142. 'ᾯ' => 'ᾧ',
  49143. 'Ᾰ' => 'ᾰ',
  49144. 'á¾¹' => 'á¾±',
  49145. 'Ὰ' => 'ὰ',
  49146. 'á¾»' => 'á½±',
  49147. 'á¾¼' => 'á¾³',
  49148. 'Ὲ' => 'ὲ',
  49149. 'Έ' => 'έ',
  49150. 'Ὴ' => 'ὴ',
  49151. 'á¿‹' => 'á½µ',
  49152. 'ῌ' => 'ῃ',
  49153. 'Ῐ' => '�',
  49154. 'á¿™' => 'á¿‘',
  49155. 'Ὶ' => 'ὶ',
  49156. 'á¿›' => 'á½·',
  49157. 'Ῠ' => 'ῠ',
  49158. 'á¿©' => 'á¿¡',
  49159. 'Ὺ' => 'ὺ',
  49160. 'á¿«' => 'á½»',
  49161. 'Ῥ' => 'ῥ',
  49162. 'Ὸ' => 'ὸ',
  49163. 'Ό' => 'ό',
  49164. 'Ὼ' => 'ὼ',
  49165. 'á¿»' => 'á½½',
  49166. 'ῼ' => 'ῳ',
  49167. 'Ω' => 'ω',
  49168. 'K' => 'k',
  49169. 'â„«' => 'Ã¥',
  49170. 'Ⅎ' => 'ⅎ',
  49171. 'â… ' => 'â…°',
  49172. 'â…¡' => 'â…±',
  49173. 'â…¢' => 'â…²',
  49174. 'â…£' => 'â…³',
  49175. 'â…¤' => 'â…´',
  49176. 'â…¥' => 'â…µ',
  49177. 'â…¦' => 'â…¶',
  49178. 'â…§' => 'â…·',
  49179. 'â…¨' => 'â…¸',
  49180. 'â…©' => 'â…¹',
  49181. 'â…ª' => 'â…º',
  49182. 'â…«' => 'â…»',
  49183. 'â…¬' => 'â…¼',
  49184. 'â…­' => 'â…½',
  49185. 'â…®' => 'â…¾',
  49186. 'â…¯' => 'â…¿',
  49187. 'Ↄ' => 'ↄ',
  49188. 'Ⓐ' => '�',
  49189. 'â’·' => 'â“‘',
  49190. 'â’¸' => 'â“’',
  49191. 'â’¹' => 'â““',
  49192. 'â’º' => 'â“”',
  49193. 'â’»' => 'â“•',
  49194. 'â’¼' => 'â“–',
  49195. 'â’½' => 'â“—',
  49196. 'Ⓘ' => 'ⓘ',
  49197. 'â’¿' => 'â“™',
  49198. 'Ⓚ' => 'ⓚ',
  49199. '�' => 'ⓛ',
  49200. 'Ⓜ' => 'ⓜ',
  49201. 'Ⓝ' => '�',
  49202. 'Ⓞ' => 'ⓞ',
  49203. 'Ⓟ' => 'ⓟ',
  49204. 'Ⓠ' => 'ⓠ',
  49205. 'Ⓡ' => 'ⓡ',
  49206. 'Ⓢ' => 'ⓢ',
  49207. 'Ⓣ' => 'ⓣ',
  49208. 'Ⓤ' => 'ⓤ',
  49209. 'â“‹' => 'â“¥',
  49210. 'Ⓦ' => 'ⓦ',
  49211. '�' => 'ⓧ',
  49212. 'Ⓨ' => 'ⓨ',
  49213. '�' => 'ⓩ',
  49214. 'â°€' => 'â°°',
  49215. 'â°�' => 'â°±',
  49216. 'â°‚' => 'â°²',
  49217. 'â°ƒ' => 'â°³',
  49218. 'â°„' => 'â°´',
  49219. 'â°…' => 'â°µ',
  49220. 'â°†' => 'â°¶',
  49221. 'â°‡' => 'â°·',
  49222. 'â°ˆ' => 'â°¸',
  49223. 'â°‰' => 'â°¹',
  49224. 'â°Š' => 'â°º',
  49225. 'â°‹' => 'â°»',
  49226. 'Ⰼ' => 'ⰼ',
  49227. 'â°�' => 'â°½',
  49228. 'â°Ž' => 'â°¾',
  49229. 'â°�' => 'â°¿',
  49230. 'â°�' => 'â±€',
  49231. 'Ⱁ' => '�',
  49232. 'Ⱂ' => 'ⱂ',
  49233. 'Ⱃ' => 'ⱃ',
  49234. 'Ⱄ' => 'ⱄ',
  49235. 'â°•' => 'â±…',
  49236. 'Ⱆ' => 'ⱆ',
  49237. 'Ⱇ' => 'ⱇ',
  49238. 'Ⱈ' => 'ⱈ',
  49239. 'Ⱉ' => 'ⱉ',
  49240. 'Ⱊ' => 'ⱊ',
  49241. 'Ⱋ' => 'ⱋ',
  49242. 'Ⱌ' => 'ⱌ',
  49243. '�' => '�',
  49244. 'Ⱎ' => 'ⱎ',
  49245. 'Ⱏ' => '�',
  49246. 'Ⱐ' => '�',
  49247. 'Ⱑ' => 'ⱑ',
  49248. 'â°¢' => 'â±’',
  49249. 'Ⱓ' => 'ⱓ',
  49250. 'â°¤' => 'â±”',
  49251. 'Ⱕ' => 'ⱕ',
  49252. 'â°¦' => 'â±–',
  49253. 'â°§' => 'â±—',
  49254. 'Ⱘ' => 'ⱘ',
  49255. 'â°©' => 'â±™',
  49256. 'Ⱚ' => 'ⱚ',
  49257. 'â°«' => 'â±›',
  49258. 'Ⱜ' => 'ⱜ',
  49259. 'Ⱝ' => '�',
  49260. 'Ⱞ' => 'ⱞ',
  49261. 'Ⱡ' => 'ⱡ',
  49262. 'â±¢' => 'É«',
  49263. 'â±£' => 'áµ½',
  49264. 'Ɽ' => 'ɽ',
  49265. 'Ⱨ' => 'ⱨ',
  49266. 'Ⱪ' => 'ⱪ',
  49267. 'Ⱬ' => 'ⱬ',
  49268. 'â±­' => 'É‘',
  49269. 'Ɱ' => 'ɱ',
  49270. 'Ɐ' => '�',
  49271. 'â±°' => 'É’',
  49272. 'â±²' => 'â±³',
  49273. 'â±µ' => 'â±¶',
  49274. 'â±¾' => 'È¿',
  49275. 'Ɀ' => 'ɀ',
  49276. 'Ⲁ' => '�',
  49277. 'Ⲃ' => 'ⲃ',
  49278. 'Ⲅ' => 'ⲅ',
  49279. 'Ⲇ' => 'ⲇ',
  49280. 'Ⲉ' => 'ⲉ',
  49281. 'Ⲋ' => 'ⲋ',
  49282. 'Ⲍ' => '�',
  49283. 'Ⲏ' => '�',
  49284. '�' => 'ⲑ',
  49285. 'Ⲓ' => 'ⲓ',
  49286. 'Ⲕ' => 'ⲕ',
  49287. 'â²–' => 'â²—',
  49288. 'Ⲙ' => 'ⲙ',
  49289. 'Ⲛ' => 'ⲛ',
  49290. 'Ⲝ' => '�',
  49291. 'Ⲟ' => 'ⲟ',
  49292. 'Ⲡ' => 'ⲡ',
  49293. 'â²¢' => 'â²£',
  49294. 'Ⲥ' => 'ⲥ',
  49295. 'Ⲧ' => 'ⲧ',
  49296. 'Ⲩ' => 'ⲩ',
  49297. 'Ⲫ' => 'ⲫ',
  49298. 'Ⲭ' => 'ⲭ',
  49299. 'Ⲯ' => 'ⲯ',
  49300. 'â²°' => 'â²±',
  49301. 'â²²' => 'â²³',
  49302. 'â²´' => 'â²µ',
  49303. 'â²¶' => 'â²·',
  49304. 'Ⲹ' => 'ⲹ',
  49305. 'Ⲻ' => 'ⲻ',
  49306. 'â²¼' => 'â²½',
  49307. 'Ⲿ' => 'ⲿ',
  49308. 'Ⳁ' => '�',
  49309. 'Ⳃ' => 'ⳃ',
  49310. 'Ⳅ' => 'ⳅ',
  49311. 'Ⳇ' => 'ⳇ',
  49312. 'Ⳉ' => 'ⳉ',
  49313. 'Ⳋ' => 'ⳋ',
  49314. 'Ⳍ' => '�',
  49315. 'Ⳏ' => '�',
  49316. '�' => 'ⳑ',
  49317. 'Ⳓ' => 'ⳓ',
  49318. 'Ⳕ' => 'ⳕ',
  49319. 'â³–' => 'â³—',
  49320. 'Ⳙ' => 'ⳙ',
  49321. 'Ⳛ' => 'ⳛ',
  49322. 'Ⳝ' => '�',
  49323. 'Ⳟ' => 'ⳟ',
  49324. 'Ⳡ' => 'ⳡ',
  49325. 'â³¢' => 'â³£',
  49326. 'Ⳬ' => 'ⳬ',
  49327. 'â³­' => 'â³®',
  49328. 'â³²' => 'â³³',
  49329. 'Ꙁ' => '�',
  49330. 'Ꙃ' => 'ꙃ',
  49331. 'Ꙅ' => 'ꙅ',
  49332. 'Ꙇ' => 'ꙇ',
  49333. 'Ꙉ' => 'ꙉ',
  49334. 'Ꙋ' => 'ꙋ',
  49335. 'Ꙍ' => '�',
  49336. 'Ꙏ' => '�',
  49337. '�' => 'ꙑ',
  49338. 'Ꙓ' => 'ꙓ',
  49339. 'Ꙕ' => 'ꙕ',
  49340. 'ê™–' => 'ê™—',
  49341. 'Ꙙ' => 'ꙙ',
  49342. 'Ꙛ' => 'ꙛ',
  49343. 'Ꙝ' => '�',
  49344. 'Ꙟ' => 'ꙟ',
  49345. 'Ꙡ' => 'ꙡ',
  49346. 'Ꙣ' => 'ꙣ',
  49347. 'Ꙥ' => 'ꙥ',
  49348. 'Ꙧ' => 'ꙧ',
  49349. 'Ꙩ' => 'ꙩ',
  49350. 'Ꙫ' => 'ꙫ',
  49351. 'Ꙭ' => 'ꙭ',
  49352. 'Ꚁ' => '�',
  49353. 'Ꚃ' => 'ꚃ',
  49354. 'êš„' => 'êš…',
  49355. 'Ꚇ' => 'ꚇ',
  49356. 'Ꚉ' => 'ꚉ',
  49357. 'Ꚋ' => 'ꚋ',
  49358. 'Ꚍ' => '�',
  49359. 'Ꚏ' => '�',
  49360. '�' => 'ꚑ',
  49361. 'êš’' => 'êš“',
  49362. 'êš”' => 'êš•',
  49363. 'êš–' => 'êš—',
  49364. 'Ꚙ' => 'ꚙ',
  49365. 'êšš' => 'êš›',
  49366. 'Ꜣ' => 'ꜣ',
  49367. 'Ꜥ' => 'ꜥ',
  49368. 'Ꜧ' => 'ꜧ',
  49369. 'Ꜩ' => 'ꜩ',
  49370. 'Ꜫ' => 'ꜫ',
  49371. 'Ꜭ' => 'ꜭ',
  49372. 'Ꜯ' => 'ꜯ',
  49373. 'Ꜳ' => 'ꜳ',
  49374. 'Ꜵ' => 'ꜵ',
  49375. 'Ꜷ' => 'ꜷ',
  49376. 'Ꜹ' => 'ꜹ',
  49377. 'Ꜻ' => 'ꜻ',
  49378. 'Ꜽ' => 'ꜽ',
  49379. 'Ꜿ' => 'ꜿ',
  49380. '�' => '�',
  49381. '�' => '�',
  49382. '�' => '�',
  49383. '�' => '�',
  49384. '�' => '�',
  49385. '�' => '�',
  49386. '�' => '�',
  49387. '�' => '�',
  49388. '�' => '�',
  49389. '�' => '�',
  49390. '�' => '�',
  49391. '�' => '�',
  49392. '�' => '�',
  49393. '�' => '�',
  49394. '�' => '�',
  49395. '�' => '�',
  49396. '�' => '�',
  49397. '�' => '�',
  49398. '�' => '�',
  49399. '�' => '�',
  49400. '�' => '�',
  49401. '�' => '�',
  49402. '�' => '�',
  49403. '�' => '�',
  49404. '�' => '�',
  49405. '�' => '�',
  49406. '�' => 'ᵹ',
  49407. '�' => '�',
  49408. 'Ꞁ' => '�',
  49409. 'Ꞃ' => 'ꞃ',
  49410. 'êž„' => 'êž…',
  49411. 'Ꞇ' => 'ꞇ',
  49412. 'Ꞌ' => 'ꞌ',
  49413. '�' => 'ɥ',
  49414. '�' => 'ꞑ',
  49415. 'êž’' => 'êž“',
  49416. 'êž–' => 'êž—',
  49417. 'Ꞙ' => 'ꞙ',
  49418. 'êžš' => 'êž›',
  49419. 'Ꞝ' => '�',
  49420. 'Ꞟ' => 'ꞟ',
  49421. 'êž ' => 'êž¡',
  49422. 'Ꞣ' => 'ꞣ',
  49423. 'Ꞥ' => 'ꞥ',
  49424. 'Ꞧ' => 'ꞧ',
  49425. 'Ꞩ' => 'ꞩ',
  49426. 'Ɦ' => 'ɦ',
  49427. 'Ɜ' => 'ɜ',
  49428. 'Ɡ' => 'ɡ',
  49429. 'Ɬ' => 'ɬ',
  49430. 'Ɪ' => 'ɪ',
  49431. 'êž°' => 'Êž',
  49432. 'Ʇ' => 'ʇ',
  49433. 'Ʝ' => '�',
  49434. 'êž³' => 'ê­“',
  49435. 'êž´' => 'êžµ',
  49436. 'êž¶' => 'êž·',
  49437. 'Ꞹ' => 'ꞹ',
  49438. 'Ꞻ' => 'ꞻ',
  49439. 'êž¼' => 'êž½',
  49440. 'êž¾' => 'êž¿',
  49441. 'Ꟃ' => 'ꟃ',
  49442. 'Ꞔ' => 'ꞔ',
  49443. 'Ʂ' => 'ʂ',
  49444. 'Ᶎ' => 'ᶎ',
  49445. 'Ꟈ' => 'ꟈ',
  49446. 'Ꟊ' => 'ꟊ',
  49447. 'Ꟶ' => 'ꟶ',
  49448. 'A' => '�',
  49449. 'B' => 'b',
  49450. 'C' => 'c',
  49451. 'D' => 'd',
  49452. 'ï¼¥' => 'ï½…',
  49453. 'F' => 'f',
  49454. 'G' => 'g',
  49455. 'H' => 'h',
  49456. 'I' => 'i',
  49457. 'J' => 'j',
  49458. 'K' => 'k',
  49459. 'L' => 'l',
  49460. 'M' => '�',
  49461. 'N' => 'n',
  49462. 'O' => '�',
  49463. 'P' => '�',
  49464. 'Q' => 'q',
  49465. 'ï¼²' => 'ï½’',
  49466. 'S' => 's',
  49467. 'ï¼´' => 'ï½”',
  49468. 'U' => 'u',
  49469. 'ï¼¶' => 'ï½–',
  49470. 'ï¼·' => 'ï½—',
  49471. 'X' => 'x',
  49472. 'ï¼¹' => 'ï½™',
  49473. 'Z' => 'z',
  49474. '�' => '�',
  49475. '�' => '�',
  49476. '�' => '�',
  49477. '�' => '�',
  49478. '�' => '�',
  49479. '�' => '�',
  49480. '�' => '�',
  49481. '�' => '�',
  49482. '�' => '�',
  49483. '�' => '�',
  49484. '�' => '�',
  49485. '�' => '�',
  49486. '�' => '�',
  49487. '�' => '�',
  49488. '�' => '�',
  49489. '�' => '�',
  49490. '�' => '�',
  49491. '�' => '�',
  49492. '�' => '�',
  49493. '�' => '�',
  49494. '�' => '�',
  49495. '�' => '�',
  49496. '�' => '�',
  49497. '�' => '�',
  49498. '�' => '�',
  49499. '�' => '�',
  49500. '�' => '�',
  49501. '�' => '�',
  49502. '�' => '�',
  49503. '�' => '�',
  49504. '�' => '�',
  49505. '�' => '�',
  49506. '�' => '�',
  49507. '�' => '�',
  49508. '�' => '�',
  49509. '�' => '�',
  49510. '�' => '�',
  49511. '�' => '�',
  49512. '�' => '�',
  49513. '�' => '�',
  49514. '�' => '�',
  49515. '�' => '�',
  49516. '�' => '�',
  49517. '�' => '�',
  49518. '�' => '�',
  49519. '�' => '�',
  49520. '�' => '�',
  49521. '�' => '�',
  49522. '�' => '�',
  49523. '�' => '�',
  49524. '�' => '�',
  49525. '�' => '�',
  49526. '�' => '�',
  49527. '�' => '�',
  49528. '�' => '�',
  49529. '�' => '�',
  49530. '�' => '�',
  49531. '�' => '�',
  49532. '�' => '�',
  49533. '�' => '�',
  49534. '�' => '�',
  49535. '�' => '�',
  49536. '�' => '�',
  49537. '�' => '�',
  49538. '�' => '�',
  49539. '�' => '�',
  49540. '�' => '�',
  49541. '�' => '�',
  49542. '�' => '�',
  49543. '�' => '�',
  49544. '�' => '�',
  49545. '�' => '�',
  49546. '�' => '�',
  49547. '�' => '�',
  49548. '�' => '�',
  49549. '�' => '�',
  49550. '�' => '�',
  49551. '�' => '�',
  49552. '�' => '�',
  49553. '�' => '�',
  49554. '�' => '�',
  49555. '�' => '�',
  49556. '�' => '�',
  49557. '�' => '�',
  49558. '�' => '�',
  49559. '�' => '�',
  49560. '�' => '�',
  49561. '�' => '�',
  49562. '�' => '�',
  49563. '�' => '�',
  49564. '�' => '�',
  49565. '�' => '�',
  49566. '�' => '�',
  49567. '�' => '�',
  49568. '�' => '�',
  49569. '�' => '�',
  49570. '�' => '�',
  49571. '�' => '�',
  49572. '�' => '�',
  49573. '�' => '�',
  49574. '�' => '�',
  49575. '�' => '�',
  49576. '�' => '�',
  49577. '�' => '�',
  49578. '�' => '�',
  49579. '�' => '�',
  49580. '�' => '�',
  49581. '�' => '�',
  49582. '�' => '�',
  49583. '�' => '�',
  49584. '�' => '�',
  49585. '�' => '�',
  49586. '�' => '�',
  49587. '�' => '�',
  49588. '�' => '�',
  49589. '�' => '�',
  49590. '�' => '�',
  49591. '�' => '�',
  49592. '�' => '�',
  49593. '�' => '�',
  49594. '�' => '�',
  49595. '�' => '�',
  49596. '�' => '�',
  49597. '�' => '�',
  49598. '�' => '�',
  49599. '�' => '�',
  49600. '�' => '�',
  49601. 'ð‘¢ ' => 'ð‘£€',
  49602. '𑢡' => '�',
  49603. '𑢢' => '𑣂',
  49604. '𑢣' => '𑣃',
  49605. '𑢤' => '𑣄',
  49606. 'ð‘¢¥' => 'ð‘£…',
  49607. '𑢦' => '𑣆',
  49608. '𑢧' => '𑣇',
  49609. '𑢨' => '𑣈',
  49610. '𑢩' => '𑣉',
  49611. '𑢪' => '𑣊',
  49612. '𑢫' => '𑣋',
  49613. '𑢬' => '𑣌',
  49614. '𑢭' => '�',
  49615. '𑢮' => '𑣎',
  49616. '𑢯' => '�',
  49617. '𑢰' => '�',
  49618. '𑢱' => '𑣑',
  49619. 'ð‘¢²' => 'ð‘£’',
  49620. '𑢳' => '𑣓',
  49621. 'ð‘¢´' => 'ð‘£”',
  49622. '𑢵' => '𑣕',
  49623. 'ð‘¢¶' => 'ð‘£–',
  49624. 'ð‘¢·' => 'ð‘£—',
  49625. '𑢸' => '𑣘',
  49626. 'ð‘¢¹' => 'ð‘£™',
  49627. '𑢺' => '𑣚',
  49628. 'ð‘¢»' => 'ð‘£›',
  49629. '𑢼' => '𑣜',
  49630. '𑢽' => '�',
  49631. '𑢾' => '𑣞',
  49632. '𑢿' => '𑣟',
  49633. 'ð–¹€' => 'ð–¹ ',
  49634. '�' => '𖹡',
  49635. '𖹂' => '𖹢',
  49636. '𖹃' => '𖹣',
  49637. '𖹄' => '𖹤',
  49638. 'ð–¹…' => 'ð–¹¥',
  49639. '𖹆' => '𖹦',
  49640. '𖹇' => '𖹧',
  49641. '𖹈' => '𖹨',
  49642. '𖹉' => '𖹩',
  49643. '𖹊' => '𖹪',
  49644. '𖹋' => '𖹫',
  49645. '𖹌' => '𖹬',
  49646. '�' => '𖹭',
  49647. '𖹎' => '𖹮',
  49648. '�' => '𖹯',
  49649. '�' => '𖹰',
  49650. '𖹑' => '𖹱',
  49651. 'ð–¹’' => 'ð–¹²',
  49652. '𖹓' => '𖹳',
  49653. 'ð–¹”' => 'ð–¹´',
  49654. '𖹕' => '𖹵',
  49655. 'ð–¹–' => 'ð–¹¶',
  49656. 'ð–¹—' => 'ð–¹·',
  49657. '𖹘' => '𖹸',
  49658. 'ð–¹™' => 'ð–¹¹',
  49659. '𖹚' => '𖹺',
  49660. 'ð–¹›' => 'ð–¹»',
  49661. '𖹜' => '𖹼',
  49662. '�' => '𖹽',
  49663. '𖹞' => '𖹾',
  49664. '𖹟' => '𖹿',
  49665. '𞤀' => '𞤢',
  49666. '�' => '𞤣',
  49667. '𞤂' => '𞤤',
  49668. '𞤃' => '𞤥',
  49669. '𞤄' => '𞤦',
  49670. '𞤅' => '𞤧',
  49671. '𞤆' => '𞤨',
  49672. '𞤇' => '𞤩',
  49673. '𞤈' => '𞤪',
  49674. '𞤉' => '𞤫',
  49675. '𞤊' => '𞤬',
  49676. '𞤋' => '𞤭',
  49677. '𞤌' => '𞤮',
  49678. '�' => '𞤯',
  49679. '𞤎' => '𞤰',
  49680. '�' => '𞤱',
  49681. '�' => '𞤲',
  49682. '𞤑' => '𞤳',
  49683. '𞤒' => '𞤴',
  49684. '𞤓' => '𞤵',
  49685. '𞤔' => '𞤶',
  49686. '𞤕' => '𞤷',
  49687. '𞤖' => '𞤸',
  49688. '𞤗' => '𞤹',
  49689. '𞤘' => '𞤺',
  49690. '𞤙' => '𞤻',
  49691. '𞤚' => '𞤼',
  49692. '𞤛' => '𞤽',
  49693. '𞤜' => '𞤾',
  49694. '�' => '𞤿',
  49695. '𞤞' => '𞥀',
  49696. '𞤟' => '�',
  49697. '𞤠' => '𞥂',
  49698. '𞤡' => '𞥃',
  49699. );
  49700. <?php
  49701. 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';
  49702. <?php
  49703. return array (
  49704. 'a' => 'A',
  49705. 'b' => 'B',
  49706. 'c' => 'C',
  49707. 'd' => 'D',
  49708. 'e' => 'E',
  49709. 'f' => 'F',
  49710. 'g' => 'G',
  49711. 'h' => 'H',
  49712. 'i' => 'I',
  49713. 'j' => 'J',
  49714. 'k' => 'K',
  49715. 'l' => 'L',
  49716. 'm' => 'M',
  49717. 'n' => 'N',
  49718. 'o' => 'O',
  49719. 'p' => 'P',
  49720. 'q' => 'Q',
  49721. 'r' => 'R',
  49722. 's' => 'S',
  49723. 't' => 'T',
  49724. 'u' => 'U',
  49725. 'v' => 'V',
  49726. 'w' => 'W',
  49727. 'x' => 'X',
  49728. 'y' => 'Y',
  49729. 'z' => 'Z',
  49730. 'µ' => 'Μ',
  49731. 'à' => 'À',
  49732. 'á' => '�',
  49733. 'â' => 'Â',
  49734. 'ã' => 'Ã',
  49735. 'ä' => 'Ä',
  49736. 'Ã¥' => 'Ã…',
  49737. 'æ' => 'Æ',
  49738. 'ç' => 'Ç',
  49739. 'è' => 'È',
  49740. 'é' => 'É',
  49741. 'ê' => 'Ê',
  49742. 'ë' => 'Ë',
  49743. 'ì' => 'Ì',
  49744. 'í' => '�',
  49745. 'î' => 'Î',
  49746. 'ï' => '�',
  49747. 'ð' => '�',
  49748. 'ñ' => 'Ñ',
  49749. 'ò' => 'Ò',
  49750. 'ó' => 'Ó',
  49751. 'ô' => 'Ô',
  49752. 'õ' => 'Õ',
  49753. 'ö' => 'Ö',
  49754. 'ø' => 'Ø',
  49755. 'ù' => 'Ù',
  49756. 'ú' => 'Ú',
  49757. 'û' => 'Û',
  49758. 'ü' => 'Ü',
  49759. 'ý' => '�',
  49760. 'þ' => 'Þ',
  49761. 'ÿ' => 'Ÿ',
  49762. '�' => 'Ā',
  49763. 'ă' => 'Ă',
  49764. 'Ä…' => 'Ä„',
  49765. 'ć' => 'Ć',
  49766. 'ĉ' => 'Ĉ',
  49767. 'Ä‹' => 'ÄŠ',
  49768. '�' => 'Č',
  49769. '�' => 'Ď',
  49770. 'đ' => '�',
  49771. 'Ä“' => 'Ä’',
  49772. 'Ä•' => 'Ä”',
  49773. 'Ä—' => 'Ä–',
  49774. 'ę' => 'Ę',
  49775. 'Ä›' => 'Äš',
  49776. '�' => 'Ĝ',
  49777. 'ÄŸ' => 'Äž',
  49778. 'Ä¡' => 'Ä ',
  49779. 'Ä£' => 'Ä¢',
  49780. 'ĥ' => 'Ĥ',
  49781. 'ħ' => 'Ħ',
  49782. 'ĩ' => 'Ĩ',
  49783. 'ī' => 'Ī',
  49784. 'ĭ' => 'Ĭ',
  49785. 'į' => 'Į',
  49786. 'ı' => 'I',
  49787. 'ij' => 'IJ',
  49788. 'ĵ' => 'Ĵ',
  49789. 'ķ' => 'Ķ',
  49790. 'ĺ' => 'Ĺ',
  49791. 'ļ' => 'Ļ',
  49792. 'ľ' => 'Ľ',
  49793. 'Å€' => 'Ä¿',
  49794. 'ł' => '�',
  49795. 'ń' => 'Ń',
  49796. 'ņ' => 'Ņ',
  49797. 'ň' => 'Ň',
  49798. 'Å‹' => 'ÅŠ',
  49799. '�' => 'Ō',
  49800. '�' => 'Ŏ',
  49801. 'ő' => '�',
  49802. 'Å“' => 'Å’',
  49803. 'Å•' => 'Å”',
  49804. 'Å—' => 'Å–',
  49805. 'ř' => 'Ř',
  49806. 'Å›' => 'Åš',
  49807. '�' => 'Ŝ',
  49808. 'ÅŸ' => 'Åž',
  49809. 'Å¡' => 'Å ',
  49810. 'Å£' => 'Å¢',
  49811. 'ť' => 'Ť',
  49812. 'ŧ' => 'Ŧ',
  49813. 'ũ' => 'Ũ',
  49814. 'ū' => 'Ū',
  49815. 'ŭ' => 'Ŭ',
  49816. 'ů' => 'Ů',
  49817. 'ű' => 'Ű',
  49818. 'ų' => 'Ų',
  49819. 'ŵ' => 'Ŵ',
  49820. 'ŷ' => 'Ŷ',
  49821. 'ź' => 'Ź',
  49822. 'ż' => 'Ż',
  49823. 'ž' => 'Ž',
  49824. 'Å¿' => 'S',
  49825. 'ƀ' => 'Ƀ',
  49826. 'ƃ' => 'Ƃ',
  49827. 'Æ…' => 'Æ„',
  49828. 'ƈ' => 'Ƈ',
  49829. 'ƌ' => 'Ƌ',
  49830. 'Æ’' => 'Æ‘',
  49831. 'ƕ' => 'Ƕ',
  49832. 'ƙ' => 'Ƙ',
  49833. 'ƚ' => 'Ƚ',
  49834. 'Æž' => 'È ',
  49835. 'Æ¡' => 'Æ ',
  49836. 'Æ£' => 'Æ¢',
  49837. 'ƥ' => 'Ƥ',
  49838. 'ƨ' => 'Ƨ',
  49839. 'ƭ' => 'Ƭ',
  49840. 'ư' => 'Ư',
  49841. 'ƴ' => 'Ƴ',
  49842. 'ƶ' => 'Ƶ',
  49843. 'ƹ' => 'Ƹ',
  49844. 'ƽ' => 'Ƽ',
  49845. 'Æ¿' => 'Ç·',
  49846. 'Ç…' => 'Ç„',
  49847. 'dž' => 'DŽ',
  49848. 'Lj' => 'LJ',
  49849. 'lj' => 'LJ',
  49850. 'Ç‹' => 'ÇŠ',
  49851. 'nj' => 'NJ',
  49852. 'ǎ' => '�',
  49853. '�' => '�',
  49854. 'Ç’' => 'Ç‘',
  49855. 'Ç”' => 'Ç“',
  49856. 'Ç–' => 'Ç•',
  49857. 'ǘ' => 'Ǘ',
  49858. 'Çš' => 'Ç™',
  49859. 'ǜ' => 'Ǜ',
  49860. '�' => 'Ǝ',
  49861. 'ÇŸ' => 'Çž',
  49862. 'Ç¡' => 'Ç ',
  49863. 'Ç£' => 'Ç¢',
  49864. 'ǥ' => 'Ǥ',
  49865. 'ǧ' => 'Ǧ',
  49866. 'ǩ' => 'Ǩ',
  49867. 'ǫ' => 'Ǫ',
  49868. 'ǭ' => 'Ǭ',
  49869. 'ǯ' => 'Ǯ',
  49870. 'Dz' => 'DZ',
  49871. 'dz' => 'DZ',
  49872. 'ǵ' => 'Ǵ',
  49873. 'ǹ' => 'Ǹ',
  49874. 'ǻ' => 'Ǻ',
  49875. 'ǽ' => 'Ǽ',
  49876. 'ǿ' => 'Ǿ',
  49877. '�' => 'Ȁ',
  49878. 'ȃ' => 'Ȃ',
  49879. 'È…' => 'È„',
  49880. 'ȇ' => 'Ȇ',
  49881. 'ȉ' => 'Ȉ',
  49882. 'È‹' => 'ÈŠ',
  49883. '�' => 'Ȍ',
  49884. '�' => 'Ȏ',
  49885. 'ȑ' => '�',
  49886. 'È“' => 'È’',
  49887. 'È•' => 'È”',
  49888. 'È—' => 'È–',
  49889. 'ș' => 'Ș',
  49890. 'È›' => 'Èš',
  49891. '�' => 'Ȝ',
  49892. 'ÈŸ' => 'Èž',
  49893. 'È£' => 'È¢',
  49894. 'ȥ' => 'Ȥ',
  49895. 'ȧ' => 'Ȧ',
  49896. 'ȩ' => 'Ȩ',
  49897. 'ȫ' => 'Ȫ',
  49898. 'ȭ' => 'Ȭ',
  49899. 'ȯ' => 'Ȯ',
  49900. 'ȱ' => 'Ȱ',
  49901. 'ȳ' => 'Ȳ',
  49902. 'ȼ' => 'Ȼ',
  49903. 'È¿' => 'â±¾',
  49904. 'ɀ' => 'Ɀ',
  49905. 'ɂ' => '�',
  49906. 'ɇ' => 'Ɇ',
  49907. 'ɉ' => 'Ɉ',
  49908. 'É‹' => 'ÉŠ',
  49909. '�' => 'Ɍ',
  49910. '�' => 'Ɏ',
  49911. '�' => 'Ɐ',
  49912. 'É‘' => 'â±­',
  49913. 'É’' => 'â±°',
  49914. 'ɓ' => '�',
  49915. 'ɔ' => 'Ɔ',
  49916. 'ɖ' => 'Ɖ',
  49917. 'É—' => 'ÆŠ',
  49918. 'ə' => '�',
  49919. 'ɛ' => '�',
  49920. 'ɜ' => 'Ɜ',
  49921. 'É ' => 'Æ“',
  49922. 'ɡ' => 'Ɡ',
  49923. 'É£' => 'Æ”',
  49924. 'ɥ' => '�',
  49925. 'ɦ' => 'Ɦ',
  49926. 'ɨ' => 'Ɨ',
  49927. 'É©' => 'Æ–',
  49928. 'ɪ' => 'Ɪ',
  49929. 'É«' => 'â±¢',
  49930. 'ɬ' => 'Ɬ',
  49931. 'ɯ' => 'Ɯ',
  49932. 'ɱ' => 'Ɱ',
  49933. 'ɲ' => '�',
  49934. 'ɵ' => 'Ɵ',
  49935. 'ɽ' => 'Ɽ',
  49936. 'ʀ' => 'Ʀ',
  49937. 'ʂ' => 'Ʂ',
  49938. 'ʃ' => 'Ʃ',
  49939. 'ʇ' => 'Ʇ',
  49940. 'ʈ' => 'Ʈ',
  49941. 'ʉ' => 'Ʉ',
  49942. 'ʊ' => 'Ʊ',
  49943. 'ʋ' => 'Ʋ',
  49944. 'ʌ' => 'Ʌ',
  49945. 'Ê’' => 'Æ·',
  49946. '�' => 'Ʝ',
  49947. 'Êž' => 'êž°',
  49948. 'ͅ' => 'Ι',
  49949. 'ͱ' => 'Ͱ',
  49950. 'ͳ' => 'Ͳ',
  49951. 'ͷ' => 'Ͷ',
  49952. 'ͻ' => 'Ͻ',
  49953. 'ͼ' => 'Ͼ',
  49954. 'ͽ' => 'Ͽ',
  49955. 'ά' => 'Ά',
  49956. 'έ' => 'Έ',
  49957. 'ή' => 'Ή',
  49958. 'ί' => 'Ί',
  49959. 'α' => 'Α',
  49960. 'β' => 'Β',
  49961. 'γ' => 'Γ',
  49962. 'δ' => 'Δ',
  49963. 'ε' => 'Ε',
  49964. 'ζ' => 'Ζ',
  49965. 'η' => 'Η',
  49966. 'θ' => 'Θ',
  49967. 'ι' => 'Ι',
  49968. 'κ' => 'Κ',
  49969. 'λ' => 'Λ',
  49970. 'μ' => 'Μ',
  49971. 'ν' => '�',
  49972. 'ξ' => 'Ξ',
  49973. 'ο' => 'Ο',
  49974. 'π' => 'Π',
  49975. '�' => 'Ρ',
  49976. 'ς' => 'Σ',
  49977. 'σ' => 'Σ',
  49978. 'τ' => 'Τ',
  49979. 'Ï…' => 'Î¥',
  49980. 'φ' => 'Φ',
  49981. 'χ' => 'Χ',
  49982. 'ψ' => 'Ψ',
  49983. 'ω' => 'Ω',
  49984. 'ϊ' => 'Ϊ',
  49985. 'ϋ' => 'Ϋ',
  49986. 'ό' => 'Ό',
  49987. '�' => 'Ύ',
  49988. 'ώ' => '�',
  49989. '�' => 'Β',
  49990. 'ϑ' => 'Θ',
  49991. 'ϕ' => 'Φ',
  49992. 'ϖ' => 'Π',
  49993. 'ϗ' => '�',
  49994. 'ϙ' => 'Ϙ',
  49995. 'Ï›' => 'Ïš',
  49996. '�' => 'Ϝ',
  49997. 'ÏŸ' => 'Ïž',
  49998. 'Ï¡' => 'Ï ',
  49999. 'Ï£' => 'Ï¢',
  50000. 'ϥ' => 'Ϥ',
  50001. 'ϧ' => 'Ϧ',
  50002. 'ϩ' => 'Ϩ',
  50003. 'ϫ' => 'Ϫ',
  50004. 'ϭ' => 'Ϭ',
  50005. 'ϯ' => 'Ϯ',
  50006. 'ϰ' => 'Κ',
  50007. 'ϱ' => 'Ρ',
  50008. 'ϲ' => 'Ϲ',
  50009. 'ϳ' => 'Ϳ',
  50010. 'ϵ' => 'Ε',
  50011. 'ϸ' => 'Ϸ',
  50012. 'ϻ' => 'Ϻ',
  50013. 'а' => '�',
  50014. 'б' => 'Б',
  50015. 'в' => 'В',
  50016. 'г' => 'Г',
  50017. 'д' => 'Д',
  50018. 'е' => 'Е',
  50019. 'ж' => 'Ж',
  50020. 'з' => 'З',
  50021. 'и' => 'И',
  50022. 'й' => 'Й',
  50023. 'к' => 'К',
  50024. 'л' => 'Л',
  50025. 'м' => 'М',
  50026. 'н' => '�',
  50027. 'о' => 'О',
  50028. 'п' => 'П',
  50029. 'р' => 'Р',
  50030. '�' => 'С',
  50031. 'т' => 'Т',
  50032. 'у' => 'У',
  50033. 'ф' => 'Ф',
  50034. 'Ñ…' => 'Ð¥',
  50035. 'ц' => 'Ц',
  50036. 'ч' => 'Ч',
  50037. 'ш' => 'Ш',
  50038. 'щ' => 'Щ',
  50039. 'ъ' => 'Ъ',
  50040. 'ы' => 'Ы',
  50041. 'ь' => 'Ь',
  50042. '�' => 'Э',
  50043. 'ю' => 'Ю',
  50044. '�' => 'Я',
  50045. '�' => 'Ѐ',
  50046. 'ё' => '�',
  50047. 'ђ' => 'Ђ',
  50048. 'ѓ' => 'Ѓ',
  50049. 'є' => 'Є',
  50050. 'Ñ•' => 'Ð…',
  50051. 'і' => 'І',
  50052. 'ї' => 'Ї',
  50053. 'ј' => 'Ј',
  50054. 'љ' => 'Љ',
  50055. 'њ' => 'Њ',
  50056. 'ћ' => 'Ћ',
  50057. 'ќ' => 'Ќ',
  50058. '�' => '�',
  50059. 'Ñž' => 'ÐŽ',
  50060. 'џ' => '�',
  50061. 'Ñ¡' => 'Ñ ',
  50062. 'Ñ£' => 'Ñ¢',
  50063. 'ѥ' => 'Ѥ',
  50064. 'ѧ' => 'Ѧ',
  50065. 'ѩ' => 'Ѩ',
  50066. 'ѫ' => 'Ѫ',
  50067. 'ѭ' => 'Ѭ',
  50068. 'ѯ' => 'Ѯ',
  50069. 'ѱ' => 'Ѱ',
  50070. 'ѳ' => 'Ѳ',
  50071. 'ѵ' => 'Ѵ',
  50072. 'ѷ' => 'Ѷ',
  50073. 'ѹ' => 'Ѹ',
  50074. 'ѻ' => 'Ѻ',
  50075. 'ѽ' => 'Ѽ',
  50076. 'ѿ' => 'Ѿ',
  50077. 'Ò�' => 'Ò€',
  50078. 'Ò‹' => 'ÒŠ',
  50079. '�' => 'Ҍ',
  50080. 'Ò�' => 'ÒŽ',
  50081. 'Ò‘' => 'Ò�',
  50082. 'Ò“' => 'Ò’',
  50083. 'Ò•' => 'Ò”',
  50084. 'Ò—' => 'Ò–',
  50085. 'Ò™' => 'Ò˜',
  50086. 'Ò›' => 'Òš',
  50087. '�' => 'Ҝ',
  50088. 'ÒŸ' => 'Òž',
  50089. 'Ò¡' => 'Ò ',
  50090. 'Ò£' => 'Ò¢',
  50091. 'Ò¥' => 'Ò¤',
  50092. 'Ò§' => 'Ò¦',
  50093. 'Ò©' => 'Ò¨',
  50094. 'Ò«' => 'Òª',
  50095. 'Ò­' => 'Ò¬',
  50096. 'Ò¯' => 'Ò®',
  50097. 'Ò±' => 'Ò°',
  50098. 'Ò³' => 'Ò²',
  50099. 'Òµ' => 'Ò´',
  50100. 'Ò·' => 'Ò¶',
  50101. 'Ò¹' => 'Ò¸',
  50102. 'Ò»' => 'Òº',
  50103. 'Ò½' => 'Ò¼',
  50104. 'Ò¿' => 'Ò¾',
  50105. 'Ó‚' => 'Ó�',
  50106. 'Ó„' => 'Óƒ',
  50107. 'Ó†' => 'Ó…',
  50108. 'Óˆ' => 'Ó‡',
  50109. 'ÓŠ' => 'Ó‰',
  50110. 'ӌ' => 'Ӌ',
  50111. 'ÓŽ' => 'Ó�',
  50112. 'Ó�' => 'Ó€',
  50113. 'Ó‘' => 'Ó�',
  50114. 'Ó“' => 'Ó’',
  50115. 'Ó•' => 'Ó”',
  50116. 'Ó—' => 'Ó–',
  50117. 'Ó™' => 'Ó˜',
  50118. 'Ó›' => 'Óš',
  50119. '�' => 'Ӝ',
  50120. 'ÓŸ' => 'Óž',
  50121. 'Ó¡' => 'Ó ',
  50122. 'Ó£' => 'Ó¢',
  50123. 'Ó¥' => 'Ó¤',
  50124. 'Ó§' => 'Ó¦',
  50125. 'Ó©' => 'Ó¨',
  50126. 'Ó«' => 'Óª',
  50127. 'Ó­' => 'Ó¬',
  50128. 'Ó¯' => 'Ó®',
  50129. 'Ó±' => 'Ó°',
  50130. 'Ó³' => 'Ó²',
  50131. 'Óµ' => 'Ó´',
  50132. 'Ó·' => 'Ó¶',
  50133. 'Ó¹' => 'Ó¸',
  50134. 'Ó»' => 'Óº',
  50135. 'Ó½' => 'Ó¼',
  50136. 'Ó¿' => 'Ó¾',
  50137. 'Ô�' => 'Ô€',
  50138. 'Ôƒ' => 'Ô‚',
  50139. 'Ô…' => 'Ô„',
  50140. 'Ô‡' => 'Ô†',
  50141. 'Ô‰' => 'Ôˆ',
  50142. 'Ô‹' => 'ÔŠ',
  50143. '�' => 'Ԍ',
  50144. 'Ô�' => 'ÔŽ',
  50145. 'Ô‘' => 'Ô�',
  50146. 'Ô“' => 'Ô’',
  50147. 'Ô•' => 'Ô”',
  50148. 'Ô—' => 'Ô–',
  50149. 'Ô™' => 'Ô˜',
  50150. 'Ô›' => 'Ôš',
  50151. '�' => 'Ԝ',
  50152. 'ÔŸ' => 'Ôž',
  50153. 'Ô¡' => 'Ô ',
  50154. 'Ô£' => 'Ô¢',
  50155. 'Ô¥' => 'Ô¤',
  50156. 'Ô§' => 'Ô¦',
  50157. 'Ô©' => 'Ô¨',
  50158. 'Ô«' => 'Ôª',
  50159. 'Ô­' => 'Ô¬',
  50160. 'Ô¯' => 'Ô®',
  50161. 'Õ¡' => 'Ô±',
  50162. 'Õ¢' => 'Ô²',
  50163. 'Õ£' => 'Ô³',
  50164. 'Õ¤' => 'Ô´',
  50165. 'Õ¥' => 'Ôµ',
  50166. 'Õ¦' => 'Ô¶',
  50167. 'Õ§' => 'Ô·',
  50168. 'Õ¨' => 'Ô¸',
  50169. 'Õ©' => 'Ô¹',
  50170. 'Õª' => 'Ôº',
  50171. 'Õ«' => 'Ô»',
  50172. 'Õ¬' => 'Ô¼',
  50173. 'Õ­' => 'Ô½',
  50174. 'Õ®' => 'Ô¾',
  50175. 'Õ¯' => 'Ô¿',
  50176. 'Õ°' => 'Õ€',
  50177. 'Õ±' => 'Õ�',
  50178. 'Õ²' => 'Õ‚',
  50179. 'Õ³' => 'Õƒ',
  50180. 'Õ´' => 'Õ„',
  50181. 'Õµ' => 'Õ…',
  50182. 'Õ¶' => 'Õ†',
  50183. 'Õ·' => 'Õ‡',
  50184. 'Õ¸' => 'Õˆ',
  50185. 'Õ¹' => 'Õ‰',
  50186. 'Õº' => 'ÕŠ',
  50187. 'Õ»' => 'Õ‹',
  50188. 'ռ' => 'Ռ',
  50189. 'Õ½' => 'Õ�',
  50190. 'Õ¾' => 'ÕŽ',
  50191. 'Õ¿' => 'Õ�',
  50192. 'Ö€' => 'Õ�',
  50193. 'Ö�' => 'Õ‘',
  50194. 'Ö‚' => 'Õ’',
  50195. 'Öƒ' => 'Õ“',
  50196. 'Ö„' => 'Õ”',
  50197. 'Ö…' => 'Õ•',
  50198. 'Ö†' => 'Õ–',
  50199. '�' => '�',
  50200. 'ბ' => 'Ბ',
  50201. 'გ' => 'Გ',
  50202. 'დ' => 'Დ',
  50203. 'ე' => 'Ე',
  50204. 'ვ' => 'Ვ',
  50205. 'ზ' => 'Ზ',
  50206. 'თ' => 'Თ',
  50207. 'ი' => 'Ი',
  50208. 'კ' => 'Კ',
  50209. 'ლ' => 'Ლ',
  50210. 'მ' => 'Მ',
  50211. 'ნ' => 'Ნ',
  50212. '�' => '�',
  50213. 'პ' => 'Პ',
  50214. 'ჟ' => 'Ჟ',
  50215. 'რ' => 'Რ',
  50216. 'ს' => 'Ს',
  50217. 'ტ' => 'Ტ',
  50218. 'უ' => 'Უ',
  50219. 'ფ' => 'Ფ',
  50220. 'ქ' => 'Ქ',
  50221. 'ღ' => 'Ღ',
  50222. 'ყ' => 'Ყ',
  50223. 'შ' => 'Შ',
  50224. 'ჩ' => 'Ჩ',
  50225. 'ც' => 'Ც',
  50226. 'ძ' => 'Ძ',
  50227. 'წ' => 'Წ',
  50228. 'ჭ' => 'Ჭ',
  50229. 'ხ' => 'Ხ',
  50230. 'ჯ' => 'Ჯ',
  50231. 'ჰ' => 'Ჰ',
  50232. 'ჱ' => 'Ჱ',
  50233. 'ჲ' => 'Ჲ',
  50234. 'ჳ' => 'Ჳ',
  50235. 'ჴ' => 'Ჴ',
  50236. 'ჵ' => 'Ჵ',
  50237. 'ჶ' => 'Ჶ',
  50238. 'ჷ' => 'Ჷ',
  50239. 'ჸ' => 'Ჸ',
  50240. 'ჹ' => 'Ჹ',
  50241. 'ჺ' => 'Ჺ',
  50242. 'ჽ' => 'Ჽ',
  50243. 'ჾ' => 'Ჾ',
  50244. 'ჿ' => 'Ჿ',
  50245. '�' => '�',
  50246. '�' => '�',
  50247. '�' => '�',
  50248. '�' => '�',
  50249. '�' => '�',
  50250. '�' => '�',
  50251. 'á²€' => 'Ð’',
  50252. '�' => 'Д',
  50253. 'ᲂ' => 'О',
  50254. 'ᲃ' => 'С',
  50255. 'ᲄ' => 'Т',
  50256. 'ᲅ' => 'Т',
  50257. 'ᲆ' => 'Ъ',
  50258. 'ᲇ' => 'Ѣ',
  50259. 'ᲈ' => 'Ꙋ',
  50260. 'ᵹ' => '�',
  50261. 'áµ½' => 'â±£',
  50262. 'ᶎ' => 'Ᶎ',
  50263. '�' => 'Ḁ',
  50264. 'ḃ' => 'Ḃ',
  50265. 'ḅ' => 'Ḅ',
  50266. 'ḇ' => 'Ḇ',
  50267. 'ḉ' => 'Ḉ',
  50268. 'ḋ' => 'Ḋ',
  50269. '�' => 'Ḍ',
  50270. '�' => 'Ḏ',
  50271. 'ḑ' => '�',
  50272. 'ḓ' => 'Ḓ',
  50273. 'ḕ' => 'Ḕ',
  50274. 'ḗ' => 'Ḗ',
  50275. 'ḙ' => 'Ḙ',
  50276. 'ḛ' => 'Ḛ',
  50277. '�' => 'Ḝ',
  50278. 'ḟ' => 'Ḟ',
  50279. 'ḡ' => 'Ḡ',
  50280. 'ḣ' => 'Ḣ',
  50281. 'ḥ' => 'Ḥ',
  50282. 'ḧ' => 'Ḧ',
  50283. 'ḩ' => 'Ḩ',
  50284. 'ḫ' => 'Ḫ',
  50285. 'ḭ' => 'Ḭ',
  50286. 'ḯ' => 'Ḯ',
  50287. 'ḱ' => 'Ḱ',
  50288. 'ḳ' => 'Ḳ',
  50289. 'ḵ' => 'Ḵ',
  50290. 'ḷ' => 'Ḷ',
  50291. 'ḹ' => 'Ḹ',
  50292. 'ḻ' => 'Ḻ',
  50293. 'ḽ' => 'Ḽ',
  50294. 'ḿ' => 'Ḿ',
  50295. '�' => 'Ṁ',
  50296. 'ṃ' => 'Ṃ',
  50297. 'ṅ' => 'Ṅ',
  50298. 'ṇ' => 'Ṇ',
  50299. 'ṉ' => 'Ṉ',
  50300. 'ṋ' => 'Ṋ',
  50301. '�' => 'Ṍ',
  50302. '�' => 'Ṏ',
  50303. 'ṑ' => '�',
  50304. 'ṓ' => 'Ṓ',
  50305. 'ṕ' => 'Ṕ',
  50306. 'á¹—' => 'á¹–',
  50307. 'ṙ' => 'Ṙ',
  50308. 'ṛ' => 'Ṛ',
  50309. '�' => 'Ṝ',
  50310. 'ṟ' => 'Ṟ',
  50311. 'ṡ' => 'Ṡ',
  50312. 'á¹£' => 'á¹¢',
  50313. 'ṥ' => 'Ṥ',
  50314. 'ṧ' => 'Ṧ',
  50315. 'ṩ' => 'Ṩ',
  50316. 'ṫ' => 'Ṫ',
  50317. 'ṭ' => 'Ṭ',
  50318. 'ṯ' => 'Ṯ',
  50319. 'á¹±' => 'á¹°',
  50320. 'á¹³' => 'á¹²',
  50321. 'á¹µ' => 'á¹´',
  50322. 'á¹·' => 'á¹¶',
  50323. 'ṹ' => 'Ṹ',
  50324. 'ṻ' => 'Ṻ',
  50325. 'á¹½' => 'á¹¼',
  50326. 'ṿ' => 'Ṿ',
  50327. '�' => 'Ẁ',
  50328. 'ẃ' => 'Ẃ',
  50329. 'ẅ' => 'Ẅ',
  50330. 'ẇ' => 'Ẇ',
  50331. 'ẉ' => 'Ẉ',
  50332. 'ẋ' => 'Ẋ',
  50333. '�' => 'Ẍ',
  50334. '�' => 'Ẏ',
  50335. 'ẑ' => '�',
  50336. 'ẓ' => 'Ẓ',
  50337. 'ẕ' => 'Ẕ',
  50338. 'ẛ' => 'Ṡ',
  50339. 'ạ' => 'Ạ',
  50340. 'ả' => 'Ả',
  50341. 'ấ' => 'Ấ',
  50342. 'ầ' => 'Ầ',
  50343. 'ẩ' => 'Ẩ',
  50344. 'ẫ' => 'Ẫ',
  50345. 'ậ' => 'Ậ',
  50346. 'ắ' => 'Ắ',
  50347. 'ằ' => 'Ằ',
  50348. 'ẳ' => 'Ẳ',
  50349. 'ẵ' => 'Ẵ',
  50350. 'ặ' => 'Ặ',
  50351. 'ẹ' => 'Ẹ',
  50352. 'ẻ' => 'Ẻ',
  50353. 'ẽ' => 'Ẽ',
  50354. 'ế' => 'Ế',
  50355. '�' => 'Ề',
  50356. 'ể' => 'Ể',
  50357. 'ễ' => 'Ễ',
  50358. 'ệ' => 'Ệ',
  50359. 'ỉ' => 'Ỉ',
  50360. 'ị' => 'Ị',
  50361. '�' => 'Ọ',
  50362. '�' => 'Ỏ',
  50363. 'ố' => '�',
  50364. 'ồ' => 'Ồ',
  50365. 'ổ' => 'Ổ',
  50366. 'á»—' => 'á»–',
  50367. 'ộ' => 'Ộ',
  50368. 'ớ' => 'Ớ',
  50369. '�' => 'Ờ',
  50370. 'ở' => 'Ở',
  50371. 'ỡ' => 'Ỡ',
  50372. 'ợ' => 'Ợ',
  50373. 'ụ' => 'Ụ',
  50374. 'ủ' => 'Ủ',
  50375. 'ứ' => 'Ứ',
  50376. 'ừ' => 'Ừ',
  50377. 'ử' => 'Ử',
  50378. 'ữ' => 'Ữ',
  50379. 'á»±' => 'á»°',
  50380. 'ỳ' => 'Ỳ',
  50381. 'ỵ' => 'Ỵ',
  50382. 'á»·' => 'á»¶',
  50383. 'ỹ' => 'Ỹ',
  50384. 'ỻ' => 'Ỻ',
  50385. 'ỽ' => 'Ỽ',
  50386. 'ỿ' => 'Ỿ',
  50387. 'ἀ' => 'Ἀ',
  50388. '�' => 'Ἁ',
  50389. 'ἂ' => 'Ἂ',
  50390. 'ἃ' => 'Ἃ',
  50391. 'ἄ' => 'Ἄ',
  50392. 'ἅ' => '�',
  50393. 'ἆ' => 'Ἆ',
  50394. 'ἇ' => '�',
  50395. '�' => 'Ἐ',
  50396. 'ἑ' => 'Ἑ',
  50397. 'ἒ' => 'Ἒ',
  50398. 'ἓ' => 'Ἓ',
  50399. 'ἔ' => 'Ἔ',
  50400. 'ἕ' => '�',
  50401. 'ἠ' => 'Ἠ',
  50402. 'ἡ' => 'Ἡ',
  50403. 'ἢ' => 'Ἢ',
  50404. 'ἣ' => 'Ἣ',
  50405. 'ἤ' => 'Ἤ',
  50406. 'á¼¥' => 'á¼­',
  50407. 'ἦ' => 'Ἦ',
  50408. 'ἧ' => 'Ἧ',
  50409. 'ἰ' => 'Ἰ',
  50410. 'á¼±' => 'á¼¹',
  50411. 'ἲ' => 'Ἲ',
  50412. 'á¼³' => 'á¼»',
  50413. 'á¼´' => 'á¼¼',
  50414. 'á¼µ' => 'á¼½',
  50415. 'á¼¶' => 'á¼¾',
  50416. 'ἷ' => 'Ἷ',
  50417. 'ὀ' => 'Ὀ',
  50418. '�' => 'Ὁ',
  50419. 'ὂ' => 'Ὂ',
  50420. 'ὃ' => 'Ὃ',
  50421. 'ὄ' => 'Ὄ',
  50422. 'ὅ' => '�',
  50423. 'ὑ' => 'Ὑ',
  50424. 'ὓ' => 'Ὓ',
  50425. 'ὕ' => '�',
  50426. 'ὗ' => 'Ὗ',
  50427. 'ὠ' => 'Ὠ',
  50428. 'ὡ' => 'Ὡ',
  50429. 'ὢ' => 'Ὢ',
  50430. 'ὣ' => 'Ὣ',
  50431. 'ὤ' => 'Ὤ',
  50432. 'á½¥' => 'á½­',
  50433. 'ὦ' => 'Ὦ',
  50434. 'ὧ' => 'Ὧ',
  50435. 'ὰ' => 'Ὰ',
  50436. 'á½±' => 'á¾»',
  50437. 'ὲ' => 'Ὲ',
  50438. 'έ' => 'Έ',
  50439. 'ὴ' => 'Ὴ',
  50440. 'á½µ' => 'á¿‹',
  50441. 'ὶ' => 'Ὶ',
  50442. 'á½·' => 'á¿›',
  50443. 'ὸ' => 'Ὸ',
  50444. 'ό' => 'Ό',
  50445. 'ὺ' => 'Ὺ',
  50446. 'á½»' => 'á¿«',
  50447. 'ὼ' => 'Ὼ',
  50448. 'á½½' => 'á¿»',
  50449. 'ᾀ' => 'ᾈ',
  50450. '�' => 'ᾉ',
  50451. 'ᾂ' => 'ᾊ',
  50452. 'ᾃ' => 'ᾋ',
  50453. 'ᾄ' => 'ᾌ',
  50454. 'ᾅ' => '�',
  50455. 'ᾆ' => 'ᾎ',
  50456. 'ᾇ' => '�',
  50457. '�' => 'ᾘ',
  50458. 'ᾑ' => 'ᾙ',
  50459. 'ᾒ' => 'ᾚ',
  50460. 'ᾓ' => 'ᾛ',
  50461. 'ᾔ' => 'ᾜ',
  50462. 'ᾕ' => '�',
  50463. 'ᾖ' => 'ᾞ',
  50464. 'ᾗ' => 'ᾟ',
  50465. 'ᾠ' => 'ᾨ',
  50466. 'ᾡ' => 'ᾩ',
  50467. 'ᾢ' => 'ᾪ',
  50468. 'ᾣ' => 'ᾫ',
  50469. 'ᾤ' => 'ᾬ',
  50470. 'á¾¥' => 'á¾­',
  50471. 'ᾦ' => 'ᾮ',
  50472. 'ᾧ' => 'ᾯ',
  50473. 'ᾰ' => 'Ᾰ',
  50474. 'á¾±' => 'á¾¹',
  50475. 'á¾³' => 'á¾¼',
  50476. 'ι' => 'Ι',
  50477. 'ῃ' => 'ῌ',
  50478. '�' => 'Ῐ',
  50479. 'á¿‘' => 'á¿™',
  50480. 'ῠ' => 'Ῠ',
  50481. 'á¿¡' => 'á¿©',
  50482. 'ῥ' => 'Ῥ',
  50483. 'ῳ' => 'ῼ',
  50484. 'ⅎ' => 'Ⅎ',
  50485. 'â…°' => 'â… ',
  50486. 'â…±' => 'â…¡',
  50487. 'â…²' => 'â…¢',
  50488. 'â…³' => 'â…£',
  50489. 'â…´' => 'â…¤',
  50490. 'â…µ' => 'â…¥',
  50491. 'â…¶' => 'â…¦',
  50492. 'â…·' => 'â…§',
  50493. 'â…¸' => 'â…¨',
  50494. 'â…¹' => 'â…©',
  50495. 'â…º' => 'â…ª',
  50496. 'â…»' => 'â…«',
  50497. 'â…¼' => 'â…¬',
  50498. 'â…½' => 'â…­',
  50499. 'â…¾' => 'â…®',
  50500. 'â…¿' => 'â…¯',
  50501. 'ↄ' => 'Ↄ',
  50502. '�' => 'Ⓐ',
  50503. 'â“‘' => 'â’·',
  50504. 'â“’' => 'â’¸',
  50505. 'â““' => 'â’¹',
  50506. 'â“”' => 'â’º',
  50507. 'â“•' => 'â’»',
  50508. 'â“–' => 'â’¼',
  50509. 'â“—' => 'â’½',
  50510. 'ⓘ' => 'Ⓘ',
  50511. 'â“™' => 'â’¿',
  50512. 'ⓚ' => 'Ⓚ',
  50513. 'ⓛ' => '�',
  50514. 'ⓜ' => 'Ⓜ',
  50515. '�' => 'Ⓝ',
  50516. 'ⓞ' => 'Ⓞ',
  50517. 'ⓟ' => 'Ⓟ',
  50518. 'ⓠ' => 'Ⓠ',
  50519. 'ⓡ' => 'Ⓡ',
  50520. 'ⓢ' => 'Ⓢ',
  50521. 'ⓣ' => 'Ⓣ',
  50522. 'ⓤ' => 'Ⓤ',
  50523. 'â“¥' => 'â“‹',
  50524. 'ⓦ' => 'Ⓦ',
  50525. 'ⓧ' => '�',
  50526. 'ⓨ' => 'Ⓨ',
  50527. 'ⓩ' => '�',
  50528. 'â°°' => 'â°€',
  50529. 'â°±' => 'â°�',
  50530. 'â°²' => 'â°‚',
  50531. 'â°³' => 'â°ƒ',
  50532. 'â°´' => 'â°„',
  50533. 'â°µ' => 'â°…',
  50534. 'â°¶' => 'â°†',
  50535. 'â°·' => 'â°‡',
  50536. 'â°¸' => 'â°ˆ',
  50537. 'â°¹' => 'â°‰',
  50538. 'â°º' => 'â°Š',
  50539. 'â°»' => 'â°‹',
  50540. 'ⰼ' => 'Ⰼ',
  50541. 'â°½' => 'â°�',
  50542. 'â°¾' => 'â°Ž',
  50543. 'â°¿' => 'â°�',
  50544. 'â±€' => 'â°�',
  50545. '�' => 'Ⱁ',
  50546. 'ⱂ' => 'Ⱂ',
  50547. 'ⱃ' => 'Ⱃ',
  50548. 'ⱄ' => 'Ⱄ',
  50549. 'â±…' => 'â°•',
  50550. 'ⱆ' => 'Ⱆ',
  50551. 'ⱇ' => 'Ⱇ',
  50552. 'ⱈ' => 'Ⱈ',
  50553. 'ⱉ' => 'Ⱉ',
  50554. 'ⱊ' => 'Ⱊ',
  50555. 'ⱋ' => 'Ⱋ',
  50556. 'ⱌ' => 'Ⱌ',
  50557. '�' => '�',
  50558. 'ⱎ' => 'Ⱎ',
  50559. '�' => 'Ⱏ',
  50560. '�' => 'Ⱐ',
  50561. 'ⱑ' => 'Ⱑ',
  50562. 'â±’' => 'â°¢',
  50563. 'ⱓ' => 'Ⱓ',
  50564. 'â±”' => 'â°¤',
  50565. 'ⱕ' => 'Ⱕ',
  50566. 'â±–' => 'â°¦',
  50567. 'â±—' => 'â°§',
  50568. 'ⱘ' => 'Ⱘ',
  50569. 'â±™' => 'â°©',
  50570. 'ⱚ' => 'Ⱚ',
  50571. 'â±›' => 'â°«',
  50572. 'ⱜ' => 'Ⱜ',
  50573. '�' => 'Ⱝ',
  50574. 'ⱞ' => 'Ⱞ',
  50575. 'ⱡ' => 'Ⱡ',
  50576. 'ⱥ' => 'Ⱥ',
  50577. 'ⱦ' => 'Ⱦ',
  50578. 'ⱨ' => 'Ⱨ',
  50579. 'ⱪ' => 'Ⱪ',
  50580. 'ⱬ' => 'Ⱬ',
  50581. 'â±³' => 'â±²',
  50582. 'â±¶' => 'â±µ',
  50583. '�' => 'Ⲁ',
  50584. 'ⲃ' => 'Ⲃ',
  50585. 'ⲅ' => 'Ⲅ',
  50586. 'ⲇ' => 'Ⲇ',
  50587. 'ⲉ' => 'Ⲉ',
  50588. 'ⲋ' => 'Ⲋ',
  50589. '�' => 'Ⲍ',
  50590. '�' => 'Ⲏ',
  50591. 'ⲑ' => '�',
  50592. 'ⲓ' => 'Ⲓ',
  50593. 'ⲕ' => 'Ⲕ',
  50594. 'â²—' => 'â²–',
  50595. 'ⲙ' => 'Ⲙ',
  50596. 'ⲛ' => 'Ⲛ',
  50597. '�' => 'Ⲝ',
  50598. 'ⲟ' => 'Ⲟ',
  50599. 'ⲡ' => 'Ⲡ',
  50600. 'â²£' => 'â²¢',
  50601. 'ⲥ' => 'Ⲥ',
  50602. 'ⲧ' => 'Ⲧ',
  50603. 'ⲩ' => 'Ⲩ',
  50604. 'ⲫ' => 'Ⲫ',
  50605. 'ⲭ' => 'Ⲭ',
  50606. 'ⲯ' => 'Ⲯ',
  50607. 'â²±' => 'â²°',
  50608. 'â²³' => 'â²²',
  50609. 'â²µ' => 'â²´',
  50610. 'â²·' => 'â²¶',
  50611. 'ⲹ' => 'Ⲹ',
  50612. 'ⲻ' => 'Ⲻ',
  50613. 'â²½' => 'â²¼',
  50614. 'ⲿ' => 'Ⲿ',
  50615. '�' => 'Ⳁ',
  50616. 'ⳃ' => 'Ⳃ',
  50617. 'ⳅ' => 'Ⳅ',
  50618. 'ⳇ' => 'Ⳇ',
  50619. 'ⳉ' => 'Ⳉ',
  50620. 'ⳋ' => 'Ⳋ',
  50621. '�' => 'Ⳍ',
  50622. '�' => 'Ⳏ',
  50623. 'ⳑ' => '�',
  50624. 'ⳓ' => 'Ⳓ',
  50625. 'ⳕ' => 'Ⳕ',
  50626. 'â³—' => 'â³–',
  50627. 'ⳙ' => 'Ⳙ',
  50628. 'ⳛ' => 'Ⳛ',
  50629. '�' => 'Ⳝ',
  50630. 'ⳟ' => 'Ⳟ',
  50631. 'ⳡ' => 'Ⳡ',
  50632. 'â³£' => 'â³¢',
  50633. 'ⳬ' => 'Ⳬ',
  50634. 'â³®' => 'â³­',
  50635. 'â³³' => 'â³²',
  50636. 'â´€' => 'á‚ ',
  50637. 'â´�' => 'á‚¡',
  50638. 'â´‚' => 'á‚¢',
  50639. 'â´ƒ' => 'á‚£',
  50640. 'ⴄ' => 'Ⴄ',
  50641. 'â´…' => 'á‚¥',
  50642. 'ⴆ' => 'Ⴆ',
  50643. 'â´‡' => 'á‚§',
  50644. 'ⴈ' => 'Ⴈ',
  50645. 'â´‰' => 'á‚©',
  50646. 'ⴊ' => 'Ⴊ',
  50647. 'â´‹' => 'á‚«',
  50648. 'ⴌ' => 'Ⴌ',
  50649. 'â´�' => 'á‚­',
  50650. 'â´Ž' => 'á‚®',
  50651. '�' => 'Ⴏ',
  50652. 'â´�' => 'á‚°',
  50653. 'ⴑ' => 'Ⴑ',
  50654. 'ⴒ' => 'Ⴒ',
  50655. 'ⴓ' => 'Ⴓ',
  50656. 'â´”' => 'á‚´',
  50657. 'ⴕ' => 'Ⴕ',
  50658. 'â´–' => 'á‚¶',
  50659. 'â´—' => 'á‚·',
  50660. 'ⴘ' => 'Ⴘ',
  50661. 'ⴙ' => 'Ⴙ',
  50662. 'ⴚ' => 'Ⴚ',
  50663. 'â´›' => 'á‚»',
  50664. 'ⴜ' => 'Ⴜ',
  50665. '�' => 'Ⴝ',
  50666. 'ⴞ' => 'Ⴞ',
  50667. 'â´Ÿ' => 'á‚¿',
  50668. 'ⴠ' => 'Ⴠ',
  50669. 'ⴡ' => '�',
  50670. 'ⴢ' => 'Ⴢ',
  50671. 'ⴣ' => 'Ⴣ',
  50672. 'ⴤ' => 'Ⴤ',
  50673. 'ⴥ' => 'Ⴥ',
  50674. 'ⴧ' => 'Ⴧ',
  50675. 'ⴭ' => '�',
  50676. '�' => 'Ꙁ',
  50677. 'ꙃ' => 'Ꙃ',
  50678. 'ꙅ' => 'Ꙅ',
  50679. 'ꙇ' => 'Ꙇ',
  50680. 'ꙉ' => 'Ꙉ',
  50681. 'ꙋ' => 'Ꙋ',
  50682. '�' => 'Ꙍ',
  50683. '�' => 'Ꙏ',
  50684. 'ꙑ' => '�',
  50685. 'ꙓ' => 'Ꙓ',
  50686. 'ꙕ' => 'Ꙕ',
  50687. 'ê™—' => 'ê™–',
  50688. 'ꙙ' => 'Ꙙ',
  50689. 'ꙛ' => 'Ꙛ',
  50690. '�' => 'Ꙝ',
  50691. 'ꙟ' => 'Ꙟ',
  50692. 'ꙡ' => 'Ꙡ',
  50693. 'ꙣ' => 'Ꙣ',
  50694. 'ꙥ' => 'Ꙥ',
  50695. 'ꙧ' => 'Ꙧ',
  50696. 'ꙩ' => 'Ꙩ',
  50697. 'ꙫ' => 'Ꙫ',
  50698. 'ꙭ' => 'Ꙭ',
  50699. '�' => 'Ꚁ',
  50700. 'ꚃ' => 'Ꚃ',
  50701. 'êš…' => 'êš„',
  50702. 'ꚇ' => 'Ꚇ',
  50703. 'ꚉ' => 'Ꚉ',
  50704. 'ꚋ' => 'Ꚋ',
  50705. '�' => 'Ꚍ',
  50706. '�' => 'Ꚏ',
  50707. 'ꚑ' => '�',
  50708. 'êš“' => 'êš’',
  50709. 'êš•' => 'êš”',
  50710. 'êš—' => 'êš–',
  50711. 'ꚙ' => 'Ꚙ',
  50712. 'êš›' => 'êšš',
  50713. 'ꜣ' => 'Ꜣ',
  50714. 'ꜥ' => 'Ꜥ',
  50715. 'ꜧ' => 'Ꜧ',
  50716. 'ꜩ' => 'Ꜩ',
  50717. 'ꜫ' => 'Ꜫ',
  50718. 'ꜭ' => 'Ꜭ',
  50719. 'ꜯ' => 'Ꜯ',
  50720. 'ꜳ' => 'Ꜳ',
  50721. 'ꜵ' => 'Ꜵ',
  50722. 'ꜷ' => 'Ꜷ',
  50723. 'ꜹ' => 'Ꜹ',
  50724. 'ꜻ' => 'Ꜻ',
  50725. 'ꜽ' => 'Ꜽ',
  50726. 'ꜿ' => 'Ꜿ',
  50727. '�' => '�',
  50728. '�' => '�',
  50729. '�' => '�',
  50730. '�' => '�',
  50731. '�' => '�',
  50732. '�' => '�',
  50733. '�' => '�',
  50734. '�' => '�',
  50735. '�' => '�',
  50736. '�' => '�',
  50737. '�' => '�',
  50738. '�' => '�',
  50739. '�' => '�',
  50740. '�' => '�',
  50741. '�' => '�',
  50742. '�' => '�',
  50743. '�' => '�',
  50744. '�' => '�',
  50745. '�' => '�',
  50746. '�' => '�',
  50747. '�' => '�',
  50748. '�' => '�',
  50749. '�' => '�',
  50750. '�' => '�',
  50751. '�' => '�',
  50752. '�' => '�',
  50753. '�' => '�',
  50754. '�' => 'Ꞁ',
  50755. 'ꞃ' => 'Ꞃ',
  50756. 'êž…' => 'êž„',
  50757. 'ꞇ' => 'Ꞇ',
  50758. 'ꞌ' => 'Ꞌ',
  50759. 'ꞑ' => '�',
  50760. 'êž“' => 'êž’',
  50761. 'ꞔ' => 'Ꞔ',
  50762. 'êž—' => 'êž–',
  50763. 'ꞙ' => 'Ꞙ',
  50764. 'êž›' => 'êžš',
  50765. '�' => 'Ꞝ',
  50766. 'ꞟ' => 'Ꞟ',
  50767. 'êž¡' => 'êž ',
  50768. 'ꞣ' => 'Ꞣ',
  50769. 'ꞥ' => 'Ꞥ',
  50770. 'ꞧ' => 'Ꞧ',
  50771. 'ꞩ' => 'Ꞩ',
  50772. 'êžµ' => 'êž´',
  50773. 'êž·' => 'êž¶',
  50774. 'ꞹ' => 'Ꞹ',
  50775. 'ꞻ' => 'Ꞻ',
  50776. 'êž½' => 'êž¼',
  50777. 'êž¿' => 'êž¾',
  50778. 'ꟃ' => 'Ꟃ',
  50779. 'ꟈ' => 'Ꟈ',
  50780. 'ꟊ' => 'Ꟊ',
  50781. 'ꟶ' => 'Ꟶ',
  50782. 'ê­“' => 'êž³',
  50783. 'ꭰ' => 'Ꭰ',
  50784. 'ꭱ' => 'Ꭱ',
  50785. 'ꭲ' => 'Ꭲ',
  50786. 'ꭳ' => 'Ꭳ',
  50787. 'ꭴ' => 'Ꭴ',
  50788. 'ꭵ' => 'Ꭵ',
  50789. 'ꭶ' => 'Ꭶ',
  50790. 'ꭷ' => 'Ꭷ',
  50791. 'ꭸ' => 'Ꭸ',
  50792. 'ꭹ' => 'Ꭹ',
  50793. 'ꭺ' => 'Ꭺ',
  50794. 'ꭻ' => 'Ꭻ',
  50795. 'ꭼ' => 'Ꭼ',
  50796. 'ꭽ' => 'Ꭽ',
  50797. 'ꭾ' => 'Ꭾ',
  50798. 'ꭿ' => 'Ꭿ',
  50799. 'ꮀ' => 'Ꮀ',
  50800. '�' => 'Ꮁ',
  50801. 'ꮂ' => 'Ꮂ',
  50802. 'ꮃ' => 'Ꮃ',
  50803. 'ꮄ' => 'Ꮄ',
  50804. 'ꮅ' => 'Ꮅ',
  50805. 'ꮆ' => 'Ꮆ',
  50806. 'ꮇ' => 'Ꮇ',
  50807. 'ꮈ' => 'Ꮈ',
  50808. 'ꮉ' => 'Ꮉ',
  50809. 'ꮊ' => 'Ꮊ',
  50810. 'ꮋ' => 'Ꮋ',
  50811. 'ꮌ' => 'Ꮌ',
  50812. '�' => 'Ꮍ',
  50813. 'ꮎ' => 'Ꮎ',
  50814. '�' => 'Ꮏ',
  50815. '�' => '�',
  50816. 'ꮑ' => '�',
  50817. 'ꮒ' => '�',
  50818. 'ꮓ' => '�',
  50819. 'ꮔ' => '�',
  50820. 'ꮕ' => '�',
  50821. 'ꮖ' => '�',
  50822. 'ꮗ' => '�',
  50823. 'ꮘ' => '�',
  50824. 'ꮙ' => '�',
  50825. 'ꮚ' => '�',
  50826. 'ꮛ' => '�',
  50827. 'ꮜ' => '�',
  50828. '�' => '�',
  50829. 'ꮞ' => '�',
  50830. 'ꮟ' => '�',
  50831. 'ꮠ' => '�',
  50832. 'ꮡ' => '�',
  50833. 'ꮢ' => '�',
  50834. 'ꮣ' => '�',
  50835. 'ꮤ' => '�',
  50836. 'ꮥ' => '�',
  50837. 'ꮦ' => '�',
  50838. 'ꮧ' => '�',
  50839. 'ꮨ' => '�',
  50840. 'ꮩ' => '�',
  50841. 'ꮪ' => '�',
  50842. 'ꮫ' => '�',
  50843. 'ꮬ' => '�',
  50844. 'ꮭ' => '�',
  50845. 'ꮮ' => '�',
  50846. 'ꮯ' => '�',
  50847. 'ꮰ' => '�',
  50848. 'ꮱ' => '�',
  50849. 'ꮲ' => '�',
  50850. 'ꮳ' => '�',
  50851. 'ꮴ' => '�',
  50852. 'ꮵ' => '�',
  50853. 'ꮶ' => '�',
  50854. 'ꮷ' => '�',
  50855. 'ꮸ' => '�',
  50856. 'ꮹ' => '�',
  50857. 'ꮺ' => '�',
  50858. 'ꮻ' => '�',
  50859. 'ꮼ' => '�',
  50860. 'ꮽ' => '�',
  50861. 'ꮾ' => '�',
  50862. 'ꮿ' => '�',
  50863. '�' => 'A',
  50864. 'b' => 'B',
  50865. 'c' => 'C',
  50866. 'd' => 'D',
  50867. 'ï½…' => 'ï¼¥',
  50868. 'f' => 'F',
  50869. 'g' => 'G',
  50870. 'h' => 'H',
  50871. 'i' => 'I',
  50872. 'j' => 'J',
  50873. 'k' => 'K',
  50874. 'l' => 'L',
  50875. '�' => 'M',
  50876. 'n' => 'N',
  50877. '�' => 'O',
  50878. '�' => 'P',
  50879. 'q' => 'Q',
  50880. 'ï½’' => 'ï¼²',
  50881. 's' => 'S',
  50882. 'ï½”' => 'ï¼´',
  50883. 'u' => 'U',
  50884. 'ï½–' => 'ï¼¶',
  50885. 'ï½—' => 'ï¼·',
  50886. 'x' => 'X',
  50887. 'ï½™' => 'ï¼¹',
  50888. 'z' => 'Z',
  50889. '�' => '�',
  50890. '�' => '�',
  50891. '�' => '�',
  50892. '�' => '�',
  50893. '�' => '�',
  50894. '�' => '�',
  50895. '�' => '�',
  50896. '�' => '�',
  50897. '�' => '�',
  50898. '�' => '�',
  50899. '�' => '�',
  50900. '�' => '�',
  50901. '�' => '�',
  50902. '�' => '�',
  50903. '�' => '�',
  50904. '�' => '�',
  50905. '�' => '�',
  50906. '�' => '�',
  50907. '�' => '�',
  50908. '�' => '�',
  50909. '�' => '�',
  50910. '�' => '�',
  50911. '�' => '�',
  50912. '�' => '�',
  50913. '�' => '�',
  50914. '�' => '�',
  50915. '�' => '�',
  50916. '�' => '�',
  50917. '�' => '�',
  50918. '�' => '�',
  50919. '�' => '�',
  50920. '�' => '�',
  50921. '�' => '�',
  50922. '�' => '�',
  50923. '�' => '�',
  50924. '�' => '�',
  50925. '�' => '�',
  50926. '�' => '�',
  50927. '�' => '�',
  50928. '�' => '�',
  50929. '�' => '�',
  50930. '�' => '�',
  50931. '�' => '�',
  50932. '�' => '�',
  50933. '�' => '�',
  50934. '�' => '�',
  50935. '�' => '�',
  50936. '�' => '�',
  50937. '�' => '�',
  50938. '�' => '�',
  50939. '�' => '�',
  50940. '�' => '�',
  50941. '�' => '�',
  50942. '�' => '�',
  50943. '�' => '�',
  50944. '�' => '�',
  50945. '�' => '�',
  50946. '�' => '�',
  50947. '�' => '�',
  50948. '�' => '�',
  50949. '�' => '�',
  50950. '�' => '�',
  50951. '�' => '�',
  50952. '�' => '�',
  50953. '�' => '�',
  50954. '�' => '�',
  50955. '�' => '�',
  50956. '�' => '�',
  50957. '�' => '�',
  50958. '�' => '�',
  50959. '�' => '�',
  50960. '�' => '�',
  50961. '�' => '�',
  50962. '�' => '�',
  50963. '�' => '�',
  50964. '�' => '�',
  50965. '�' => '�',
  50966. '�' => '�',
  50967. '�' => '�',
  50968. '�' => '�',
  50969. '�' => '�',
  50970. '�' => '�',
  50971. '�' => '�',
  50972. '�' => '�',
  50973. '�' => '�',
  50974. '�' => '�',
  50975. '�' => '�',
  50976. '�' => '�',
  50977. '�' => '�',
  50978. '�' => '�',
  50979. '�' => '�',
  50980. '�' => '�',
  50981. '�' => '�',
  50982. '�' => '�',
  50983. '�' => '�',
  50984. '�' => '�',
  50985. '�' => '�',
  50986. '�' => '�',
  50987. '�' => '�',
  50988. '�' => '�',
  50989. '�' => '�',
  50990. '�' => '�',
  50991. '�' => '�',
  50992. '�' => '�',
  50993. '�' => '�',
  50994. '�' => '�',
  50995. '�' => '�',
  50996. '�' => '�',
  50997. '�' => '�',
  50998. '�' => '�',
  50999. '�' => '�',
  51000. '�' => '�',
  51001. '�' => '�',
  51002. '�' => '�',
  51003. '�' => '�',
  51004. '�' => '�',
  51005. '�' => '�',
  51006. '�' => '�',
  51007. '�' => '�',
  51008. '�' => '�',
  51009. '�' => '�',
  51010. '�' => '�',
  51011. '�' => '�',
  51012. '�' => '�',
  51013. '�' => '�',
  51014. '�' => '�',
  51015. '�' => '�',
  51016. 'ð‘£€' => 'ð‘¢ ',
  51017. '�' => '𑢡',
  51018. '𑣂' => '𑢢',
  51019. '𑣃' => '𑢣',
  51020. '𑣄' => '𑢤',
  51021. 'ð‘£…' => 'ð‘¢¥',
  51022. '𑣆' => '𑢦',
  51023. '𑣇' => '𑢧',
  51024. '𑣈' => '𑢨',
  51025. '𑣉' => '𑢩',
  51026. '𑣊' => '𑢪',
  51027. '𑣋' => '𑢫',
  51028. '𑣌' => '𑢬',
  51029. '�' => '𑢭',
  51030. '𑣎' => '𑢮',
  51031. '�' => '𑢯',
  51032. '�' => '𑢰',
  51033. '𑣑' => '𑢱',
  51034. 'ð‘£’' => 'ð‘¢²',
  51035. '𑣓' => '𑢳',
  51036. 'ð‘£”' => 'ð‘¢´',
  51037. '𑣕' => '𑢵',
  51038. 'ð‘£–' => 'ð‘¢¶',
  51039. 'ð‘£—' => 'ð‘¢·',
  51040. '𑣘' => '𑢸',
  51041. 'ð‘£™' => 'ð‘¢¹',
  51042. '𑣚' => '𑢺',
  51043. 'ð‘£›' => 'ð‘¢»',
  51044. '𑣜' => '𑢼',
  51045. '�' => '𑢽',
  51046. '𑣞' => '𑢾',
  51047. '𑣟' => '𑢿',
  51048. 'ð–¹ ' => 'ð–¹€',
  51049. '𖹡' => '�',
  51050. '𖹢' => '𖹂',
  51051. '𖹣' => '𖹃',
  51052. '𖹤' => '𖹄',
  51053. 'ð–¹¥' => 'ð–¹…',
  51054. '𖹦' => '𖹆',
  51055. '𖹧' => '𖹇',
  51056. '𖹨' => '𖹈',
  51057. '𖹩' => '𖹉',
  51058. '𖹪' => '𖹊',
  51059. '𖹫' => '𖹋',
  51060. '𖹬' => '𖹌',
  51061. '𖹭' => '�',
  51062. '𖹮' => '𖹎',
  51063. '𖹯' => '�',
  51064. '𖹰' => '�',
  51065. '𖹱' => '𖹑',
  51066. 'ð–¹²' => 'ð–¹’',
  51067. '𖹳' => '𖹓',
  51068. 'ð–¹´' => 'ð–¹”',
  51069. '𖹵' => '𖹕',
  51070. 'ð–¹¶' => 'ð–¹–',
  51071. 'ð–¹·' => 'ð–¹—',
  51072. '𖹸' => '𖹘',
  51073. 'ð–¹¹' => 'ð–¹™',
  51074. '𖹺' => '𖹚',
  51075. 'ð–¹»' => 'ð–¹›',
  51076. '𖹼' => '𖹜',
  51077. '𖹽' => '�',
  51078. '𖹾' => '𖹞',
  51079. '𖹿' => '𖹟',
  51080. '𞤢' => '𞤀',
  51081. '𞤣' => '�',
  51082. '𞤤' => '𞤂',
  51083. '𞤥' => '𞤃',
  51084. '𞤦' => '𞤄',
  51085. '𞤧' => '𞤅',
  51086. '𞤨' => '𞤆',
  51087. '𞤩' => '𞤇',
  51088. '𞤪' => '𞤈',
  51089. '𞤫' => '𞤉',
  51090. '𞤬' => '𞤊',
  51091. '𞤭' => '𞤋',
  51092. '𞤮' => '𞤌',
  51093. '𞤯' => '�',
  51094. '𞤰' => '𞤎',
  51095. '𞤱' => '�',
  51096. '𞤲' => '�',
  51097. '𞤳' => '𞤑',
  51098. '𞤴' => '𞤒',
  51099. '𞤵' => '𞤓',
  51100. '𞤶' => '𞤔',
  51101. '𞤷' => '𞤕',
  51102. '𞤸' => '𞤖',
  51103. '𞤹' => '𞤗',
  51104. '𞤺' => '𞤘',
  51105. '𞤻' => '𞤙',
  51106. '𞤼' => '𞤚',
  51107. '𞤽' => '𞤛',
  51108. '𞤾' => '𞤜',
  51109. '𞤿' => '�',
  51110. '𞥀' => '𞤞',
  51111. '�' => '𞤟',
  51112. '𞥂' => '𞤠',
  51113. '𞥃' => '𞤡',
  51114. );
  51115. <?php
  51116. use Symfony\Polyfill\Mbstring as p;
  51117. if (!function_exists('mb_convert_encoding')) {
  51118. function mb_convert_encoding($s, $to, $from = null) { return p\Mbstring::mb_convert_encoding($s, $to, $from); }
  51119. }
  51120. if (!function_exists('mb_decode_mimeheader')) {
  51121. function mb_decode_mimeheader($s) { return p\Mbstring::mb_decode_mimeheader($s); }
  51122. }
  51123. if (!function_exists('mb_encode_mimeheader')) {
  51124. function mb_encode_mimeheader($s, $charset = null, $transferEnc = null, $lf = null, $indent = null) { return p\Mbstring::mb_encode_mimeheader($s, $charset, $transferEnc, $lf, $indent); }
  51125. }
  51126. if (!function_exists('mb_decode_numericentity')) {
  51127. function mb_decode_numericentity($s, $convmap, $enc = null) { return p\Mbstring::mb_decode_numericentity($s, $convmap, $enc); }
  51128. }
  51129. if (!function_exists('mb_encode_numericentity')) {
  51130. function mb_encode_numericentity($s, $convmap, $enc = null, $is_hex = false) { return p\Mbstring::mb_encode_numericentity($s, $convmap, $enc, $is_hex); }
  51131. }
  51132. if (!function_exists('mb_convert_case')) {
  51133. function mb_convert_case($s, $mode, $enc = null) { return p\Mbstring::mb_convert_case($s, $mode, $enc); }
  51134. }
  51135. if (!function_exists('mb_internal_encoding')) {
  51136. function mb_internal_encoding($enc = null) { return p\Mbstring::mb_internal_encoding($enc); }
  51137. }
  51138. if (!function_exists('mb_language')) {
  51139. function mb_language($lang = null) { return p\Mbstring::mb_language($lang); }
  51140. }
  51141. if (!function_exists('mb_list_encodings')) {
  51142. function mb_list_encodings() { return p\Mbstring::mb_list_encodings(); }
  51143. }
  51144. if (!function_exists('mb_encoding_aliases')) {
  51145. function mb_encoding_aliases($encoding) { return p\Mbstring::mb_encoding_aliases($encoding); }
  51146. }
  51147. if (!function_exists('mb_check_encoding')) {
  51148. function mb_check_encoding($var = null, $encoding = null) { return p\Mbstring::mb_check_encoding($var, $encoding); }
  51149. }
  51150. if (!function_exists('mb_detect_encoding')) {
  51151. function mb_detect_encoding($str, $encodingList = null, $strict = false) { return p\Mbstring::mb_detect_encoding($str, $encodingList, $strict); }
  51152. }
  51153. if (!function_exists('mb_detect_order')) {
  51154. function mb_detect_order($encodingList = null) { return p\Mbstring::mb_detect_order($encodingList); }
  51155. }
  51156. if (!function_exists('mb_parse_str')) {
  51157. function mb_parse_str($s, &$result = array()) { parse_str($s, $result); }
  51158. }
  51159. if (!function_exists('mb_strlen')) {
  51160. function mb_strlen($s, $enc = null) { return p\Mbstring::mb_strlen($s, $enc); }
  51161. }
  51162. if (!function_exists('mb_strpos')) {
  51163. function mb_strpos($s, $needle, $offset = 0, $enc = null) { return p\Mbstring::mb_strpos($s, $needle, $offset, $enc); }
  51164. }
  51165. if (!function_exists('mb_strtolower')) {
  51166. function mb_strtolower($s, $enc = null) { return p\Mbstring::mb_strtolower($s, $enc); }
  51167. }
  51168. if (!function_exists('mb_strtoupper')) {
  51169. function mb_strtoupper($s, $enc = null) { return p\Mbstring::mb_strtoupper($s, $enc); }
  51170. }
  51171. if (!function_exists('mb_substitute_character')) {
  51172. function mb_substitute_character($char = null) { return p\Mbstring::mb_substitute_character($char); }
  51173. }
  51174. if (!function_exists('mb_substr')) {
  51175. function mb_substr($s, $start, $length = 2147483647, $enc = null) { return p\Mbstring::mb_substr($s, $start, $length, $enc); }
  51176. }
  51177. if (!function_exists('mb_stripos')) {
  51178. function mb_stripos($s, $needle, $offset = 0, $enc = null) { return p\Mbstring::mb_stripos($s, $needle, $offset, $enc); }
  51179. }
  51180. if (!function_exists('mb_stristr')) {
  51181. function mb_stristr($s, $needle, $part = false, $enc = null) { return p\Mbstring::mb_stristr($s, $needle, $part, $enc); }
  51182. }
  51183. if (!function_exists('mb_strrchr')) {
  51184. function mb_strrchr($s, $needle, $part = false, $enc = null) { return p\Mbstring::mb_strrchr($s, $needle, $part, $enc); }
  51185. }
  51186. if (!function_exists('mb_strrichr')) {
  51187. function mb_strrichr($s, $needle, $part = false, $enc = null) { return p\Mbstring::mb_strrichr($s, $needle, $part, $enc); }
  51188. }
  51189. if (!function_exists('mb_strripos')) {
  51190. function mb_strripos($s, $needle, $offset = 0, $enc = null) { return p\Mbstring::mb_strripos($s, $needle, $offset, $enc); }
  51191. }
  51192. if (!function_exists('mb_strrpos')) {
  51193. function mb_strrpos($s, $needle, $offset = 0, $enc = null) { return p\Mbstring::mb_strrpos($s, $needle, $offset, $enc); }
  51194. }
  51195. if (!function_exists('mb_strstr')) {
  51196. function mb_strstr($s, $needle, $part = false, $enc = null) { return p\Mbstring::mb_strstr($s, $needle, $part, $enc); }
  51197. }
  51198. if (!function_exists('mb_get_info')) {
  51199. function mb_get_info($type = 'all') { return p\Mbstring::mb_get_info($type); }
  51200. }
  51201. if (!function_exists('mb_http_output')) {
  51202. function mb_http_output($enc = null) { return p\Mbstring::mb_http_output($enc); }
  51203. }
  51204. if (!function_exists('mb_strwidth')) {
  51205. function mb_strwidth($s, $enc = null) { return p\Mbstring::mb_strwidth($s, $enc); }
  51206. }
  51207. if (!function_exists('mb_substr_count')) {
  51208. function mb_substr_count($haystack, $needle, $enc = null) { return p\Mbstring::mb_substr_count($haystack, $needle, $enc); }
  51209. }
  51210. if (!function_exists('mb_output_handler')) {
  51211. function mb_output_handler($contents, $status) { return p\Mbstring::mb_output_handler($contents, $status); }
  51212. }
  51213. if (!function_exists('mb_http_input')) {
  51214. function mb_http_input($type = '') { return p\Mbstring::mb_http_input($type); }
  51215. }
  51216. if (!function_exists('mb_convert_variables')) {
  51217. 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); }
  51218. }
  51219. if (!function_exists('mb_ord')) {
  51220. function mb_ord($s, $enc = null) { return p\Mbstring::mb_ord($s, $enc); }
  51221. }
  51222. if (!function_exists('mb_chr')) {
  51223. function mb_chr($code, $enc = null) { return p\Mbstring::mb_chr($code, $enc); }
  51224. }
  51225. if (!function_exists('mb_scrub')) {
  51226. function mb_scrub($s, $enc = null) { $enc = null === $enc ? mb_internal_encoding() : $enc; return mb_convert_encoding($s, $enc, $enc); }
  51227. }
  51228. if (!function_exists('mb_str_split')) {
  51229. function mb_str_split($string, $split_length = 1, $encoding = null) { return p\Mbstring::mb_str_split($string, $split_length, $encoding); }
  51230. }
  51231. if (extension_loaded('mbstring')) {
  51232. return;
  51233. }
  51234. if (!defined('MB_CASE_UPPER')) {
  51235. define('MB_CASE_UPPER', 0);
  51236. }
  51237. if (!defined('MB_CASE_LOWER')) {
  51238. define('MB_CASE_LOWER', 1);
  51239. }
  51240. if (!defined('MB_CASE_TITLE')) {
  51241. define('MB_CASE_TITLE', 2);
  51242. }
  51243. <?php
  51244. namespace Symfony\Component\Process\Exception;
  51245. interface ExceptionInterface
  51246. {
  51247. }
  51248. <?php
  51249. namespace Symfony\Component\Process\Exception;
  51250. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  51251. {
  51252. }
  51253. <?php
  51254. namespace Symfony\Component\Process\Exception;
  51255. class LogicException extends \LogicException implements ExceptionInterface
  51256. {
  51257. }
  51258. <?php
  51259. namespace Symfony\Component\Process\Exception;
  51260. use Symfony\Component\Process\Process;
  51261. class ProcessFailedException extends RuntimeException
  51262. {
  51263. private $process;
  51264. public function __construct(Process $process)
  51265. {
  51266. if ($process->isSuccessful()) {
  51267. throw new InvalidArgumentException('Expected a failed process, but the given process was successful.');
  51268. }
  51269. $error = sprintf('The command "%s" failed.'."\n\nExit Code: %s(%s)\n\nWorking directory: %s",
  51270. $process->getCommandLine(),
  51271. $process->getExitCode(),
  51272. $process->getExitCodeText(),
  51273. $process->getWorkingDirectory()
  51274. );
  51275. if (!$process->isOutputDisabled()) {
  51276. $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s",
  51277. $process->getOutput(),
  51278. $process->getErrorOutput()
  51279. );
  51280. }
  51281. parent::__construct($error);
  51282. $this->process = $process;
  51283. }
  51284. public function getProcess()
  51285. {
  51286. return $this->process;
  51287. }
  51288. }
  51289. <?php
  51290. namespace Symfony\Component\Process\Exception;
  51291. use Symfony\Component\Process\Process;
  51292. class ProcessTimedOutException extends RuntimeException
  51293. {
  51294. const TYPE_GENERAL = 1;
  51295. const TYPE_IDLE = 2;
  51296. private $process;
  51297. private $timeoutType;
  51298. public function __construct(Process $process, $timeoutType)
  51299. {
  51300. $this->process = $process;
  51301. $this->timeoutType = $timeoutType;
  51302. parent::__construct(sprintf(
  51303. 'The process "%s" exceeded the timeout of %s seconds.',
  51304. $process->getCommandLine(),
  51305. $this->getExceededTimeout()
  51306. ));
  51307. }
  51308. public function getProcess()
  51309. {
  51310. return $this->process;
  51311. }
  51312. public function isGeneralTimeout()
  51313. {
  51314. return self::TYPE_GENERAL === $this->timeoutType;
  51315. }
  51316. public function isIdleTimeout()
  51317. {
  51318. return self::TYPE_IDLE === $this->timeoutType;
  51319. }
  51320. public function getExceededTimeout()
  51321. {
  51322. switch ($this->timeoutType) {
  51323. case self::TYPE_GENERAL:
  51324. return $this->process->getTimeout();
  51325. case self::TYPE_IDLE:
  51326. return $this->process->getIdleTimeout();
  51327. default:
  51328. throw new \LogicException(sprintf('Unknown timeout type "%d".', $this->timeoutType));
  51329. }
  51330. }
  51331. }
  51332. <?php
  51333. namespace Symfony\Component\Process\Exception;
  51334. class RuntimeException extends \RuntimeException implements ExceptionInterface
  51335. {
  51336. }
  51337. <?php
  51338. namespace Symfony\Component\Process;
  51339. class ExecutableFinder
  51340. {
  51341. private $suffixes = array('.exe', '.bat', '.cmd', '.com');
  51342. public function setSuffixes(array $suffixes)
  51343. {
  51344. $this->suffixes = $suffixes;
  51345. }
  51346. public function addSuffix($suffix)
  51347. {
  51348. $this->suffixes[] = $suffix;
  51349. }
  51350. public function find($name, $default = null, array $extraDirs = array())
  51351. {
  51352. if (ini_get('open_basedir')) {
  51353. $searchPath = explode(PATH_SEPARATOR, ini_get('open_basedir'));
  51354. $dirs = array();
  51355. foreach ($searchPath as $path) {
  51356. if (@is_dir($path)) {
  51357. $dirs[] = $path;
  51358. } else {
  51359. if (basename($path) == $name && @is_executable($path)) {
  51360. return $path;
  51361. }
  51362. }
  51363. }
  51364. } else {
  51365. $dirs = array_merge(
  51366. explode(PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')),
  51367. $extraDirs
  51368. );
  51369. }
  51370. $suffixes = array('');
  51371. if ('\\' === \DIRECTORY_SEPARATOR) {
  51372. $pathExt = getenv('PATHEXT');
  51373. $suffixes = array_merge($pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes, $suffixes);
  51374. }
  51375. foreach ($suffixes as $suffix) {
  51376. foreach ($dirs as $dir) {
  51377. if (@is_file($file = $dir.\DIRECTORY_SEPARATOR.$name.$suffix) && ('\\' === \DIRECTORY_SEPARATOR || @is_executable($file))) {
  51378. return $file;
  51379. }
  51380. }
  51381. }
  51382. return $default;
  51383. }
  51384. }
  51385. Copyright (c) 2004-2018 Fabien Potencier
  51386. Permission is hereby granted, free of charge, to any person obtaining a copy
  51387. of this software and associated documentation files (the "Software"), to deal
  51388. in the Software without restriction, including without limitation the rights
  51389. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  51390. copies of the Software, and to permit persons to whom the Software is furnished
  51391. to do so, subject to the following conditions:
  51392. The above copyright notice and this permission notice shall be included in all
  51393. copies or substantial portions of the Software.
  51394. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  51395. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  51396. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  51397. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  51398. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  51399. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  51400. THE SOFTWARE.
  51401. <?php
  51402. namespace Symfony\Component\Process;
  51403. class PhpExecutableFinder
  51404. {
  51405. private $executableFinder;
  51406. public function __construct()
  51407. {
  51408. $this->executableFinder = new ExecutableFinder();
  51409. }
  51410. public function find($includeArgs = true)
  51411. {
  51412. $args = $this->findArguments();
  51413. $args = $includeArgs && $args ? ' '.implode(' ', $args) : '';
  51414. if (\defined('HHVM_VERSION')) {
  51415. return (getenv('PHP_BINARY') ?: PHP_BINARY).$args;
  51416. }
  51417. if (\defined('PHP_BINARY') && PHP_BINARY && \in_array(\PHP_SAPI, array('cli', 'cli-server', 'phpdbg'), true)) {
  51418. return PHP_BINARY.$args;
  51419. }
  51420. if ($php = getenv('PHP_PATH')) {
  51421. if (!@is_executable($php)) {
  51422. return false;
  51423. }
  51424. return $php;
  51425. }
  51426. if ($php = getenv('PHP_PEAR_PHP_BIN')) {
  51427. if (@is_executable($php)) {
  51428. return $php;
  51429. }
  51430. }
  51431. if (@is_executable($php = PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php'))) {
  51432. return $php;
  51433. }
  51434. $dirs = array(PHP_BINDIR);
  51435. if ('\\' === \DIRECTORY_SEPARATOR) {
  51436. $dirs[] = 'C:\xampp\php\\';
  51437. }
  51438. return $this->executableFinder->find('php', false, $dirs);
  51439. }
  51440. public function findArguments()
  51441. {
  51442. $arguments = array();
  51443. if (\defined('HHVM_VERSION')) {
  51444. $arguments[] = '--php';
  51445. } elseif ('phpdbg' === \PHP_SAPI) {
  51446. $arguments[] = '-qrr';
  51447. }
  51448. return $arguments;
  51449. }
  51450. }
  51451. <?php
  51452. namespace Symfony\Component\Process;
  51453. use Symfony\Component\Process\Exception\RuntimeException;
  51454. class PhpProcess extends Process
  51455. {
  51456. public function __construct($script, $cwd = null, array $env = null, $timeout = 60, array $options = array())
  51457. {
  51458. $executableFinder = new PhpExecutableFinder();
  51459. if (false === $php = $executableFinder->find()) {
  51460. $php = null;
  51461. }
  51462. if ('phpdbg' === \PHP_SAPI) {
  51463. $file = tempnam(sys_get_temp_dir(), 'dbg');
  51464. file_put_contents($file, $script);
  51465. register_shutdown_function('unlink', $file);
  51466. $php .= ' '.ProcessUtils::escapeArgument($file);
  51467. $script = null;
  51468. }
  51469. if ('\\' !== \DIRECTORY_SEPARATOR && null !== $php) {
  51470. $php = 'exec '.$php;
  51471. }
  51472. parent::__construct($php, $cwd, $env, $script, $timeout, $options);
  51473. }
  51474. public function setPhpBinary($php)
  51475. {
  51476. $this->setCommandLine($php);
  51477. }
  51478. public function start($callback = null)
  51479. {
  51480. if (null === $this->getCommandLine()) {
  51481. throw new RuntimeException('Unable to find the PHP executable.');
  51482. }
  51483. parent::start($callback);
  51484. }
  51485. }
  51486. <?php
  51487. namespace Symfony\Component\Process\Pipes;
  51488. abstract class AbstractPipes implements PipesInterface
  51489. {
  51490. public $pipes = array();
  51491. private $inputBuffer = '';
  51492. private $input;
  51493. private $blocked = true;
  51494. private $lastError;
  51495. public function __construct($input)
  51496. {
  51497. if (\is_resource($input)) {
  51498. $this->input = $input;
  51499. } elseif (\is_string($input)) {
  51500. $this->inputBuffer = $input;
  51501. } else {
  51502. $this->inputBuffer = (string) $input;
  51503. }
  51504. }
  51505. public function close()
  51506. {
  51507. foreach ($this->pipes as $pipe) {
  51508. fclose($pipe);
  51509. }
  51510. $this->pipes = array();
  51511. }
  51512. protected function hasSystemCallBeenInterrupted()
  51513. {
  51514. $lastError = $this->lastError;
  51515. $this->lastError = null;
  51516. return null !== $lastError && false !== stripos($lastError, 'interrupted system call');
  51517. }
  51518. protected function unblock()
  51519. {
  51520. if (!$this->blocked) {
  51521. return;
  51522. }
  51523. foreach ($this->pipes as $pipe) {
  51524. stream_set_blocking($pipe, 0);
  51525. }
  51526. if (null !== $this->input) {
  51527. stream_set_blocking($this->input, 0);
  51528. }
  51529. $this->blocked = false;
  51530. }
  51531. protected function write()
  51532. {
  51533. if (!isset($this->pipes[0])) {
  51534. return;
  51535. }
  51536. $input = $this->input;
  51537. $r = $e = array();
  51538. $w = array($this->pipes[0]);
  51539. if (false === @stream_select($r, $w, $e, 0, 0)) {
  51540. return;
  51541. }
  51542. foreach ($w as $stdin) {
  51543. if (isset($this->inputBuffer[0])) {
  51544. $written = fwrite($stdin, $this->inputBuffer);
  51545. $this->inputBuffer = substr($this->inputBuffer, $written);
  51546. if (isset($this->inputBuffer[0])) {
  51547. return array($this->pipes[0]);
  51548. }
  51549. }
  51550. if ($input) {
  51551. for (;;) {
  51552. $data = fread($input, self::CHUNK_SIZE);
  51553. if (!isset($data[0])) {
  51554. break;
  51555. }
  51556. $written = fwrite($stdin, $data);
  51557. $data = substr($data, $written);
  51558. if (isset($data[0])) {
  51559. $this->inputBuffer = $data;
  51560. return array($this->pipes[0]);
  51561. }
  51562. }
  51563. if (feof($input)) {
  51564. $this->input = null;
  51565. }
  51566. }
  51567. }
  51568. if (null === $this->input && !isset($this->inputBuffer[0])) {
  51569. fclose($this->pipes[0]);
  51570. unset($this->pipes[0]);
  51571. } elseif (!$w) {
  51572. return array($this->pipes[0]);
  51573. }
  51574. }
  51575. public function handleError($type, $msg)
  51576. {
  51577. $this->lastError = $msg;
  51578. }
  51579. }
  51580. <?php
  51581. namespace Symfony\Component\Process\Pipes;
  51582. interface PipesInterface
  51583. {
  51584. const CHUNK_SIZE = 16384;
  51585. public function getDescriptors();
  51586. public function getFiles();
  51587. public function readAndWrite($blocking, $close = false);
  51588. public function areOpen();
  51589. public function close();
  51590. }
  51591. <?php
  51592. namespace Symfony\Component\Process\Pipes;
  51593. use Symfony\Component\Process\Process;
  51594. class UnixPipes extends AbstractPipes
  51595. {
  51596. private $ttyMode;
  51597. private $ptyMode;
  51598. private $disableOutput;
  51599. public function __construct($ttyMode, $ptyMode, $input, $disableOutput)
  51600. {
  51601. $this->ttyMode = (bool) $ttyMode;
  51602. $this->ptyMode = (bool) $ptyMode;
  51603. $this->disableOutput = (bool) $disableOutput;
  51604. parent::__construct($input);
  51605. }
  51606. public function __destruct()
  51607. {
  51608. $this->close();
  51609. }
  51610. public function getDescriptors()
  51611. {
  51612. if ($this->disableOutput) {
  51613. $nullstream = fopen('/dev/null', 'c');
  51614. return array(
  51615. array('pipe', 'r'),
  51616. $nullstream,
  51617. $nullstream,
  51618. );
  51619. }
  51620. if ($this->ttyMode) {
  51621. return array(
  51622. array('file', '/dev/tty', 'r'),
  51623. array('file', '/dev/tty', 'w'),
  51624. array('file', '/dev/tty', 'w'),
  51625. );
  51626. }
  51627. if ($this->ptyMode && Process::isPtySupported()) {
  51628. return array(
  51629. array('pty'),
  51630. array('pty'),
  51631. array('pty'),
  51632. );
  51633. }
  51634. return array(
  51635. array('pipe', 'r'),
  51636. array('pipe', 'w'),
  51637. array('pipe', 'w'),
  51638. );
  51639. }
  51640. public function getFiles()
  51641. {
  51642. return array();
  51643. }
  51644. public function readAndWrite($blocking, $close = false)
  51645. {
  51646. $this->unblock();
  51647. $w = $this->write();
  51648. $read = $e = array();
  51649. $r = $this->pipes;
  51650. unset($r[0]);
  51651. set_error_handler(array($this, 'handleError'));
  51652. if (($r || $w) && false === stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1E6 : 0)) {
  51653. restore_error_handler();
  51654. if (!$this->hasSystemCallBeenInterrupted()) {
  51655. $this->pipes = array();
  51656. }
  51657. return $read;
  51658. }
  51659. restore_error_handler();
  51660. foreach ($r as $pipe) {
  51661. $read[$type = array_search($pipe, $this->pipes, true)] = '';
  51662. do {
  51663. $data = fread($pipe, self::CHUNK_SIZE);
  51664. $read[$type] .= $data;
  51665. } while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1])));
  51666. if (!isset($read[$type][0])) {
  51667. unset($read[$type]);
  51668. }
  51669. if ($close && feof($pipe)) {
  51670. fclose($pipe);
  51671. unset($this->pipes[$type]);
  51672. }
  51673. }
  51674. return $read;
  51675. }
  51676. public function areOpen()
  51677. {
  51678. return (bool) $this->pipes;
  51679. }
  51680. public static function create(Process $process, $input)
  51681. {
  51682. return new static($process->isTty(), $process->isPty(), $input, $process->isOutputDisabled());
  51683. }
  51684. }
  51685. <?php
  51686. namespace Symfony\Component\Process\Pipes;
  51687. use Symfony\Component\Process\Exception\RuntimeException;
  51688. use Symfony\Component\Process\Process;
  51689. class WindowsPipes extends AbstractPipes
  51690. {
  51691. private $files = array();
  51692. private $fileHandles = array();
  51693. private $lockHandles = array();
  51694. private $readBytes = array(
  51695. Process::STDOUT => 0,
  51696. Process::STDERR => 0,
  51697. );
  51698. private $disableOutput;
  51699. public function __construct($disableOutput, $input)
  51700. {
  51701. $this->disableOutput = (bool) $disableOutput;
  51702. if (!$this->disableOutput) {
  51703. $pipes = array(
  51704. Process::STDOUT => Process::OUT,
  51705. Process::STDERR => Process::ERR,
  51706. );
  51707. $tmpDir = sys_get_temp_dir();
  51708. $lastError = 'unknown reason';
  51709. set_error_handler(function ($type, $msg) use (&$lastError) { $lastError = $msg; });
  51710. for ($i = 0;; ++$i) {
  51711. foreach ($pipes as $pipe => $name) {
  51712. $file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name);
  51713. if (!$h = fopen($file.'.lock', 'w')) {
  51714. restore_error_handler();
  51715. throw new RuntimeException(sprintf('A temporary file could not be opened to write the process output: %s', $lastError));
  51716. }
  51717. if (!flock($h, LOCK_EX | LOCK_NB)) {
  51718. continue 2;
  51719. }
  51720. if (isset($this->lockHandles[$pipe])) {
  51721. flock($this->lockHandles[$pipe], LOCK_UN);
  51722. fclose($this->lockHandles[$pipe]);
  51723. }
  51724. $this->lockHandles[$pipe] = $h;
  51725. if (!fclose(fopen($file, 'w')) || !$h = fopen($file, 'r')) {
  51726. flock($this->lockHandles[$pipe], LOCK_UN);
  51727. fclose($this->lockHandles[$pipe]);
  51728. unset($this->lockHandles[$pipe]);
  51729. continue 2;
  51730. }
  51731. $this->fileHandles[$pipe] = $h;
  51732. $this->files[$pipe] = $file;
  51733. }
  51734. break;
  51735. }
  51736. restore_error_handler();
  51737. }
  51738. parent::__construct($input);
  51739. }
  51740. public function __destruct()
  51741. {
  51742. $this->close();
  51743. }
  51744. public function getDescriptors()
  51745. {
  51746. if ($this->disableOutput) {
  51747. $nullstream = fopen('NUL', 'c');
  51748. return array(
  51749. array('pipe', 'r'),
  51750. $nullstream,
  51751. $nullstream,
  51752. );
  51753. }
  51754. return array(
  51755. array('pipe', 'r'),
  51756. array('file', 'NUL', 'w'),
  51757. array('file', 'NUL', 'w'),
  51758. );
  51759. }
  51760. public function getFiles()
  51761. {
  51762. return $this->files;
  51763. }
  51764. public function readAndWrite($blocking, $close = false)
  51765. {
  51766. $this->unblock();
  51767. $w = $this->write();
  51768. $read = $r = $e = array();
  51769. if ($blocking) {
  51770. if ($w) {
  51771. @stream_select($r, $w, $e, 0, Process::TIMEOUT_PRECISION * 1E6);
  51772. } elseif ($this->fileHandles) {
  51773. usleep(Process::TIMEOUT_PRECISION * 1E6);
  51774. }
  51775. }
  51776. foreach ($this->fileHandles as $type => $fileHandle) {
  51777. $data = stream_get_contents($fileHandle, -1, $this->readBytes[$type]);
  51778. if (isset($data[0])) {
  51779. $this->readBytes[$type] += \strlen($data);
  51780. $read[$type] = $data;
  51781. }
  51782. if ($close) {
  51783. ftruncate($fileHandle, 0);
  51784. fclose($fileHandle);
  51785. flock($this->lockHandles[$type], LOCK_UN);
  51786. fclose($this->lockHandles[$type]);
  51787. unset($this->fileHandles[$type], $this->lockHandles[$type]);
  51788. }
  51789. }
  51790. return $read;
  51791. }
  51792. public function areOpen()
  51793. {
  51794. return $this->pipes && $this->fileHandles;
  51795. }
  51796. public function close()
  51797. {
  51798. parent::close();
  51799. foreach ($this->fileHandles as $type => $handle) {
  51800. ftruncate($handle, 0);
  51801. fclose($handle);
  51802. flock($this->lockHandles[$type], LOCK_UN);
  51803. fclose($this->lockHandles[$type]);
  51804. }
  51805. $this->fileHandles = $this->lockHandles = array();
  51806. }
  51807. public static function create(Process $process, $input)
  51808. {
  51809. return new static($process->isOutputDisabled(), $input);
  51810. }
  51811. }
  51812. <?php
  51813. namespace Symfony\Component\Process;
  51814. use Symfony\Component\Process\Exception\InvalidArgumentException;
  51815. use Symfony\Component\Process\Exception\LogicException;
  51816. use Symfony\Component\Process\Exception\ProcessFailedException;
  51817. use Symfony\Component\Process\Exception\ProcessTimedOutException;
  51818. use Symfony\Component\Process\Exception\RuntimeException;
  51819. use Symfony\Component\Process\Pipes\PipesInterface;
  51820. use Symfony\Component\Process\Pipes\UnixPipes;
  51821. use Symfony\Component\Process\Pipes\WindowsPipes;
  51822. class Process
  51823. {
  51824. const ERR = 'err';
  51825. const OUT = 'out';
  51826. const STATUS_READY = 'ready';
  51827. const STATUS_STARTED = 'started';
  51828. const STATUS_TERMINATED = 'terminated';
  51829. const STDIN = 0;
  51830. const STDOUT = 1;
  51831. const STDERR = 2;
  51832. const TIMEOUT_PRECISION = 0.2;
  51833. private $callback;
  51834. private $commandline;
  51835. private $cwd;
  51836. private $env;
  51837. private $input;
  51838. private $starttime;
  51839. private $lastOutputTime;
  51840. private $timeout;
  51841. private $idleTimeout;
  51842. private $options;
  51843. private $exitcode;
  51844. private $fallbackStatus = array();
  51845. private $processInformation;
  51846. private $outputDisabled = false;
  51847. private $stdout;
  51848. private $stderr;
  51849. private $enhanceWindowsCompatibility = true;
  51850. private $enhanceSigchildCompatibility;
  51851. private $process;
  51852. private $status = self::STATUS_READY;
  51853. private $incrementalOutputOffset = 0;
  51854. private $incrementalErrorOutputOffset = 0;
  51855. private $tty;
  51856. private $pty;
  51857. private $useFileHandles = false;
  51858. private $processPipes;
  51859. private $latestSignal;
  51860. private static $sigchild;
  51861. public static $exitCodes = array(
  51862. 0 => 'OK',
  51863. 1 => 'General error',
  51864. 2 => 'Misuse of shell builtins',
  51865. 126 => 'Invoked command cannot execute',
  51866. 127 => 'Command not found',
  51867. 128 => 'Invalid exit argument',
  51868. 129 => 'Hangup',
  51869. 130 => 'Interrupt',
  51870. 131 => 'Quit and dump core',
  51871. 132 => 'Illegal instruction',
  51872. 133 => 'Trace/breakpoint trap',
  51873. 134 => 'Process aborted',
  51874. 135 => 'Bus error: "access to undefined portion of memory object"',
  51875. 136 => 'Floating point exception: "erroneous arithmetic operation"',
  51876. 137 => 'Kill (terminate immediately)',
  51877. 138 => 'User-defined 1',
  51878. 139 => 'Segmentation violation',
  51879. 140 => 'User-defined 2',
  51880. 141 => 'Write to pipe with no one reading',
  51881. 142 => 'Signal raised by alarm',
  51882. 143 => 'Termination (request to terminate)',
  51883. 145 => 'Child process terminated, stopped (or continued*)',
  51884. 146 => 'Continue if stopped',
  51885. 147 => 'Stop executing temporarily',
  51886. 148 => 'Terminal stop signal',
  51887. 149 => 'Background process attempting to read from tty ("in")',
  51888. 150 => 'Background process attempting to write to tty ("out")',
  51889. 151 => 'Urgent data available on socket',
  51890. 152 => 'CPU time limit exceeded',
  51891. 153 => 'File size limit exceeded',
  51892. 154 => 'Signal raised by timer counting virtual time: "virtual timer expired"',
  51893. 155 => 'Profiling timer expired',
  51894. 157 => 'Pollable event',
  51895. 159 => 'Bad syscall',
  51896. );
  51897. public function __construct($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = array())
  51898. {
  51899. if (!\function_exists('proc_open')) {
  51900. throw new RuntimeException('The Process class relies on proc_open, which is not available on your PHP installation.');
  51901. }
  51902. $this->commandline = $commandline;
  51903. $this->cwd = $cwd;
  51904. if (null === $this->cwd && (\defined('ZEND_THREAD_SAFE') || '\\' === \DIRECTORY_SEPARATOR)) {
  51905. $this->cwd = getcwd();
  51906. }
  51907. if (null !== $env) {
  51908. $this->setEnv($env);
  51909. }
  51910. $this->setInput($input);
  51911. $this->setTimeout($timeout);
  51912. $this->useFileHandles = '\\' === \DIRECTORY_SEPARATOR;
  51913. $this->pty = false;
  51914. $this->enhanceSigchildCompatibility = '\\' !== \DIRECTORY_SEPARATOR && $this->isSigchildEnabled();
  51915. $this->options = array_replace(array('suppress_errors' => true, 'binary_pipes' => true), $options);
  51916. }
  51917. public function __destruct()
  51918. {
  51919. $this->stop(0);
  51920. }
  51921. public function __clone()
  51922. {
  51923. $this->resetProcessData();
  51924. }
  51925. public function run($callback = null)
  51926. {
  51927. $this->start($callback);
  51928. return $this->wait();
  51929. }
  51930. public function mustRun($callback = null)
  51931. {
  51932. if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  51933. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
  51934. }
  51935. if (0 !== $this->run($callback)) {
  51936. throw new ProcessFailedException($this);
  51937. }
  51938. return $this;
  51939. }
  51940. public function start($callback = null)
  51941. {
  51942. if ($this->isRunning()) {
  51943. throw new RuntimeException('Process is already running');
  51944. }
  51945. if ($this->outputDisabled && null !== $callback) {
  51946. throw new LogicException('Output has been disabled, enable it to allow the use of a callback.');
  51947. }
  51948. $this->resetProcessData();
  51949. $this->starttime = $this->lastOutputTime = microtime(true);
  51950. $this->callback = $this->buildCallback($callback);
  51951. $descriptors = $this->getDescriptors();
  51952. $commandline = $this->commandline;
  51953. if ('\\' === \DIRECTORY_SEPARATOR && $this->enhanceWindowsCompatibility) {
  51954. $commandline = 'cmd /V:ON /E:ON /D /C "('.$commandline.')';
  51955. foreach ($this->processPipes->getFiles() as $offset => $filename) {
  51956. $commandline .= ' '.$offset.'>'.ProcessUtils::escapeArgument($filename);
  51957. }
  51958. $commandline .= '"';
  51959. if (!isset($this->options['bypass_shell'])) {
  51960. $this->options['bypass_shell'] = true;
  51961. }
  51962. } elseif (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  51963. $descriptors[3] = array('pipe', 'w');
  51964. $commandline = '{ ('.$this->commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
  51965. $commandline .= 'pid=$!; echo $pid >&3; wait $pid; code=$?; echo $code >&3; exit $code';
  51966. $ptsWorkaround = fopen(__FILE__, 'r');
  51967. }
  51968. $this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $this->env, $this->options);
  51969. if (!\is_resource($this->process)) {
  51970. throw new RuntimeException('Unable to launch a new process.');
  51971. }
  51972. $this->status = self::STATUS_STARTED;
  51973. if (isset($descriptors[3])) {
  51974. $this->fallbackStatus['pid'] = (int) fgets($this->processPipes->pipes[3]);
  51975. }
  51976. if ($this->tty) {
  51977. return;
  51978. }
  51979. $this->updateStatus(false);
  51980. $this->checkTimeout();
  51981. }
  51982. public function restart($callback = null)
  51983. {
  51984. if ($this->isRunning()) {
  51985. throw new RuntimeException('Process is already running');
  51986. }
  51987. $process = clone $this;
  51988. $process->start($callback);
  51989. return $process;
  51990. }
  51991. public function wait($callback = null)
  51992. {
  51993. $this->requireProcessIsStarted(__FUNCTION__);
  51994. $this->updateStatus(false);
  51995. if (null !== $callback) {
  51996. $this->callback = $this->buildCallback($callback);
  51997. }
  51998. do {
  51999. $this->checkTimeout();
  52000. $running = '\\' === \DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen();
  52001. $this->readPipes($running, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  52002. } while ($running);
  52003. while ($this->isRunning()) {
  52004. usleep(1000);
  52005. }
  52006. if ($this->processInformation['signaled'] && $this->processInformation['termsig'] !== $this->latestSignal) {
  52007. throw new RuntimeException(sprintf('The process has been signaled with signal "%s".', $this->processInformation['termsig']));
  52008. }
  52009. return $this->exitcode;
  52010. }
  52011. public function getPid()
  52012. {
  52013. return $this->isRunning() ? $this->processInformation['pid'] : null;
  52014. }
  52015. public function signal($signal)
  52016. {
  52017. $this->doSignal($signal, true);
  52018. return $this;
  52019. }
  52020. public function disableOutput()
  52021. {
  52022. if ($this->isRunning()) {
  52023. throw new RuntimeException('Disabling output while the process is running is not possible.');
  52024. }
  52025. if (null !== $this->idleTimeout) {
  52026. throw new LogicException('Output can not be disabled while an idle timeout is set.');
  52027. }
  52028. $this->outputDisabled = true;
  52029. return $this;
  52030. }
  52031. public function enableOutput()
  52032. {
  52033. if ($this->isRunning()) {
  52034. throw new RuntimeException('Enabling output while the process is running is not possible.');
  52035. }
  52036. $this->outputDisabled = false;
  52037. return $this;
  52038. }
  52039. public function isOutputDisabled()
  52040. {
  52041. return $this->outputDisabled;
  52042. }
  52043. public function getOutput()
  52044. {
  52045. $this->readPipesForOutput(__FUNCTION__);
  52046. if (false === $ret = stream_get_contents($this->stdout, -1, 0)) {
  52047. return '';
  52048. }
  52049. return $ret;
  52050. }
  52051. public function getIncrementalOutput()
  52052. {
  52053. $this->readPipesForOutput(__FUNCTION__);
  52054. $latest = stream_get_contents($this->stdout, -1, $this->incrementalOutputOffset);
  52055. $this->incrementalOutputOffset = ftell($this->stdout);
  52056. if (false === $latest) {
  52057. return '';
  52058. }
  52059. return $latest;
  52060. }
  52061. public function clearOutput()
  52062. {
  52063. ftruncate($this->stdout, 0);
  52064. fseek($this->stdout, 0);
  52065. $this->incrementalOutputOffset = 0;
  52066. return $this;
  52067. }
  52068. public function getErrorOutput()
  52069. {
  52070. $this->readPipesForOutput(__FUNCTION__);
  52071. if (false === $ret = stream_get_contents($this->stderr, -1, 0)) {
  52072. return '';
  52073. }
  52074. return $ret;
  52075. }
  52076. public function getIncrementalErrorOutput()
  52077. {
  52078. $this->readPipesForOutput(__FUNCTION__);
  52079. $latest = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset);
  52080. $this->incrementalErrorOutputOffset = ftell($this->stderr);
  52081. if (false === $latest) {
  52082. return '';
  52083. }
  52084. return $latest;
  52085. }
  52086. public function clearErrorOutput()
  52087. {
  52088. ftruncate($this->stderr, 0);
  52089. fseek($this->stderr, 0);
  52090. $this->incrementalErrorOutputOffset = 0;
  52091. return $this;
  52092. }
  52093. public function getExitCode()
  52094. {
  52095. if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  52096. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
  52097. }
  52098. $this->updateStatus(false);
  52099. return $this->exitcode;
  52100. }
  52101. public function getExitCodeText()
  52102. {
  52103. if (null === $exitcode = $this->getExitCode()) {
  52104. return;
  52105. }
  52106. return isset(self::$exitCodes[$exitcode]) ? self::$exitCodes[$exitcode] : 'Unknown error';
  52107. }
  52108. public function isSuccessful()
  52109. {
  52110. return 0 === $this->getExitCode();
  52111. }
  52112. public function hasBeenSignaled()
  52113. {
  52114. $this->requireProcessIsTerminated(__FUNCTION__);
  52115. if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  52116. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
  52117. }
  52118. return $this->processInformation['signaled'];
  52119. }
  52120. public function getTermSignal()
  52121. {
  52122. $this->requireProcessIsTerminated(__FUNCTION__);
  52123. if ($this->isSigchildEnabled() && (!$this->enhanceSigchildCompatibility || -1 === $this->processInformation['termsig'])) {
  52124. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
  52125. }
  52126. return $this->processInformation['termsig'];
  52127. }
  52128. public function hasBeenStopped()
  52129. {
  52130. $this->requireProcessIsTerminated(__FUNCTION__);
  52131. return $this->processInformation['stopped'];
  52132. }
  52133. public function getStopSignal()
  52134. {
  52135. $this->requireProcessIsTerminated(__FUNCTION__);
  52136. return $this->processInformation['stopsig'];
  52137. }
  52138. public function isRunning()
  52139. {
  52140. if (self::STATUS_STARTED !== $this->status) {
  52141. return false;
  52142. }
  52143. $this->updateStatus(false);
  52144. return $this->processInformation['running'];
  52145. }
  52146. public function isStarted()
  52147. {
  52148. return self::STATUS_READY != $this->status;
  52149. }
  52150. public function isTerminated()
  52151. {
  52152. $this->updateStatus(false);
  52153. return self::STATUS_TERMINATED == $this->status;
  52154. }
  52155. public function getStatus()
  52156. {
  52157. $this->updateStatus(false);
  52158. return $this->status;
  52159. }
  52160. public function stop($timeout = 10, $signal = null)
  52161. {
  52162. $timeoutMicro = microtime(true) + $timeout;
  52163. if ($this->isRunning()) {
  52164. $this->doSignal(15, false);
  52165. do {
  52166. usleep(1000);
  52167. } while ($this->isRunning() && microtime(true) < $timeoutMicro);
  52168. if ($this->isRunning()) {
  52169. $this->doSignal($signal ?: 9, false);
  52170. }
  52171. }
  52172. if ($this->isRunning()) {
  52173. if (isset($this->fallbackStatus['pid'])) {
  52174. unset($this->fallbackStatus['pid']);
  52175. return $this->stop(0, $signal);
  52176. }
  52177. $this->close();
  52178. }
  52179. return $this->exitcode;
  52180. }
  52181. public function addOutput($line)
  52182. {
  52183. $this->lastOutputTime = microtime(true);
  52184. fseek($this->stdout, 0, SEEK_END);
  52185. fwrite($this->stdout, $line);
  52186. fseek($this->stdout, $this->incrementalOutputOffset);
  52187. }
  52188. public function addErrorOutput($line)
  52189. {
  52190. $this->lastOutputTime = microtime(true);
  52191. fseek($this->stderr, 0, SEEK_END);
  52192. fwrite($this->stderr, $line);
  52193. fseek($this->stderr, $this->incrementalErrorOutputOffset);
  52194. }
  52195. public function getCommandLine()
  52196. {
  52197. return $this->commandline;
  52198. }
  52199. public function setCommandLine($commandline)
  52200. {
  52201. $this->commandline = $commandline;
  52202. return $this;
  52203. }
  52204. public function getTimeout()
  52205. {
  52206. return $this->timeout;
  52207. }
  52208. public function getIdleTimeout()
  52209. {
  52210. return $this->idleTimeout;
  52211. }
  52212. public function setTimeout($timeout)
  52213. {
  52214. $this->timeout = $this->validateTimeout($timeout);
  52215. return $this;
  52216. }
  52217. public function setIdleTimeout($timeout)
  52218. {
  52219. if (null !== $timeout && $this->outputDisabled) {
  52220. throw new LogicException('Idle timeout can not be set while the output is disabled.');
  52221. }
  52222. $this->idleTimeout = $this->validateTimeout($timeout);
  52223. return $this;
  52224. }
  52225. public function setTty($tty)
  52226. {
  52227. if ('\\' === \DIRECTORY_SEPARATOR && $tty) {
  52228. throw new RuntimeException('TTY mode is not supported on Windows platform.');
  52229. }
  52230. if ($tty) {
  52231. static $isTtySupported;
  52232. if (null === $isTtySupported) {
  52233. $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);
  52234. }
  52235. if (!$isTtySupported) {
  52236. throw new RuntimeException('TTY mode requires /dev/tty to be read/writable.');
  52237. }
  52238. }
  52239. $this->tty = (bool) $tty;
  52240. return $this;
  52241. }
  52242. public function isTty()
  52243. {
  52244. return $this->tty;
  52245. }
  52246. public function setPty($bool)
  52247. {
  52248. $this->pty = (bool) $bool;
  52249. return $this;
  52250. }
  52251. public function isPty()
  52252. {
  52253. return $this->pty;
  52254. }
  52255. public function getWorkingDirectory()
  52256. {
  52257. if (null === $this->cwd) {
  52258. return getcwd() ?: null;
  52259. }
  52260. return $this->cwd;
  52261. }
  52262. public function setWorkingDirectory($cwd)
  52263. {
  52264. $this->cwd = $cwd;
  52265. return $this;
  52266. }
  52267. public function getEnv()
  52268. {
  52269. return $this->env;
  52270. }
  52271. public function setEnv(array $env)
  52272. {
  52273. $env = array_filter($env, function ($value) {
  52274. return !\is_array($value);
  52275. });
  52276. $this->env = array();
  52277. foreach ($env as $key => $value) {
  52278. $this->env[$key] = (string) $value;
  52279. }
  52280. return $this;
  52281. }
  52282. public function getStdin()
  52283. {
  52284. @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);
  52285. return $this->getInput();
  52286. }
  52287. public function getInput()
  52288. {
  52289. return $this->input;
  52290. }
  52291. public function setStdin($stdin)
  52292. {
  52293. @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);
  52294. return $this->setInput($stdin);
  52295. }
  52296. public function setInput($input)
  52297. {
  52298. if ($this->isRunning()) {
  52299. throw new LogicException('Input can not be set while the process is running.');
  52300. }
  52301. $this->input = ProcessUtils::validateInput(__METHOD__, $input);
  52302. return $this;
  52303. }
  52304. public function getOptions()
  52305. {
  52306. return $this->options;
  52307. }
  52308. public function setOptions(array $options)
  52309. {
  52310. $this->options = $options;
  52311. return $this;
  52312. }
  52313. public function getEnhanceWindowsCompatibility()
  52314. {
  52315. return $this->enhanceWindowsCompatibility;
  52316. }
  52317. public function setEnhanceWindowsCompatibility($enhance)
  52318. {
  52319. $this->enhanceWindowsCompatibility = (bool) $enhance;
  52320. return $this;
  52321. }
  52322. public function getEnhanceSigchildCompatibility()
  52323. {
  52324. return $this->enhanceSigchildCompatibility;
  52325. }
  52326. public function setEnhanceSigchildCompatibility($enhance)
  52327. {
  52328. $this->enhanceSigchildCompatibility = (bool) $enhance;
  52329. return $this;
  52330. }
  52331. public function checkTimeout()
  52332. {
  52333. if (self::STATUS_STARTED !== $this->status) {
  52334. return;
  52335. }
  52336. if (null !== $this->timeout && $this->timeout < microtime(true) - $this->starttime) {
  52337. $this->stop(0);
  52338. throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_GENERAL);
  52339. }
  52340. if (null !== $this->idleTimeout && $this->idleTimeout < microtime(true) - $this->lastOutputTime) {
  52341. $this->stop(0);
  52342. throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_IDLE);
  52343. }
  52344. }
  52345. public static function isPtySupported()
  52346. {
  52347. static $result;
  52348. if (null !== $result) {
  52349. return $result;
  52350. }
  52351. if ('\\' === \DIRECTORY_SEPARATOR) {
  52352. return $result = false;
  52353. }
  52354. return $result = (bool) @proc_open('echo 1 >/dev/null', array(array('pty'), array('pty'), array('pty')), $pipes);
  52355. }
  52356. private function getDescriptors()
  52357. {
  52358. if ('\\' === \DIRECTORY_SEPARATOR) {
  52359. $this->processPipes = WindowsPipes::create($this, $this->input);
  52360. } else {
  52361. $this->processPipes = UnixPipes::create($this, $this->input);
  52362. }
  52363. return $this->processPipes->getDescriptors();
  52364. }
  52365. protected function buildCallback($callback)
  52366. {
  52367. $that = $this;
  52368. $out = self::OUT;
  52369. $callback = function ($type, $data) use ($that, $callback, $out) {
  52370. if ($out == $type) {
  52371. $that->addOutput($data);
  52372. } else {
  52373. $that->addErrorOutput($data);
  52374. }
  52375. if (null !== $callback) {
  52376. \call_user_func($callback, $type, $data);
  52377. }
  52378. };
  52379. return $callback;
  52380. }
  52381. protected function updateStatus($blocking)
  52382. {
  52383. if (self::STATUS_STARTED !== $this->status) {
  52384. return;
  52385. }
  52386. $this->processInformation = proc_get_status($this->process);
  52387. $running = $this->processInformation['running'];
  52388. $this->readPipes($running && $blocking, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  52389. if ($this->fallbackStatus && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  52390. $this->processInformation = $this->fallbackStatus + $this->processInformation;
  52391. }
  52392. if (!$running) {
  52393. $this->close();
  52394. }
  52395. }
  52396. protected function isSigchildEnabled()
  52397. {
  52398. if (null !== self::$sigchild) {
  52399. return self::$sigchild;
  52400. }
  52401. if (!\function_exists('phpinfo') || \defined('HHVM_VERSION')) {
  52402. return self::$sigchild = false;
  52403. }
  52404. ob_start();
  52405. phpinfo(INFO_GENERAL);
  52406. return self::$sigchild = false !== strpos(ob_get_clean(), '--enable-sigchild');
  52407. }
  52408. private function readPipesForOutput($caller)
  52409. {
  52410. if ($this->outputDisabled) {
  52411. throw new LogicException('Output has been disabled.');
  52412. }
  52413. $this->requireProcessIsStarted($caller);
  52414. $this->updateStatus(false);
  52415. }
  52416. private function validateTimeout($timeout)
  52417. {
  52418. $timeout = (float) $timeout;
  52419. if (0.0 === $timeout) {
  52420. $timeout = null;
  52421. } elseif ($timeout < 0) {
  52422. throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
  52423. }
  52424. return $timeout;
  52425. }
  52426. private function readPipes($blocking, $close)
  52427. {
  52428. $result = $this->processPipes->readAndWrite($blocking, $close);
  52429. $callback = $this->callback;
  52430. foreach ($result as $type => $data) {
  52431. if (3 !== $type) {
  52432. $callback(self::STDOUT === $type ? self::OUT : self::ERR, $data);
  52433. } elseif (!isset($this->fallbackStatus['signaled'])) {
  52434. $this->fallbackStatus['exitcode'] = (int) $data;
  52435. }
  52436. }
  52437. }
  52438. private function close()
  52439. {
  52440. $this->processPipes->close();
  52441. if (\is_resource($this->process)) {
  52442. proc_close($this->process);
  52443. }
  52444. $this->exitcode = $this->processInformation['exitcode'];
  52445. $this->status = self::STATUS_TERMINATED;
  52446. if (-1 === $this->exitcode) {
  52447. if ($this->processInformation['signaled'] && 0 < $this->processInformation['termsig']) {
  52448. $this->exitcode = 128 + $this->processInformation['termsig'];
  52449. } elseif ($this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  52450. $this->processInformation['signaled'] = true;
  52451. $this->processInformation['termsig'] = -1;
  52452. }
  52453. }
  52454. $this->callback = null;
  52455. return $this->exitcode;
  52456. }
  52457. private function resetProcessData()
  52458. {
  52459. $this->starttime = null;
  52460. $this->callback = null;
  52461. $this->exitcode = null;
  52462. $this->fallbackStatus = array();
  52463. $this->processInformation = null;
  52464. $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+b');
  52465. $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+b');
  52466. $this->process = null;
  52467. $this->latestSignal = null;
  52468. $this->status = self::STATUS_READY;
  52469. $this->incrementalOutputOffset = 0;
  52470. $this->incrementalErrorOutputOffset = 0;
  52471. }
  52472. private function doSignal($signal, $throwException)
  52473. {
  52474. if (null === $pid = $this->getPid()) {
  52475. if ($throwException) {
  52476. throw new LogicException('Can not send signal on a non running process.');
  52477. }
  52478. return false;
  52479. }
  52480. if ('\\' === \DIRECTORY_SEPARATOR) {
  52481. exec(sprintf('taskkill /F /T /PID %d 2>&1', $pid), $output, $exitCode);
  52482. if ($exitCode && $this->isRunning()) {
  52483. if ($throwException) {
  52484. throw new RuntimeException(sprintf('Unable to kill the process (%s).', implode(' ', $output)));
  52485. }
  52486. return false;
  52487. }
  52488. } else {
  52489. if (!$this->enhanceSigchildCompatibility || !$this->isSigchildEnabled()) {
  52490. $ok = @proc_terminate($this->process, $signal);
  52491. } elseif (\function_exists('posix_kill')) {
  52492. $ok = @posix_kill($pid, $signal);
  52493. } elseif ($ok = proc_open(sprintf('kill -%d %d', $signal, $pid), array(2 => array('pipe', 'w')), $pipes)) {
  52494. $ok = false === fgets($pipes[2]);
  52495. }
  52496. if (!$ok) {
  52497. if ($throwException) {
  52498. throw new RuntimeException(sprintf('Error while sending signal `%s`.', $signal));
  52499. }
  52500. return false;
  52501. }
  52502. }
  52503. $this->latestSignal = (int) $signal;
  52504. $this->fallbackStatus['signaled'] = true;
  52505. $this->fallbackStatus['exitcode'] = -1;
  52506. $this->fallbackStatus['termsig'] = $this->latestSignal;
  52507. return true;
  52508. }
  52509. private function requireProcessIsStarted($functionName)
  52510. {
  52511. if (!$this->isStarted()) {
  52512. throw new LogicException(sprintf('Process must be started before calling %s.', $functionName));
  52513. }
  52514. }
  52515. private function requireProcessIsTerminated($functionName)
  52516. {
  52517. if (!$this->isTerminated()) {
  52518. throw new LogicException(sprintf('Process must be terminated before calling %s.', $functionName));
  52519. }
  52520. }
  52521. }
  52522. <?php
  52523. namespace Symfony\Component\Process;
  52524. use Symfony\Component\Process\Exception\InvalidArgumentException;
  52525. use Symfony\Component\Process\Exception\LogicException;
  52526. class ProcessBuilder
  52527. {
  52528. private $arguments;
  52529. private $cwd;
  52530. private $env = array();
  52531. private $input;
  52532. private $timeout = 60;
  52533. private $options = array();
  52534. private $inheritEnv = true;
  52535. private $prefix = array();
  52536. private $outputDisabled = false;
  52537. public function __construct(array $arguments = array())
  52538. {
  52539. $this->arguments = $arguments;
  52540. }
  52541. public static function create(array $arguments = array())
  52542. {
  52543. return new static($arguments);
  52544. }
  52545. public function add($argument)
  52546. {
  52547. $this->arguments[] = $argument;
  52548. return $this;
  52549. }
  52550. public function setPrefix($prefix)
  52551. {
  52552. $this->prefix = \is_array($prefix) ? $prefix : array($prefix);
  52553. return $this;
  52554. }
  52555. public function setArguments(array $arguments)
  52556. {
  52557. $this->arguments = $arguments;
  52558. return $this;
  52559. }
  52560. public function setWorkingDirectory($cwd)
  52561. {
  52562. $this->cwd = $cwd;
  52563. return $this;
  52564. }
  52565. public function inheritEnvironmentVariables($inheritEnv = true)
  52566. {
  52567. $this->inheritEnv = $inheritEnv;
  52568. return $this;
  52569. }
  52570. public function setEnv($name, $value)
  52571. {
  52572. $this->env[$name] = $value;
  52573. return $this;
  52574. }
  52575. public function addEnvironmentVariables(array $variables)
  52576. {
  52577. $this->env = array_replace($this->env, $variables);
  52578. return $this;
  52579. }
  52580. public function setInput($input)
  52581. {
  52582. $this->input = ProcessUtils::validateInput(__METHOD__, $input);
  52583. return $this;
  52584. }
  52585. public function setTimeout($timeout)
  52586. {
  52587. if (null === $timeout) {
  52588. $this->timeout = null;
  52589. return $this;
  52590. }
  52591. $timeout = (float) $timeout;
  52592. if ($timeout < 0) {
  52593. throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
  52594. }
  52595. $this->timeout = $timeout;
  52596. return $this;
  52597. }
  52598. public function setOption($name, $value)
  52599. {
  52600. $this->options[$name] = $value;
  52601. return $this;
  52602. }
  52603. public function disableOutput()
  52604. {
  52605. $this->outputDisabled = true;
  52606. return $this;
  52607. }
  52608. public function enableOutput()
  52609. {
  52610. $this->outputDisabled = false;
  52611. return $this;
  52612. }
  52613. public function getProcess()
  52614. {
  52615. if (0 === \count($this->prefix) && 0 === \count($this->arguments)) {
  52616. throw new LogicException('You must add() command arguments before calling getProcess().');
  52617. }
  52618. $options = $this->options;
  52619. $arguments = array_merge($this->prefix, $this->arguments);
  52620. $script = implode(' ', array_map(array(__NAMESPACE__.'\\ProcessUtils', 'escapeArgument'), $arguments));
  52621. if ($this->inheritEnv) {
  52622. $env = array_replace($_ENV, $_SERVER, $this->env);
  52623. } else {
  52624. $env = $this->env;
  52625. }
  52626. $process = new Process($script, $this->cwd, $env, $this->input, $this->timeout, $options);
  52627. if ($this->outputDisabled) {
  52628. $process->disableOutput();
  52629. }
  52630. return $process;
  52631. }
  52632. }
  52633. <?php
  52634. namespace Symfony\Component\Process;
  52635. use Symfony\Component\Process\Exception\InvalidArgumentException;
  52636. class ProcessUtils
  52637. {
  52638. private function __construct()
  52639. {
  52640. }
  52641. public static function escapeArgument($argument)
  52642. {
  52643. if ('\\' === \DIRECTORY_SEPARATOR) {
  52644. if ('' === $argument) {
  52645. return escapeshellarg($argument);
  52646. }
  52647. $escapedArgument = '';
  52648. $quote = false;
  52649. foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
  52650. if ('"' === $part) {
  52651. $escapedArgument .= '\\"';
  52652. } elseif (self::isSurroundedBy($part, '%')) {
  52653. $escapedArgument .= '^%"'.substr($part, 1, -1).'"^%';
  52654. } else {
  52655. if ('\\' === substr($part, -1)) {
  52656. $part .= '\\';
  52657. }
  52658. $quote = true;
  52659. $escapedArgument .= $part;
  52660. }
  52661. }
  52662. if ($quote) {
  52663. $escapedArgument = '"'.$escapedArgument.'"';
  52664. }
  52665. return $escapedArgument;
  52666. }
  52667. return "'".str_replace("'", "'\\''", $argument)."'";
  52668. }
  52669. public static function validateInput($caller, $input)
  52670. {
  52671. if (null !== $input) {
  52672. if (\is_resource($input)) {
  52673. return $input;
  52674. }
  52675. if (\is_string($input)) {
  52676. return $input;
  52677. }
  52678. if (is_scalar($input)) {
  52679. return (string) $input;
  52680. }
  52681. if (\is_object($input) && method_exists($input, '__toString')) {
  52682. @trigger_error('Passing an object as an input is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  52683. return (string) $input;
  52684. }
  52685. throw new InvalidArgumentException(sprintf('%s only accepts strings or stream resources.', $caller));
  52686. }
  52687. return $input;
  52688. }
  52689. private static function isSurroundedBy($arg, $char)
  52690. {
  52691. return 2 < \strlen($arg) && $char === $arg[0] && $char === $arg[\strlen($arg) - 1];
  52692. }
  52693. }
  52694. Copyright (c) 2011 Jordi Boggiano
  52695. Permission is hereby granted, free of charge, to any person obtaining a copy
  52696. of this software and associated documentation files (the "Software"), to deal
  52697. in the Software without restriction, including without limitation the rights
  52698. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  52699. copies of the Software, and to permit persons to whom the Software is furnished
  52700. to do so, subject to the following conditions:
  52701. The above copyright notice and this permission notice shall be included in all
  52702. copies or substantial portions of the Software.
  52703. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  52704. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  52705. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  52706. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  52707. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  52708. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  52709. THE SOFTWARE.
  52710. <?php
  52711. namespace Seld\JsonLint;
  52712. class DuplicateKeyException extends ParsingException
  52713. {
  52714. public function __construct($message, $key, array $details = array())
  52715. {
  52716. $details['key'] = $key;
  52717. parent::__construct($message, $details);
  52718. }
  52719. public function getKey()
  52720. {
  52721. return $this->details['key'];
  52722. }
  52723. public function getDetails()
  52724. {
  52725. return $this->details;
  52726. }
  52727. }
  52728. <?php
  52729. namespace Seld\JsonLint;
  52730. use stdClass;
  52731. class JsonParser
  52732. {
  52733. const DETECT_KEY_CONFLICTS = 1;
  52734. const ALLOW_DUPLICATE_KEYS = 2;
  52735. const PARSE_TO_ASSOC = 4;
  52736. private $lexer;
  52737. private $flags;
  52738. private $stack;
  52739. private $vstack;
  52740. private $lstack;
  52741. private $symbols = array(
  52742. 'error' => 2,
  52743. 'JSONString' => 3,
  52744. 'STRING' => 4,
  52745. 'JSONNumber' => 5,
  52746. 'NUMBER' => 6,
  52747. 'JSONNullLiteral' => 7,
  52748. 'NULL' => 8,
  52749. 'JSONBooleanLiteral' => 9,
  52750. 'TRUE' => 10,
  52751. 'FALSE' => 11,
  52752. 'JSONText' => 12,
  52753. 'JSONValue' => 13,
  52754. 'EOF' => 14,
  52755. 'JSONObject' => 15,
  52756. 'JSONArray' => 16,
  52757. '{' => 17,
  52758. '}' => 18,
  52759. 'JSONMemberList' => 19,
  52760. 'JSONMember' => 20,
  52761. ':' => 21,
  52762. ',' => 22,
  52763. '[' => 23,
  52764. ']' => 24,
  52765. 'JSONElementList' => 25,
  52766. '$accept' => 0,
  52767. '$end' => 1,
  52768. );
  52769. private $terminals_ = array(
  52770. 2 => "error",
  52771. 4 => "STRING",
  52772. 6 => "NUMBER",
  52773. 8 => "NULL",
  52774. 10 => "TRUE",
  52775. 11 => "FALSE",
  52776. 14 => "EOF",
  52777. 17 => "{",
  52778. 18 => "}",
  52779. 21 => ":",
  52780. 22 => ",",
  52781. 23 => "[",
  52782. 24 => "]",
  52783. );
  52784. private $productions_ = array(
  52785. 0,
  52786. array(3, 1),
  52787. array(5, 1),
  52788. array(7, 1),
  52789. array(9, 1),
  52790. array(9, 1),
  52791. array(12, 2),
  52792. array(13, 1),
  52793. array(13, 1),
  52794. array(13, 1),
  52795. array(13, 1),
  52796. array(13, 1),
  52797. array(13, 1),
  52798. array(15, 2),
  52799. array(15, 3),
  52800. array(20, 3),
  52801. array(19, 1),
  52802. array(19, 3),
  52803. array(16, 2),
  52804. array(16, 3),
  52805. array(25, 1),
  52806. array(25, 3)
  52807. );
  52808. 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)),
  52809. );
  52810. private $defaultActions = array(
  52811. 16 => array(2, 6)
  52812. );
  52813. public function lint($input, $flags = 0)
  52814. {
  52815. try {
  52816. $this->parse($input, $flags);
  52817. } catch (ParsingException $e) {
  52818. return $e;
  52819. }
  52820. return null;
  52821. }
  52822. public function parse($input, $flags = 0)
  52823. {
  52824. $this->failOnBOM($input);
  52825. $this->flags = $flags;
  52826. $this->stack = array(0);
  52827. $this->vstack = array(null);
  52828. $this->lstack = array();
  52829. $yytext = '';
  52830. $yylineno = 0;
  52831. $yyleng = 0;
  52832. $recovering = 0;
  52833. $TERROR = 2;
  52834. $EOF = 1;
  52835. $this->lexer = new Lexer();
  52836. $this->lexer->setInput($input);
  52837. $yyloc = $this->lexer->yylloc;
  52838. $this->lstack[] = $yyloc;
  52839. $symbol = null;
  52840. $preErrorSymbol = null;
  52841. $state = null;
  52842. $action = null;
  52843. $a = null;
  52844. $r = null;
  52845. $yyval = new stdClass;
  52846. $p = null;
  52847. $len = null;
  52848. $newState = null;
  52849. $expected = null;
  52850. $errStr = null;
  52851. while (true) {
  52852. $state = $this->stack[\count($this->stack)-1];
  52853. if (isset($this->defaultActions[$state])) {
  52854. $action = $this->defaultActions[$state];
  52855. } else {
  52856. if ($symbol == null) {
  52857. $symbol = $this->lex();
  52858. }
  52859. $action = isset($this->table[$state][$symbol]) ? $this->table[$state][$symbol] : false;
  52860. }
  52861. if (!$action || !$action[0]) {
  52862. if (!$recovering) {
  52863. $expected = array();
  52864. foreach ($this->table[$state] as $p => $ignore) {
  52865. if (isset($this->terminals_[$p]) && $p > 2) {
  52866. $expected[] = "'" . $this->terminals_[$p] . "'";
  52867. }
  52868. }
  52869. $message = null;
  52870. if (\in_array("'STRING'", $expected) && \in_array(substr($this->lexer->match, 0, 1), array('"', "'"))) {
  52871. $message = "Invalid string";
  52872. if ("'" === substr($this->lexer->match, 0, 1)) {
  52873. $message .= ", it appears you used single quotes instead of double quotes";
  52874. } elseif (preg_match('{".+?(\\\\[^"bfnrt/\\\\u](...)?)}', $this->lexer->getFullUpcomingInput(), $match)) {
  52875. $message .= ", it appears you have an unescaped backslash at: ".$match[1];
  52876. } elseif (preg_match('{"(?:[^"]+|\\\\")*$}m', $this->lexer->getFullUpcomingInput())) {
  52877. $message .= ", it appears you forgot to terminate a string, or attempted to write a multiline string which is invalid";
  52878. }
  52879. }
  52880. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  52881. $errStr .= $this->lexer->showPosition() . "\n";
  52882. if ($message) {
  52883. $errStr .= $message;
  52884. } else {
  52885. $errStr .= (\count($expected) > 1) ? "Expected one of: " : "Expected: ";
  52886. $errStr .= implode(', ', $expected);
  52887. }
  52888. if (',' === substr(trim($this->lexer->getPastInput()), -1)) {
  52889. $errStr .= " - It appears you have an extra trailing comma";
  52890. }
  52891. $this->parseError($errStr, array(
  52892. 'text' => $this->lexer->match,
  52893. 'token' => !empty($this->terminals_[$symbol]) ? $this->terminals_[$symbol] : $symbol,
  52894. 'line' => $this->lexer->yylineno,
  52895. 'loc' => $yyloc,
  52896. 'expected' => $expected,
  52897. ));
  52898. }
  52899. if ($recovering == 3) {
  52900. if ($symbol == $EOF) {
  52901. throw new ParsingException($errStr ?: 'Parsing halted.');
  52902. }
  52903. $yyleng = $this->lexer->yyleng;
  52904. $yytext = $this->lexer->yytext;
  52905. $yylineno = $this->lexer->yylineno;
  52906. $yyloc = $this->lexer->yylloc;
  52907. $symbol = $this->lex();
  52908. }
  52909. while (true) {
  52910. if (\array_key_exists($TERROR, $this->table[$state])) {
  52911. break;
  52912. }
  52913. if ($state == 0) {
  52914. throw new ParsingException($errStr ?: 'Parsing halted.');
  52915. }
  52916. $this->popStack(1);
  52917. $state = $this->stack[\count($this->stack)-1];
  52918. }
  52919. $preErrorSymbol = $symbol;
  52920. $symbol = $TERROR;
  52921. $state = $this->stack[\count($this->stack)-1];
  52922. $action = isset($this->table[$state][$TERROR]) ? $this->table[$state][$TERROR] : false;
  52923. $recovering = 3;
  52924. }
  52925. if (\is_array($action[0]) && \count($action) > 1) {
  52926. throw new ParsingException('Parse Error: multiple actions possible at state: ' . $state . ', token: ' . $symbol);
  52927. }
  52928. switch ($action[0]) {
  52929. case 1:
  52930. $this->stack[] = $symbol;
  52931. $this->vstack[] = $this->lexer->yytext;
  52932. $this->lstack[] = $this->lexer->yylloc;
  52933. $this->stack[] = $action[1];
  52934. $symbol = null;
  52935. if (!$preErrorSymbol) {
  52936. $yyleng = $this->lexer->yyleng;
  52937. $yytext = $this->lexer->yytext;
  52938. $yylineno = $this->lexer->yylineno;
  52939. $yyloc = $this->lexer->yylloc;
  52940. if ($recovering > 0) {
  52941. $recovering--;
  52942. }
  52943. } else {
  52944. $symbol = $preErrorSymbol;
  52945. $preErrorSymbol = null;
  52946. }
  52947. break;
  52948. case 2:
  52949. $len = $this->productions_[$action[1]][1];
  52950. $yyval->token = $this->vstack[\count($this->vstack) - $len];
  52951. $yyval->store = array(
  52952. 'first_line' => $this->lstack[\count($this->lstack) - ($len ?: 1)]['first_line'],
  52953. 'last_line' => $this->lstack[\count($this->lstack) - 1]['last_line'],
  52954. 'first_column' => $this->lstack[\count($this->lstack) - ($len ?: 1)]['first_column'],
  52955. 'last_column' => $this->lstack[\count($this->lstack) - 1]['last_column'],
  52956. );
  52957. $r = $this->performAction($yyval, $yytext, $yyleng, $yylineno, $action[1], $this->vstack);
  52958. if (!$r instanceof Undefined) {
  52959. return $r;
  52960. }
  52961. if ($len) {
  52962. $this->popStack($len);
  52963. }
  52964. $this->stack[] = $this->productions_[$action[1]][0];
  52965. $this->vstack[] = $yyval->token;
  52966. $this->lstack[] = $yyval->store;
  52967. $newState = $this->table[$this->stack[\count($this->stack)-2]][$this->stack[\count($this->stack)-1]];
  52968. $this->stack[] = $newState;
  52969. break;
  52970. case 3:
  52971. return true;
  52972. }
  52973. }
  52974. }
  52975. protected function parseError($str, $hash)
  52976. {
  52977. throw new ParsingException($str, $hash);
  52978. }
  52979. private function performAction(stdClass $yyval, $yytext, $yyleng, $yylineno, $yystate, &$tokens)
  52980. {
  52981. $len = \count($tokens) - 1;
  52982. switch ($yystate) {
  52983. case 1:
  52984. $yytext = preg_replace_callback('{(?:\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4})}', array($this, 'stringInterpolation'), $yytext);
  52985. $yyval->token = $yytext;
  52986. break;
  52987. case 2:
  52988. if (strpos($yytext, 'e') !== false || strpos($yytext, 'E') !== false) {
  52989. $yyval->token = \floatval($yytext);
  52990. } else {
  52991. $yyval->token = strpos($yytext, '.') === false ? \intval($yytext) : \floatval($yytext);
  52992. }
  52993. break;
  52994. case 3:
  52995. $yyval->token = null;
  52996. break;
  52997. case 4:
  52998. $yyval->token = true;
  52999. break;
  53000. case 5:
  53001. $yyval->token = false;
  53002. break;
  53003. case 6:
  53004. return $yyval->token = $tokens[$len-1];
  53005. case 13:
  53006. if ($this->flags & self::PARSE_TO_ASSOC) {
  53007. $yyval->token = array();
  53008. } else {
  53009. $yyval->token = new stdClass;
  53010. }
  53011. break;
  53012. case 14:
  53013. $yyval->token = $tokens[$len-1];
  53014. break;
  53015. case 15:
  53016. $yyval->token = array($tokens[$len-2], $tokens[$len]);
  53017. break;
  53018. case 16:
  53019. if (PHP_VERSION_ID < 70100) {
  53020. $property = $tokens[$len][0] === '' ? '_empty_' : $tokens[$len][0];
  53021. } else {
  53022. $property = $tokens[$len][0];
  53023. }
  53024. if ($this->flags & self::PARSE_TO_ASSOC) {
  53025. $yyval->token = array();
  53026. $yyval->token[$property] = $tokens[$len][1];
  53027. } else {
  53028. $yyval->token = new stdClass;
  53029. $yyval->token->$property = $tokens[$len][1];
  53030. }
  53031. break;
  53032. case 17:
  53033. if ($this->flags & self::PARSE_TO_ASSOC) {
  53034. $yyval->token =& $tokens[$len-2];
  53035. $key = $tokens[$len][0];
  53036. if (($this->flags & self::DETECT_KEY_CONFLICTS) && isset($tokens[$len-2][$key])) {
  53037. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  53038. $errStr .= $this->lexer->showPosition() . "\n";
  53039. $errStr .= "Duplicate key: ".$tokens[$len][0];
  53040. throw new DuplicateKeyException($errStr, $tokens[$len][0], array('line' => $yylineno+1));
  53041. } elseif (($this->flags & self::ALLOW_DUPLICATE_KEYS) && isset($tokens[$len-2][$key])) {
  53042. $duplicateCount = 1;
  53043. do {
  53044. $duplicateKey = $key . '.' . $duplicateCount++;
  53045. } while (isset($tokens[$len-2][$duplicateKey]));
  53046. $key = $duplicateKey;
  53047. }
  53048. $tokens[$len-2][$key] = $tokens[$len][1];
  53049. } else {
  53050. $yyval->token = $tokens[$len-2];
  53051. if (PHP_VERSION_ID < 70100) {
  53052. $key = $tokens[$len][0] === '' ? '_empty_' : $tokens[$len][0];
  53053. } else {
  53054. $key = $tokens[$len][0];
  53055. }
  53056. if (($this->flags & self::DETECT_KEY_CONFLICTS) && isset($tokens[$len-2]->{$key})) {
  53057. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  53058. $errStr .= $this->lexer->showPosition() . "\n";
  53059. $errStr .= "Duplicate key: ".$tokens[$len][0];
  53060. throw new DuplicateKeyException($errStr, $tokens[$len][0], array('line' => $yylineno+1));
  53061. } elseif (($this->flags & self::ALLOW_DUPLICATE_KEYS) && isset($tokens[$len-2]->{$key})) {
  53062. $duplicateCount = 1;
  53063. do {
  53064. $duplicateKey = $key . '.' . $duplicateCount++;
  53065. } while (isset($tokens[$len-2]->$duplicateKey));
  53066. $key = $duplicateKey;
  53067. }
  53068. $tokens[$len-2]->$key = $tokens[$len][1];
  53069. }
  53070. break;
  53071. case 18:
  53072. $yyval->token = array();
  53073. break;
  53074. case 19:
  53075. $yyval->token = $tokens[$len-1];
  53076. break;
  53077. case 20:
  53078. $yyval->token = array($tokens[$len]);
  53079. break;
  53080. case 21:
  53081. $tokens[$len-2][] = $tokens[$len];
  53082. $yyval->token = $tokens[$len-2];
  53083. break;
  53084. }
  53085. return new Undefined();
  53086. }
  53087. private function stringInterpolation($match)
  53088. {
  53089. switch ($match[0]) {
  53090. case '\\\\':
  53091. return '\\';
  53092. case '\"':
  53093. return '"';
  53094. case '\b':
  53095. return \chr(8);
  53096. case '\f':
  53097. return \chr(12);
  53098. case '\n':
  53099. return "\n";
  53100. case '\r':
  53101. return "\r";
  53102. case '\t':
  53103. return "\t";
  53104. case '\/':
  53105. return "/";
  53106. default:
  53107. return html_entity_decode('&#x'.ltrim(substr($match[0], 2), '0').';', ENT_QUOTES, 'UTF-8');
  53108. }
  53109. }
  53110. private function popStack($n)
  53111. {
  53112. $this->stack = \array_slice($this->stack, 0, - (2 * $n));
  53113. $this->vstack = \array_slice($this->vstack, 0, - $n);
  53114. $this->lstack = \array_slice($this->lstack, 0, - $n);
  53115. }
  53116. private function lex()
  53117. {
  53118. $token = $this->lexer->lex() ?: 1;
  53119. if (!is_numeric($token)) {
  53120. $token = isset($this->symbols[$token]) ? $this->symbols[$token] : $token;
  53121. }
  53122. return $token;
  53123. }
  53124. private function failOnBOM($input)
  53125. {
  53126. $bom = "\xEF\xBB\xBF";
  53127. if (substr($input, 0, 3) === $bom) {
  53128. $this->parseError("BOM detected, make sure your input does not include a Unicode Byte-Order-Mark", array());
  53129. }
  53130. }
  53131. }
  53132. <?php
  53133. namespace Seld\JsonLint;
  53134. class Lexer
  53135. {
  53136. private $EOF = 1;
  53137. private $rules = array(
  53138. 0 => '/\G\s+/',
  53139. 1 => '/\G-?([0-9]|[1-9][0-9]+)(\.[0-9]+)?([eE][+-]?[0-9]+)?\b/',
  53140. 2 => '{\G"(?>\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^\0-\x1f\\\\"]++)*+"}',
  53141. 3 => '/\G\{/',
  53142. 4 => '/\G\}/',
  53143. 5 => '/\G\[/',
  53144. 6 => '/\G\]/',
  53145. 7 => '/\G,/',
  53146. 8 => '/\G:/',
  53147. 9 => '/\Gtrue\b/',
  53148. 10 => '/\Gfalse\b/',
  53149. 11 => '/\Gnull\b/',
  53150. 12 => '/\G$/',
  53151. 13 => '/\G./',
  53152. );
  53153. private $conditions = array(
  53154. "INITIAL" => array(
  53155. "rules" => array(0,1,2,3,4,5,6,7,8,9,10,11,12,13),
  53156. "inclusive" => true,
  53157. ),
  53158. );
  53159. private $conditionStack;
  53160. private $input;
  53161. private $more;
  53162. private $done;
  53163. private $offset;
  53164. public $match;
  53165. public $yylineno;
  53166. public $yyleng;
  53167. public $yytext;
  53168. public $yylloc;
  53169. public function lex()
  53170. {
  53171. $r = $this->next();
  53172. if (!$r instanceof Undefined) {
  53173. return $r;
  53174. }
  53175. return $this->lex();
  53176. }
  53177. public function setInput($input)
  53178. {
  53179. $this->input = $input;
  53180. $this->more = false;
  53181. $this->done = false;
  53182. $this->offset = 0;
  53183. $this->yylineno = $this->yyleng = 0;
  53184. $this->yytext = $this->match = '';
  53185. $this->conditionStack = array('INITIAL');
  53186. $this->yylloc = array('first_line' => 1, 'first_column' => 0, 'last_line' => 1, 'last_column' => 0);
  53187. return $this;
  53188. }
  53189. public function showPosition()
  53190. {
  53191. $pre = str_replace("\n", '', $this->getPastInput());
  53192. $c = str_repeat('-', max(0, \strlen($pre) - 1));
  53193. return $pre . str_replace("\n", '', $this->getUpcomingInput()) . "\n" . $c . "^";
  53194. }
  53195. public function getPastInput()
  53196. {
  53197. $pastLength = $this->offset - \strlen($this->match);
  53198. return ($pastLength > 20 ? '...' : '') . substr($this->input, max(0, $pastLength - 20), min(20, $pastLength));
  53199. }
  53200. public function getUpcomingInput()
  53201. {
  53202. $next = $this->match;
  53203. if (\strlen($next) < 20) {
  53204. $next .= substr($this->input, $this->offset, 20 - \strlen($next));
  53205. }
  53206. return substr($next, 0, 20) . (\strlen($next) > 20 ? '...' : '');
  53207. }
  53208. public function getFullUpcomingInput()
  53209. {
  53210. $next = $this->match;
  53211. if (substr($next, 0, 1) === '"' && substr_count($next, '"') === 1) {
  53212. $len = \strlen($this->input);
  53213. $strEnd = min(strpos($this->input, '"', $this->offset + 1) ?: $len, strpos($this->input, "\n", $this->offset + 1) ?: $len);
  53214. $next .= substr($this->input, $this->offset, $strEnd - $this->offset);
  53215. } elseif (\strlen($next) < 20) {
  53216. $next .= substr($this->input, $this->offset, 20 - \strlen($next));
  53217. }
  53218. return $next;
  53219. }
  53220. protected function parseError($str, $hash)
  53221. {
  53222. throw new \Exception($str);
  53223. }
  53224. private function next()
  53225. {
  53226. if ($this->done) {
  53227. return $this->EOF;
  53228. }
  53229. if ($this->offset === \strlen($this->input)) {
  53230. $this->done = true;
  53231. }
  53232. $token = null;
  53233. $match = null;
  53234. $col = null;
  53235. $lines = null;
  53236. if (!$this->more) {
  53237. $this->yytext = '';
  53238. $this->match = '';
  53239. }
  53240. $rules = $this->getCurrentRules();
  53241. $rulesLen = \count($rules);
  53242. for ($i=0; $i < $rulesLen; $i++) {
  53243. if (preg_match($this->rules[$rules[$i]], $this->input, $match, 0, $this->offset)) {
  53244. preg_match_all('/\n.*/', $match[0], $lines);
  53245. $lines = $lines[0];
  53246. if ($lines) {
  53247. $this->yylineno += \count($lines);
  53248. }
  53249. $this->yylloc = array(
  53250. 'first_line' => $this->yylloc['last_line'],
  53251. 'last_line' => $this->yylineno+1,
  53252. 'first_column' => $this->yylloc['last_column'],
  53253. 'last_column' => $lines ? \strlen($lines[\count($lines) - 1]) - 1 : $this->yylloc['last_column'] + \strlen($match[0]),
  53254. );
  53255. $this->yytext .= $match[0];
  53256. $this->match .= $match[0];
  53257. $this->yyleng = \strlen($this->yytext);
  53258. $this->more = false;
  53259. $this->offset += \strlen($match[0]);
  53260. $token = $this->performAction($rules[$i], $this->conditionStack[\count($this->conditionStack)-1]);
  53261. if ($token) {
  53262. return $token;
  53263. }
  53264. return new Undefined();
  53265. }
  53266. }
  53267. if ($this->offset === \strlen($this->input)) {
  53268. return $this->EOF;
  53269. }
  53270. $this->parseError(
  53271. 'Lexical error on line ' . ($this->yylineno+1) . ". Unrecognized text.\n" . $this->showPosition(),
  53272. array(
  53273. 'text' => "",
  53274. 'token' => null,
  53275. 'line' => $this->yylineno,
  53276. )
  53277. );
  53278. }
  53279. private function getCurrentRules()
  53280. {
  53281. return $this->conditions[$this->conditionStack[\count($this->conditionStack)-1]]['rules'];
  53282. }
  53283. private function performAction($avoiding_name_collisions, $YY_START)
  53284. {
  53285. switch ($avoiding_name_collisions) {
  53286. case 0:
  53287. break;
  53288. case 1:
  53289. return 6;
  53290. case 2:
  53291. $this->yytext = substr($this->yytext, 1, $this->yyleng-2);
  53292. return 4;
  53293. case 3:
  53294. return 17;
  53295. case 4:
  53296. return 18;
  53297. case 5:
  53298. return 23;
  53299. case 6:
  53300. return 24;
  53301. case 7:
  53302. return 22;
  53303. case 8:
  53304. return 21;
  53305. case 9:
  53306. return 10;
  53307. case 10:
  53308. return 11;
  53309. case 11:
  53310. return 8;
  53311. case 12:
  53312. return 14;
  53313. case 13:
  53314. return 'INVALID';
  53315. }
  53316. }
  53317. }
  53318. <?php
  53319. namespace Seld\JsonLint;
  53320. class ParsingException extends \Exception
  53321. {
  53322. protected $details;
  53323. public function __construct($message, $details = array())
  53324. {
  53325. $this->details = $details;
  53326. parent::__construct($message);
  53327. }
  53328. public function getDetails()
  53329. {
  53330. return $this->details;
  53331. }
  53332. }
  53333. <?php
  53334. namespace Seld\JsonLint;
  53335. class Undefined
  53336. {
  53337. }
  53338. MIT License
  53339. Copyright (c) 2016
  53340. Permission is hereby granted, free of charge, to any person obtaining a copy
  53341. of this software and associated documentation files (the "Software"), to deal
  53342. in the Software without restriction, including without limitation the rights
  53343. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  53344. copies of the Software, and to permit persons to whom the Software is
  53345. furnished to do so, subject to the following conditions:
  53346. The above copyright notice and this permission notice shall be included in all
  53347. copies or substantial portions of the Software.
  53348. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  53349. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  53350. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  53351. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  53352. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  53353. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  53354. SOFTWARE.
  53355. <?php
  53356. require __DIR__ . '/../vendor/autoload.php';
  53357. $data = json_decode(file_get_contents('data.json'));
  53358. $validator = new JsonSchema\Validator();
  53359. $validator->check($data, (object) array('$ref' => 'file://' . realpath('schema.json')));
  53360. if ($validator->isValid()) {
  53361. echo "The supplied JSON validates against the schema.\n";
  53362. } else {
  53363. echo "JSON does not validate. Violations:\n";
  53364. foreach ($validator->getErrors() as $error) {
  53365. echo sprintf("[%s] %s\n", $error['property'], $error['message']);
  53366. }
  53367. }
  53368. <?php
  53369. namespace JsonSchema\Constraints;
  53370. use JsonSchema\Entity\JsonPointer;
  53371. use JsonSchema\Exception\InvalidArgumentException;
  53372. use JsonSchema\Exception\ValidationException;
  53373. use JsonSchema\Validator;
  53374. class BaseConstraint
  53375. {
  53376. protected $errors = array();
  53377. protected $errorMask = Validator::ERROR_NONE;
  53378. protected $factory;
  53379. public function __construct(Factory $factory = null)
  53380. {
  53381. $this->factory = $factory ?: new Factory();
  53382. }
  53383. public function addError(JsonPointer $path = null, $message, $constraint = '', array $more = null)
  53384. {
  53385. $error = array(
  53386. 'property' => $this->convertJsonPointerIntoPropertyPath($path ?: new JsonPointer('')),
  53387. 'pointer' => ltrim(strval($path ?: new JsonPointer('')), '#'),
  53388. 'message' => $message,
  53389. 'constraint' => $constraint,
  53390. 'context' => $this->factory->getErrorContext(),
  53391. );
  53392. if ($this->factory->getConfig(Constraint::CHECK_MODE_EXCEPTIONS)) {
  53393. throw new ValidationException(sprintf('Error validating %s: %s', $error['pointer'], $error['message']));
  53394. }
  53395. if (is_array($more) && count($more) > 0) {
  53396. $error += $more;
  53397. }
  53398. $this->errors[] = $error;
  53399. $this->errorMask |= $error['context'];
  53400. }
  53401. public function addErrors(array $errors)
  53402. {
  53403. if ($errors) {
  53404. $this->errors = array_merge($this->errors, $errors);
  53405. $errorMask = &$this->errorMask;
  53406. array_walk($errors, function ($error) use (&$errorMask) {
  53407. if (isset($error['context'])) {
  53408. $errorMask |= $error['context'];
  53409. }
  53410. });
  53411. }
  53412. }
  53413. public function getErrors($errorContext = Validator::ERROR_ALL)
  53414. {
  53415. if ($errorContext === Validator::ERROR_ALL) {
  53416. return $this->errors;
  53417. }
  53418. return array_filter($this->errors, function ($error) use ($errorContext) {
  53419. if ($errorContext & $error['context']) {
  53420. return true;
  53421. }
  53422. });
  53423. }
  53424. public function numErrors($errorContext = Validator::ERROR_ALL)
  53425. {
  53426. if ($errorContext === Validator::ERROR_ALL) {
  53427. return count($this->errors);
  53428. }
  53429. return count($this->getErrors($errorContext));
  53430. }
  53431. public function isValid()
  53432. {
  53433. return !$this->getErrors();
  53434. }
  53435. public function reset()
  53436. {
  53437. $this->errors = array();
  53438. $this->errorMask = Validator::ERROR_NONE;
  53439. }
  53440. public function getErrorMask()
  53441. {
  53442. return $this->errorMask;
  53443. }
  53444. public static function arrayToObjectRecursive($array)
  53445. {
  53446. $json = json_encode($array);
  53447. if (json_last_error() !== \JSON_ERROR_NONE) {
  53448. $message = 'Unable to encode schema array as JSON';
  53449. if (function_exists('json_last_error_msg')) {
  53450. $message .= ': ' . json_last_error_msg();
  53451. }
  53452. throw new InvalidArgumentException($message);
  53453. }
  53454. return (object) json_decode($json);
  53455. }
  53456. }
  53457. <?php
  53458. namespace JsonSchema\Constraints;
  53459. use JsonSchema\Entity\JsonPointer;
  53460. class CollectionConstraint extends Constraint
  53461. {
  53462. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null)
  53463. {
  53464. if (isset($schema->minItems) && count($value) < $schema->minItems) {
  53465. $this->addError($path, 'There must be a minimum of ' . $schema->minItems . ' items in the array', 'minItems', array('minItems' => $schema->minItems));
  53466. }
  53467. if (isset($schema->maxItems) && count($value) > $schema->maxItems) {
  53468. $this->addError($path, 'There must be a maximum of ' . $schema->maxItems . ' items in the array', 'maxItems', array('maxItems' => $schema->maxItems));
  53469. }
  53470. if (isset($schema->uniqueItems) && $schema->uniqueItems) {
  53471. $unique = $value;
  53472. if (is_array($value) && count($value)) {
  53473. $unique = array_map(function ($e) {
  53474. return var_export($e, true);
  53475. }, $value);
  53476. }
  53477. if (count(array_unique($unique)) != count($value)) {
  53478. $this->addError($path, 'There are no duplicates allowed in the array', 'uniqueItems');
  53479. }
  53480. }
  53481. if (isset($schema->items)) {
  53482. $this->validateItems($value, $schema, $path, $i);
  53483. }
  53484. }
  53485. protected function validateItems(&$value, $schema = null, JsonPointer $path = null, $i = null)
  53486. {
  53487. if (is_object($schema->items)) {
  53488. foreach ($value as $k => &$v) {
  53489. $initErrors = $this->getErrors();
  53490. $this->checkUndefined($v, $schema->items, $path, $k);
  53491. if (count($initErrors) < count($this->getErrors()) && (isset($schema->additionalItems) && $schema->additionalItems !== false)) {
  53492. $secondErrors = $this->getErrors();
  53493. $this->checkUndefined($v, $schema->additionalItems, $path, $k);
  53494. }
  53495. if (isset($secondErrors) && count($secondErrors) < count($this->getErrors())) {
  53496. $this->errors = $secondErrors;
  53497. } elseif (isset($secondErrors) && count($secondErrors) === count($this->getErrors())) {
  53498. $this->errors = $initErrors;
  53499. }
  53500. }
  53501. unset($v);
  53502. } else {
  53503. foreach ($value as $k => &$v) {
  53504. if (array_key_exists($k, $schema->items)) {
  53505. $this->checkUndefined($v, $schema->items[$k], $path, $k);
  53506. } else {
  53507. if (property_exists($schema, 'additionalItems')) {
  53508. if ($schema->additionalItems !== false) {
  53509. $this->checkUndefined($v, $schema->additionalItems, $path, $k);
  53510. } else {
  53511. $this->addError(
  53512. $path, 'The item ' . $i . '[' . $k . '] is not defined and the definition does not allow additional items', 'additionalItems', array('additionalItems' => $schema->additionalItems));
  53513. }
  53514. } else {
  53515. $this->checkUndefined($v, new \stdClass(), $path, $k);
  53516. }
  53517. }
  53518. }
  53519. unset($v);
  53520. if (count($value) > 0) {
  53521. for ($k = count($value); $k < count($schema->items); $k++) {
  53522. $undefinedInstance = $this->factory->createInstanceFor('undefined');
  53523. $this->checkUndefined($undefinedInstance, $schema->items[$k], $path, $k);
  53524. }
  53525. }
  53526. }
  53527. }
  53528. }
  53529. <?php
  53530. namespace JsonSchema\Constraints;
  53531. use JsonSchema\Entity\JsonPointer;
  53532. abstract class Constraint extends BaseConstraint implements ConstraintInterface
  53533. {
  53534. protected $inlineSchemaProperty = '$schema';
  53535. const CHECK_MODE_NONE = 0x00000000;
  53536. const CHECK_MODE_NORMAL = 0x00000001;
  53537. const CHECK_MODE_TYPE_CAST = 0x00000002;
  53538. const CHECK_MODE_COERCE_TYPES = 0x00000004;
  53539. const CHECK_MODE_APPLY_DEFAULTS = 0x00000008;
  53540. const CHECK_MODE_EXCEPTIONS = 0x00000010;
  53541. const CHECK_MODE_DISABLE_FORMAT = 0x00000020;
  53542. const CHECK_MODE_ONLY_REQUIRED_DEFAULTS = 0x00000080;
  53543. const CHECK_MODE_VALIDATE_SCHEMA = 0x00000100;
  53544. protected function incrementPath(JsonPointer $path = null, $i)
  53545. {
  53546. $path = $path ?: new JsonPointer('');
  53547. $path = $path->withPropertyPaths(
  53548. array_merge(
  53549. $path->getPropertyPaths(),
  53550. array_filter(array($i), 'strlen')
  53551. )
  53552. );
  53553. return $path;
  53554. }
  53555. protected function checkArray(&$value, $schema = null, JsonPointer $path = null, $i = null)
  53556. {
  53557. $validator = $this->factory->createInstanceFor('collection');
  53558. $validator->check($value, $schema, $path, $i);
  53559. $this->addErrors($validator->getErrors());
  53560. }
  53561. protected function checkObject(&$value, $schema = null, JsonPointer $path = null, $properties = null,
  53562. $additionalProperties = null, $patternProperties = null, $appliedDefaults = array())
  53563. {
  53564. $validator = $this->factory->createInstanceFor('object');
  53565. $validator->check($value, $schema, $path, $properties, $additionalProperties, $patternProperties, $appliedDefaults);
  53566. $this->addErrors($validator->getErrors());
  53567. }
  53568. protected function checkType(&$value, $schema = null, JsonPointer $path = null, $i = null)
  53569. {
  53570. $validator = $this->factory->createInstanceFor('type');
  53571. $validator->check($value, $schema, $path, $i);
  53572. $this->addErrors($validator->getErrors());
  53573. }
  53574. protected function checkUndefined(&$value, $schema = null, JsonPointer $path = null, $i = null, $fromDefault = false)
  53575. {
  53576. $validator = $this->factory->createInstanceFor('undefined');
  53577. $validator->check($value, $this->factory->getSchemaStorage()->resolveRefSchema($schema), $path, $i, $fromDefault);
  53578. $this->addErrors($validator->getErrors());
  53579. }
  53580. protected function checkString($value, $schema = null, JsonPointer $path = null, $i = null)
  53581. {
  53582. $validator = $this->factory->createInstanceFor('string');
  53583. $validator->check($value, $schema, $path, $i);
  53584. $this->addErrors($validator->getErrors());
  53585. }
  53586. protected function checkNumber($value, $schema = null, JsonPointer $path = null, $i = null)
  53587. {
  53588. $validator = $this->factory->createInstanceFor('number');
  53589. $validator->check($value, $schema, $path, $i);
  53590. $this->addErrors($validator->getErrors());
  53591. }
  53592. protected function checkEnum($value, $schema = null, JsonPointer $path = null, $i = null)
  53593. {
  53594. $validator = $this->factory->createInstanceFor('enum');
  53595. $validator->check($value, $schema, $path, $i);
  53596. $this->addErrors($validator->getErrors());
  53597. }
  53598. protected function checkFormat($value, $schema = null, JsonPointer $path = null, $i = null)
  53599. {
  53600. $validator = $this->factory->createInstanceFor('format');
  53601. $validator->check($value, $schema, $path, $i);
  53602. $this->addErrors($validator->getErrors());
  53603. }
  53604. protected function getTypeCheck()
  53605. {
  53606. return $this->factory->getTypeCheck();
  53607. }
  53608. protected function convertJsonPointerIntoPropertyPath(JsonPointer $pointer)
  53609. {
  53610. $result = array_map(
  53611. function ($path) {
  53612. return sprintf(is_numeric($path) ? '[%d]' : '.%s', $path);
  53613. },
  53614. $pointer->getPropertyPaths()
  53615. );
  53616. return trim(implode('', $result), '.');
  53617. }
  53618. }
  53619. <?php
  53620. namespace JsonSchema\Constraints;
  53621. use JsonSchema\Entity\JsonPointer;
  53622. interface ConstraintInterface
  53623. {
  53624. public function getErrors();
  53625. public function addErrors(array $errors);
  53626. public function addError(JsonPointer $path = null, $message, $constraint='', array $more = null);
  53627. public function isValid();
  53628. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null);
  53629. }
  53630. <?php
  53631. namespace JsonSchema\Constraints;
  53632. use JsonSchema\Entity\JsonPointer;
  53633. class EnumConstraint extends Constraint
  53634. {
  53635. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  53636. {
  53637. if ($element instanceof UndefinedConstraint && (!isset($schema->required) || !$schema->required)) {
  53638. return;
  53639. }
  53640. $type = gettype($element);
  53641. foreach ($schema->enum as $enum) {
  53642. $enumType = gettype($enum);
  53643. if ($this->factory->getConfig(self::CHECK_MODE_TYPE_CAST) && $type == 'array' && $enumType == 'object') {
  53644. if ((object) $element == $enum) {
  53645. return;
  53646. }
  53647. }
  53648. if ($type === gettype($enum)) {
  53649. if ($type == 'object') {
  53650. if ($element == $enum) {
  53651. return;
  53652. }
  53653. } elseif ($element === $enum) {
  53654. return;
  53655. }
  53656. }
  53657. }
  53658. $this->addError($path, 'Does not have a value in the enumeration ' . json_encode($schema->enum), 'enum', array('enum' => $schema->enum));
  53659. }
  53660. }
  53661. <?php
  53662. namespace JsonSchema\Constraints;
  53663. use JsonSchema\Exception\InvalidArgumentException;
  53664. use JsonSchema\SchemaStorage;
  53665. use JsonSchema\SchemaStorageInterface;
  53666. use JsonSchema\Uri\UriRetriever;
  53667. use JsonSchema\UriRetrieverInterface;
  53668. use JsonSchema\Validator;
  53669. class Factory
  53670. {
  53671. protected $schemaStorage;
  53672. protected $uriRetriever;
  53673. private $checkMode = Constraint::CHECK_MODE_NORMAL;
  53674. private $typeCheck = array();
  53675. protected $errorContext = Validator::ERROR_DOCUMENT_VALIDATION;
  53676. protected $constraintMap = array(
  53677. 'array' => 'JsonSchema\Constraints\CollectionConstraint',
  53678. 'collection' => 'JsonSchema\Constraints\CollectionConstraint',
  53679. 'object' => 'JsonSchema\Constraints\ObjectConstraint',
  53680. 'type' => 'JsonSchema\Constraints\TypeConstraint',
  53681. 'undefined' => 'JsonSchema\Constraints\UndefinedConstraint',
  53682. 'string' => 'JsonSchema\Constraints\StringConstraint',
  53683. 'number' => 'JsonSchema\Constraints\NumberConstraint',
  53684. 'enum' => 'JsonSchema\Constraints\EnumConstraint',
  53685. 'format' => 'JsonSchema\Constraints\FormatConstraint',
  53686. 'schema' => 'JsonSchema\Constraints\SchemaConstraint',
  53687. 'validator' => 'JsonSchema\Validator'
  53688. );
  53689. private $instanceCache = array();
  53690. public function __construct(
  53691. SchemaStorageInterface $schemaStorage = null,
  53692. UriRetrieverInterface $uriRetriever = null,
  53693. $checkMode = Constraint::CHECK_MODE_NORMAL
  53694. ) {
  53695. $this->setConfig($checkMode);
  53696. $this->uriRetriever = $uriRetriever ?: new UriRetriever();
  53697. $this->schemaStorage = $schemaStorage ?: new SchemaStorage($this->uriRetriever);
  53698. }
  53699. public function setConfig($checkMode = Constraint::CHECK_MODE_NORMAL)
  53700. {
  53701. $this->checkMode = $checkMode;
  53702. }
  53703. public function addConfig($options)
  53704. {
  53705. $this->checkMode |= $options;
  53706. }
  53707. public function removeConfig($options)
  53708. {
  53709. $this->checkMode &= ~$options;
  53710. }
  53711. public function getConfig($options = null)
  53712. {
  53713. if ($options === null) {
  53714. return $this->checkMode;
  53715. }
  53716. return $this->checkMode & $options;
  53717. }
  53718. public function getUriRetriever()
  53719. {
  53720. return $this->uriRetriever;
  53721. }
  53722. public function getSchemaStorage()
  53723. {
  53724. return $this->schemaStorage;
  53725. }
  53726. public function getTypeCheck()
  53727. {
  53728. if (!isset($this->typeCheck[$this->checkMode])) {
  53729. $this->typeCheck[$this->checkMode] = ($this->checkMode & Constraint::CHECK_MODE_TYPE_CAST)
  53730. ? new TypeCheck\LooseTypeCheck()
  53731. : new TypeCheck\StrictTypeCheck();
  53732. }
  53733. return $this->typeCheck[$this->checkMode];
  53734. }
  53735. public function setConstraintClass($name, $class)
  53736. {
  53737. if (!class_exists($class)) {
  53738. throw new InvalidArgumentException('Unknown constraint ' . $name);
  53739. }
  53740. if (!in_array('JsonSchema\Constraints\ConstraintInterface', class_implements($class))) {
  53741. throw new InvalidArgumentException('Invalid class ' . $name);
  53742. }
  53743. $this->constraintMap[$name] = $class;
  53744. return $this;
  53745. }
  53746. public function createInstanceFor($constraintName)
  53747. {
  53748. if (!isset($this->constraintMap[$constraintName])) {
  53749. throw new InvalidArgumentException('Unknown constraint ' . $constraintName);
  53750. }
  53751. if (!isset($this->instanceCache[$constraintName])) {
  53752. $this->instanceCache[$constraintName] = new $this->constraintMap[$constraintName]($this);
  53753. }
  53754. return clone $this->instanceCache[$constraintName];
  53755. }
  53756. public function getErrorContext()
  53757. {
  53758. return $this->errorContext;
  53759. }
  53760. public function setErrorContext($errorContext)
  53761. {
  53762. $this->errorContext = $errorContext;
  53763. }
  53764. }
  53765. <?php
  53766. namespace JsonSchema\Constraints;
  53767. use JsonSchema\Entity\JsonPointer;
  53768. use JsonSchema\Rfc3339;
  53769. class FormatConstraint extends Constraint
  53770. {
  53771. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  53772. {
  53773. if (!isset($schema->format) || $this->factory->getConfig(self::CHECK_MODE_DISABLE_FORMAT)) {
  53774. return;
  53775. }
  53776. switch ($schema->format) {
  53777. case 'date':
  53778. if (!$date = $this->validateDateTime($element, 'Y-m-d')) {
  53779. $this->addError($path, sprintf('Invalid date %s, expected format YYYY-MM-DD', json_encode($element)), 'format', array('format' => $schema->format));
  53780. }
  53781. break;
  53782. case 'time':
  53783. if (!$this->validateDateTime($element, 'H:i:s')) {
  53784. $this->addError($path, sprintf('Invalid time %s, expected format hh:mm:ss', json_encode($element)), 'format', array('format' => $schema->format));
  53785. }
  53786. break;
  53787. case 'date-time':
  53788. if (null === Rfc3339::createFromString($element)) {
  53789. $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));
  53790. }
  53791. break;
  53792. case 'utc-millisec':
  53793. if (!$this->validateDateTime($element, 'U')) {
  53794. $this->addError($path, sprintf('Invalid time %s, expected integer of milliseconds since Epoch', json_encode($element)), 'format', array('format' => $schema->format));
  53795. }
  53796. break;
  53797. case 'regex':
  53798. if (!$this->validateRegex($element)) {
  53799. $this->addError($path, 'Invalid regex format ' . $element, 'format', array('format' => $schema->format));
  53800. }
  53801. break;
  53802. case 'color':
  53803. if (!$this->validateColor($element)) {
  53804. $this->addError($path, 'Invalid color', 'format', array('format' => $schema->format));
  53805. }
  53806. break;
  53807. case 'style':
  53808. if (!$this->validateStyle($element)) {
  53809. $this->addError($path, 'Invalid style', 'format', array('format' => $schema->format));
  53810. }
  53811. break;
  53812. case 'phone':
  53813. if (!$this->validatePhone($element)) {
  53814. $this->addError($path, 'Invalid phone number', 'format', array('format' => $schema->format));
  53815. }
  53816. break;
  53817. case 'uri':
  53818. if (null === filter_var($element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE)) {
  53819. $this->addError($path, 'Invalid URL format', 'format', array('format' => $schema->format));
  53820. }
  53821. break;
  53822. case 'uriref':
  53823. case 'uri-reference':
  53824. if (null === filter_var($element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE)) {
  53825. if (substr($element, 0, 2) === '//') {
  53826. $validURL = filter_var('scheme:' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  53827. } elseif (substr($element, 0, 1) === '/') {
  53828. $validURL = filter_var('scheme://host' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  53829. } elseif (strlen($element)) {
  53830. $pathParts = explode('/', $element, 2);
  53831. if (strpos($pathParts[0], ':') !== false) {
  53832. $validURL = null;
  53833. } else {
  53834. $validURL = filter_var('scheme://host/' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  53835. }
  53836. } else {
  53837. $validURL = null;
  53838. }
  53839. if ($validURL === null) {
  53840. $this->addError($path, 'Invalid URL format', 'format', array('format' => $schema->format));
  53841. }
  53842. }
  53843. break;
  53844. case 'email':
  53845. $filterFlags = FILTER_NULL_ON_FAILURE;
  53846. if (defined('FILTER_FLAG_EMAIL_UNICODE')) {
  53847. $filterFlags |= constant('FILTER_FLAG_EMAIL_UNICODE');
  53848. }
  53849. if (null === filter_var($element, FILTER_VALIDATE_EMAIL, $filterFlags)) {
  53850. $this->addError($path, 'Invalid email', 'format', array('format' => $schema->format));
  53851. }
  53852. break;
  53853. case 'ip-address':
  53854. case 'ipv4':
  53855. if (null === filter_var($element, FILTER_VALIDATE_IP, FILTER_NULL_ON_FAILURE | FILTER_FLAG_IPV4)) {
  53856. $this->addError($path, 'Invalid IP address', 'format', array('format' => $schema->format));
  53857. }
  53858. break;
  53859. case 'ipv6':
  53860. if (null === filter_var($element, FILTER_VALIDATE_IP, FILTER_NULL_ON_FAILURE | FILTER_FLAG_IPV6)) {
  53861. $this->addError($path, 'Invalid IP address', 'format', array('format' => $schema->format));
  53862. }
  53863. break;
  53864. case 'host-name':
  53865. case 'hostname':
  53866. if (!$this->validateHostname($element)) {
  53867. $this->addError($path, 'Invalid hostname', 'format', array('format' => $schema->format));
  53868. }
  53869. break;
  53870. default:
  53871. break;
  53872. }
  53873. }
  53874. protected function validateDateTime($datetime, $format)
  53875. {
  53876. $dt = \DateTime::createFromFormat($format, $datetime);
  53877. if (!$dt) {
  53878. return false;
  53879. }
  53880. if ($datetime === $dt->format($format)) {
  53881. return true;
  53882. }
  53883. if ((strpos('u', $format) !== -1) && (preg_match('/\.\d+Z$/', $datetime))) {
  53884. return true;
  53885. }
  53886. return false;
  53887. }
  53888. protected function validateRegex($regex)
  53889. {
  53890. return false !== @preg_match('/' . $regex . '/u', '');
  53891. }
  53892. protected function validateColor($color)
  53893. {
  53894. if (in_array(strtolower($color), array('aqua', 'black', 'blue', 'fuchsia',
  53895. 'gray', 'green', 'lime', 'maroon', 'navy', 'olive', 'orange', 'purple',
  53896. 'red', 'silver', 'teal', 'white', 'yellow'))) {
  53897. return true;
  53898. }
  53899. return preg_match('/^#([a-f0-9]{3}|[a-f0-9]{6})$/i', $color);
  53900. }
  53901. protected function validateStyle($style)
  53902. {
  53903. $properties = explode(';', rtrim($style, ';'));
  53904. $invalidEntries = preg_grep('/^\s*[-a-z]+\s*:\s*.+$/i', $properties, PREG_GREP_INVERT);
  53905. return empty($invalidEntries);
  53906. }
  53907. protected function validatePhone($phone)
  53908. {
  53909. return preg_match('/^\+?(\(\d{3}\)|\d{3}) \d{3} \d{4}$/', $phone);
  53910. }
  53911. protected function validateHostname($host)
  53912. {
  53913. $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';
  53914. return preg_match($hostnameRegex, $host);
  53915. }
  53916. }
  53917. <?php
  53918. namespace JsonSchema\Constraints;
  53919. use JsonSchema\Entity\JsonPointer;
  53920. class NumberConstraint extends Constraint
  53921. {
  53922. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  53923. {
  53924. if (isset($schema->exclusiveMinimum)) {
  53925. if (isset($schema->minimum)) {
  53926. if ($schema->exclusiveMinimum && $element <= $schema->minimum) {
  53927. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'exclusiveMinimum', array('minimum' => $schema->minimum));
  53928. } elseif ($element < $schema->minimum) {
  53929. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'minimum', array('minimum' => $schema->minimum));
  53930. }
  53931. } else {
  53932. $this->addError($path, 'Use of exclusiveMinimum requires presence of minimum', 'missingMinimum');
  53933. }
  53934. } elseif (isset($schema->minimum) && $element < $schema->minimum) {
  53935. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'minimum', array('minimum' => $schema->minimum));
  53936. }
  53937. if (isset($schema->exclusiveMaximum)) {
  53938. if (isset($schema->maximum)) {
  53939. if ($schema->exclusiveMaximum && $element >= $schema->maximum) {
  53940. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'exclusiveMaximum', array('maximum' => $schema->maximum));
  53941. } elseif ($element > $schema->maximum) {
  53942. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'maximum', array('maximum' => $schema->maximum));
  53943. }
  53944. } else {
  53945. $this->addError($path, 'Use of exclusiveMaximum requires presence of maximum', 'missingMaximum');
  53946. }
  53947. } elseif (isset($schema->maximum) && $element > $schema->maximum) {
  53948. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'maximum', array('maximum' => $schema->maximum));
  53949. }
  53950. if (isset($schema->divisibleBy) && $this->fmod($element, $schema->divisibleBy) != 0) {
  53951. $this->addError($path, 'Is not divisible by ' . $schema->divisibleBy, 'divisibleBy', array('divisibleBy' => $schema->divisibleBy));
  53952. }
  53953. if (isset($schema->multipleOf) && $this->fmod($element, $schema->multipleOf) != 0) {
  53954. $this->addError($path, 'Must be a multiple of ' . $schema->multipleOf, 'multipleOf', array('multipleOf' => $schema->multipleOf));
  53955. }
  53956. $this->checkFormat($element, $schema, $path, $i);
  53957. }
  53958. private function fmod($number1, $number2)
  53959. {
  53960. $modulus = ($number1 - round($number1 / $number2) * $number2);
  53961. $precision = 0.0000000001;
  53962. if (-$precision < $modulus && $modulus < $precision) {
  53963. return 0.0;
  53964. }
  53965. return $modulus;
  53966. }
  53967. }
  53968. <?php
  53969. namespace JsonSchema\Constraints;
  53970. use JsonSchema\Entity\JsonPointer;
  53971. class ObjectConstraint extends Constraint
  53972. {
  53973. protected $appliedDefaults = array();
  53974. public function check(&$element, $schema = null, JsonPointer $path = null, $properties = null,
  53975. $additionalProp = null, $patternProperties = null, $appliedDefaults = array())
  53976. {
  53977. if ($element instanceof UndefinedConstraint) {
  53978. return;
  53979. }
  53980. $this->appliedDefaults = $appliedDefaults;
  53981. $matches = array();
  53982. if ($patternProperties) {
  53983. $matches = $this->validatePatternProperties($element, $path, $patternProperties);
  53984. }
  53985. if ($properties) {
  53986. $this->validateProperties($element, $properties, $path);
  53987. }
  53988. $this->validateElement($element, $matches, $schema, $path, $properties, $additionalProp);
  53989. }
  53990. public function validatePatternProperties($element, JsonPointer $path = null, $patternProperties)
  53991. {
  53992. $try = array('/', '#', '+', '~', '%');
  53993. $matches = array();
  53994. foreach ($patternProperties as $pregex => $schema) {
  53995. $delimiter = '/';
  53996. foreach ($try as $delimiter) {
  53997. if (strpos($pregex, $delimiter) === false) {
  53998. break;
  53999. }
  54000. }
  54001. if (@preg_match($delimiter . $pregex . $delimiter . 'u', '') === false) {
  54002. $this->addError($path, 'The pattern "' . $pregex . '" is invalid', 'pregex', array('pregex' => $pregex));
  54003. continue;
  54004. }
  54005. foreach ($element as $i => $value) {
  54006. if (preg_match($delimiter . $pregex . $delimiter . 'u', $i)) {
  54007. $matches[] = $i;
  54008. $this->checkUndefined($value, $schema ?: new \stdClass(), $path, $i, in_array($i, $this->appliedDefaults));
  54009. }
  54010. }
  54011. }
  54012. return $matches;
  54013. }
  54014. public function validateElement($element, $matches, $schema = null, JsonPointer $path = null,
  54015. $properties = null, $additionalProp = null)
  54016. {
  54017. $this->validateMinMaxConstraint($element, $schema, $path);
  54018. foreach ($element as $i => $value) {
  54019. $definition = $this->getProperty($properties, $i);
  54020. if (!in_array($i, $matches) && $additionalProp === false && $this->inlineSchemaProperty !== $i && !$definition) {
  54021. $this->addError($path, 'The property ' . $i . ' is not defined and the definition does not allow additional properties', 'additionalProp');
  54022. }
  54023. if (!in_array($i, $matches) && $additionalProp && !$definition) {
  54024. if ($additionalProp === true) {
  54025. $this->checkUndefined($value, null, $path, $i, in_array($i, $this->appliedDefaults));
  54026. } else {
  54027. $this->checkUndefined($value, $additionalProp, $path, $i, in_array($i, $this->appliedDefaults));
  54028. }
  54029. }
  54030. $require = $this->getProperty($definition, 'requires');
  54031. if ($require && !$this->getProperty($element, $require)) {
  54032. $this->addError($path, 'The presence of the property ' . $i . ' requires that ' . $require . ' also be present', 'requires');
  54033. }
  54034. $property = $this->getProperty($element, $i, $this->factory->createInstanceFor('undefined'));
  54035. if (is_object($property)) {
  54036. $this->validateMinMaxConstraint(!($property instanceof UndefinedConstraint) ? $property : $element, $definition, $path);
  54037. }
  54038. }
  54039. }
  54040. public function validateProperties(&$element, $properties = null, JsonPointer $path = null)
  54041. {
  54042. $undefinedConstraint = $this->factory->createInstanceFor('undefined');
  54043. foreach ($properties as $i => $value) {
  54044. $property = &$this->getProperty($element, $i, $undefinedConstraint);
  54045. $definition = $this->getProperty($properties, $i);
  54046. if (is_object($definition)) {
  54047. $this->checkUndefined($property, $definition, $path, $i, in_array($i, $this->appliedDefaults));
  54048. }
  54049. }
  54050. }
  54051. protected function &getProperty(&$element, $property, $fallback = null)
  54052. {
  54053. if (is_array($element) && (isset($element[$property]) || array_key_exists($property, $element)) ) {
  54054. return $element[$property];
  54055. } elseif (is_object($element) && property_exists($element, $property)) {
  54056. return $element->$property;
  54057. }
  54058. return $fallback;
  54059. }
  54060. protected function validateMinMaxConstraint($element, $objectDefinition, JsonPointer $path = null)
  54061. {
  54062. if (isset($objectDefinition->minProperties) && !is_object($objectDefinition->minProperties)) {
  54063. if ($this->getTypeCheck()->propertyCount($element) < $objectDefinition->minProperties) {
  54064. $this->addError($path, 'Must contain a minimum of ' . $objectDefinition->minProperties . ' properties', 'minProperties', array('minProperties' => $objectDefinition->minProperties));
  54065. }
  54066. }
  54067. if (isset($objectDefinition->maxProperties) && !is_object($objectDefinition->maxProperties)) {
  54068. if ($this->getTypeCheck()->propertyCount($element) > $objectDefinition->maxProperties) {
  54069. $this->addError($path, 'Must contain no more than ' . $objectDefinition->maxProperties . ' properties', 'maxProperties', array('maxProperties' => $objectDefinition->maxProperties));
  54070. }
  54071. }
  54072. }
  54073. }
  54074. <?php
  54075. namespace JsonSchema\Constraints;
  54076. use JsonSchema\Entity\JsonPointer;
  54077. use JsonSchema\Exception\InvalidArgumentException;
  54078. use JsonSchema\Exception\InvalidSchemaException;
  54079. use JsonSchema\Exception\RuntimeException;
  54080. use JsonSchema\Validator;
  54081. class SchemaConstraint extends Constraint
  54082. {
  54083. const DEFAULT_SCHEMA_SPEC = 'http://json-schema.org/draft-04/schema#';
  54084. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  54085. {
  54086. if ($schema !== null) {
  54087. $validationSchema = $schema;
  54088. } elseif ($this->getTypeCheck()->propertyExists($element, $this->inlineSchemaProperty)) {
  54089. $validationSchema = $this->getTypeCheck()->propertyGet($element, $this->inlineSchemaProperty);
  54090. } else {
  54091. throw new InvalidArgumentException('no schema found to verify against');
  54092. }
  54093. if (is_array($validationSchema)) {
  54094. $validationSchema = BaseConstraint::arrayToObjectRecursive($validationSchema);
  54095. }
  54096. if ($this->factory->getConfig(self::CHECK_MODE_VALIDATE_SCHEMA)) {
  54097. if (!$this->getTypeCheck()->isObject($validationSchema)) {
  54098. throw new RuntimeException('Cannot validate the schema of a non-object');
  54099. }
  54100. if ($this->getTypeCheck()->propertyExists($validationSchema, '$schema')) {
  54101. $schemaSpec = $this->getTypeCheck()->propertyGet($validationSchema, '$schema');
  54102. } else {
  54103. $schemaSpec = self::DEFAULT_SCHEMA_SPEC;
  54104. }
  54105. $schemaStorage = $this->factory->getSchemaStorage();
  54106. if (!$this->getTypeCheck()->isObject($schemaSpec)) {
  54107. $schemaSpec = $schemaStorage->getSchema($schemaSpec);
  54108. }
  54109. $initialErrorCount = $this->numErrors();
  54110. $initialConfig = $this->factory->getConfig();
  54111. $initialContext = $this->factory->getErrorContext();
  54112. $this->factory->removeConfig(self::CHECK_MODE_VALIDATE_SCHEMA | self::CHECK_MODE_APPLY_DEFAULTS);
  54113. $this->factory->addConfig(self::CHECK_MODE_TYPE_CAST);
  54114. $this->factory->setErrorContext(Validator::ERROR_SCHEMA_VALIDATION);
  54115. try {
  54116. $this->check($validationSchema, $schemaSpec);
  54117. } catch (\Exception $e) {
  54118. if ($this->factory->getConfig(self::CHECK_MODE_EXCEPTIONS)) {
  54119. throw new InvalidSchemaException('Schema did not pass validation', 0, $e);
  54120. }
  54121. }
  54122. if ($this->numErrors() > $initialErrorCount) {
  54123. $this->addError($path, 'Schema is not valid', 'schema');
  54124. }
  54125. $this->factory->setConfig($initialConfig);
  54126. $this->factory->setErrorContext($initialContext);
  54127. }
  54128. $this->checkUndefined($element, $validationSchema, $path, $i);
  54129. }
  54130. }
  54131. <?php
  54132. namespace JsonSchema\Constraints;
  54133. use JsonSchema\Entity\JsonPointer;
  54134. class StringConstraint extends Constraint
  54135. {
  54136. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  54137. {
  54138. if (isset($schema->maxLength) && $this->strlen($element) > $schema->maxLength) {
  54139. $this->addError($path, 'Must be at most ' . $schema->maxLength . ' characters long', 'maxLength', array(
  54140. 'maxLength' => $schema->maxLength,
  54141. ));
  54142. }
  54143. if (isset($schema->minLength) && $this->strlen($element) < $schema->minLength) {
  54144. $this->addError($path, 'Must be at least ' . $schema->minLength . ' characters long', 'minLength', array(
  54145. 'minLength' => $schema->minLength,
  54146. ));
  54147. }
  54148. if (isset($schema->pattern) && !preg_match('#' . str_replace('#', '\\#', $schema->pattern) . '#u', $element)) {
  54149. $this->addError($path, 'Does not match the regex pattern ' . $schema->pattern, 'pattern', array(
  54150. 'pattern' => $schema->pattern,
  54151. ));
  54152. }
  54153. $this->checkFormat($element, $schema, $path, $i);
  54154. }
  54155. private function strlen($string)
  54156. {
  54157. if (extension_loaded('mbstring')) {
  54158. return mb_strlen($string, mb_detect_encoding($string));
  54159. }
  54160. return strlen($string);
  54161. }
  54162. }
  54163. <?php
  54164. namespace JsonSchema\Constraints\TypeCheck;
  54165. class LooseTypeCheck implements TypeCheckInterface
  54166. {
  54167. public static function isObject($value)
  54168. {
  54169. return
  54170. is_object($value) ||
  54171. (is_array($value) && (count($value) == 0 || self::isAssociativeArray($value)));
  54172. }
  54173. public static function isArray($value)
  54174. {
  54175. return
  54176. is_array($value) &&
  54177. (count($value) == 0 || !self::isAssociativeArray($value));
  54178. }
  54179. public static function propertyGet($value, $property)
  54180. {
  54181. if (is_object($value)) {
  54182. return $value->{$property};
  54183. }
  54184. return $value[$property];
  54185. }
  54186. public static function propertySet(&$value, $property, $data)
  54187. {
  54188. if (is_object($value)) {
  54189. $value->{$property} = $data;
  54190. } else {
  54191. $value[$property] = $data;
  54192. }
  54193. }
  54194. public static function propertyExists($value, $property)
  54195. {
  54196. if (is_object($value)) {
  54197. return property_exists($value, $property);
  54198. }
  54199. return array_key_exists($property, $value);
  54200. }
  54201. public static function propertyCount($value)
  54202. {
  54203. if (is_object($value)) {
  54204. return count(get_object_vars($value));
  54205. }
  54206. return count($value);
  54207. }
  54208. private static function isAssociativeArray($arr)
  54209. {
  54210. return array_keys($arr) !== range(0, count($arr) - 1);
  54211. }
  54212. }
  54213. <?php
  54214. namespace JsonSchema\Constraints\TypeCheck;
  54215. class StrictTypeCheck implements TypeCheckInterface
  54216. {
  54217. public static function isObject($value)
  54218. {
  54219. return is_object($value);
  54220. }
  54221. public static function isArray($value)
  54222. {
  54223. return is_array($value);
  54224. }
  54225. public static function propertyGet($value, $property)
  54226. {
  54227. return $value->{$property};
  54228. }
  54229. public static function propertySet(&$value, $property, $data)
  54230. {
  54231. $value->{$property} = $data;
  54232. }
  54233. public static function propertyExists($value, $property)
  54234. {
  54235. return property_exists($value, $property);
  54236. }
  54237. public static function propertyCount($value)
  54238. {
  54239. if (!is_object($value)) {
  54240. return 0;
  54241. }
  54242. return count(get_object_vars($value));
  54243. }
  54244. }
  54245. <?php
  54246. namespace JsonSchema\Constraints\TypeCheck;
  54247. interface TypeCheckInterface
  54248. {
  54249. public static function isObject($value);
  54250. public static function isArray($value);
  54251. public static function propertyGet($value, $property);
  54252. public static function propertySet(&$value, $property, $data);
  54253. public static function propertyExists($value, $property);
  54254. public static function propertyCount($value);
  54255. }
  54256. <?php
  54257. namespace JsonSchema\Constraints;
  54258. use JsonSchema\Entity\JsonPointer;
  54259. use JsonSchema\Exception\InvalidArgumentException;
  54260. use UnexpectedValueException as StandardUnexpectedValueException;
  54261. class TypeConstraint extends Constraint
  54262. {
  54263. public static $wording = array(
  54264. 'integer' => 'an integer',
  54265. 'number' => 'a number',
  54266. 'boolean' => 'a boolean',
  54267. 'object' => 'an object',
  54268. 'array' => 'an array',
  54269. 'string' => 'a string',
  54270. 'null' => 'a null',
  54271. 'any' => null,
  54272. 0 => null,
  54273. );
  54274. public function check(&$value = null, $schema = null, JsonPointer $path = null, $i = null)
  54275. {
  54276. $type = isset($schema->type) ? $schema->type : null;
  54277. $isValid = false;
  54278. $wording = array();
  54279. if (is_array($type)) {
  54280. $this->validateTypesArray($value, $type, $wording, $isValid, $path);
  54281. } elseif (is_object($type)) {
  54282. $this->checkUndefined($value, $type, $path);
  54283. return;
  54284. } else {
  54285. $isValid = $this->validateType($value, $type);
  54286. }
  54287. if ($isValid === false) {
  54288. if (!is_array($type)) {
  54289. $this->validateTypeNameWording($type);
  54290. $wording[] = self::$wording[$type];
  54291. }
  54292. $this->addError($path, ucwords(gettype($value)) . ' value found, but ' .
  54293. $this->implodeWith($wording, ', ', 'or') . ' is required', 'type');
  54294. }
  54295. }
  54296. protected function validateTypesArray(&$value, array $type, &$validTypesWording, &$isValid, $path)
  54297. {
  54298. foreach ($type as $tp) {
  54299. if (is_object($tp)) {
  54300. if (!$isValid) {
  54301. $validator = $this->factory->createInstanceFor('type');
  54302. $subSchema = new \stdClass();
  54303. $subSchema->type = $tp;
  54304. $validator->check($value, $subSchema, $path, null);
  54305. $error = $validator->getErrors();
  54306. $isValid = !(bool) $error;
  54307. $validTypesWording[] = self::$wording['object'];
  54308. }
  54309. } else {
  54310. $this->validateTypeNameWording($tp);
  54311. $validTypesWording[] = self::$wording[$tp];
  54312. if (!$isValid) {
  54313. $isValid = $this->validateType($value, $tp);
  54314. }
  54315. }
  54316. }
  54317. }
  54318. protected function implodeWith(array $elements, $delimiter = ', ', $listEnd = false)
  54319. {
  54320. if ($listEnd === false || !isset($elements[1])) {
  54321. return implode($delimiter, $elements);
  54322. }
  54323. $lastElement = array_slice($elements, -1);
  54324. $firsElements = join($delimiter, array_slice($elements, 0, -1));
  54325. $implodedElements = array_merge(array($firsElements), $lastElement);
  54326. return join(" $listEnd ", $implodedElements);
  54327. }
  54328. protected function validateTypeNameWording($type)
  54329. {
  54330. if (!isset(self::$wording[$type])) {
  54331. throw new StandardUnexpectedValueException(
  54332. sprintf(
  54333. 'No wording for %s available, expected wordings are: [%s]',
  54334. var_export($type, true),
  54335. implode(', ', array_filter(self::$wording)))
  54336. );
  54337. }
  54338. }
  54339. protected function validateType(&$value, $type)
  54340. {
  54341. if (!$type) {
  54342. return true;
  54343. }
  54344. if ('any' === $type) {
  54345. return true;
  54346. }
  54347. if ('object' === $type) {
  54348. return $this->getTypeCheck()->isObject($value);
  54349. }
  54350. if ('array' === $type) {
  54351. return $this->getTypeCheck()->isArray($value);
  54352. }
  54353. $coerce = $this->factory->getConfig(Constraint::CHECK_MODE_COERCE_TYPES);
  54354. if ('integer' === $type) {
  54355. if ($coerce) {
  54356. $value = $this->toInteger($value);
  54357. }
  54358. return is_int($value);
  54359. }
  54360. if ('number' === $type) {
  54361. if ($coerce) {
  54362. $value = $this->toNumber($value);
  54363. }
  54364. return is_numeric($value) && !is_string($value);
  54365. }
  54366. if ('boolean' === $type) {
  54367. if ($coerce) {
  54368. $value = $this->toBoolean($value);
  54369. }
  54370. return is_bool($value);
  54371. }
  54372. if ('string' === $type) {
  54373. return is_string($value);
  54374. }
  54375. if ('email' === $type) {
  54376. return is_string($value);
  54377. }
  54378. if ('null' === $type) {
  54379. return is_null($value);
  54380. }
  54381. throw new InvalidArgumentException((is_object($value) ? 'object' : $value) . ' is an invalid type for ' . $type);
  54382. }
  54383. protected function toBoolean($value)
  54384. {
  54385. if ($value === 'true') {
  54386. return true;
  54387. }
  54388. if ($value === 'false') {
  54389. return false;
  54390. }
  54391. return $value;
  54392. }
  54393. protected function toNumber($value)
  54394. {
  54395. if (is_numeric($value)) {
  54396. return $value + 0;
  54397. }
  54398. return $value;
  54399. }
  54400. protected function toInteger($value)
  54401. {
  54402. if (is_numeric($value) && (int) $value == $value) {
  54403. return (int) $value;
  54404. }
  54405. return $value;
  54406. }
  54407. }
  54408. <?php
  54409. namespace JsonSchema\Constraints;
  54410. use JsonSchema\Constraints\TypeCheck\LooseTypeCheck;
  54411. use JsonSchema\Entity\JsonPointer;
  54412. use JsonSchema\Exception\ValidationException;
  54413. use JsonSchema\Uri\UriResolver;
  54414. class UndefinedConstraint extends Constraint
  54415. {
  54416. protected $appliedDefaults = array();
  54417. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null, $fromDefault = false)
  54418. {
  54419. if (is_null($schema) || !is_object($schema)) {
  54420. return;
  54421. }
  54422. $path = $this->incrementPath($path ?: new JsonPointer(''), $i);
  54423. if ($fromDefault) {
  54424. $path->setFromDefault();
  54425. }
  54426. $this->validateCommonProperties($value, $schema, $path, $i);
  54427. $this->validateOfProperties($value, $schema, $path, '');
  54428. $this->validateTypes($value, $schema, $path, $i);
  54429. }
  54430. public function validateTypes(&$value, $schema, JsonPointer $path, $i = null)
  54431. {
  54432. if ($this->getTypeCheck()->isArray($value)) {
  54433. $this->checkArray($value, $schema, $path, $i);
  54434. }
  54435. if (LooseTypeCheck::isObject($value)) {
  54436. $this->checkObject(
  54437. $value,
  54438. $schema,
  54439. $path,
  54440. isset($schema->properties) ? $schema->properties : null,
  54441. isset($schema->additionalProperties) ? $schema->additionalProperties : null,
  54442. isset($schema->patternProperties) ? $schema->patternProperties : null,
  54443. $this->appliedDefaults
  54444. );
  54445. }
  54446. if (is_string($value)) {
  54447. $this->checkString($value, $schema, $path, $i);
  54448. }
  54449. if (is_numeric($value)) {
  54450. $this->checkNumber($value, $schema, $path, $i);
  54451. }
  54452. if (isset($schema->enum)) {
  54453. $this->checkEnum($value, $schema, $path, $i);
  54454. }
  54455. }
  54456. protected function validateCommonProperties(&$value, $schema, JsonPointer $path, $i = '')
  54457. {
  54458. if (isset($schema->extends)) {
  54459. if (is_string($schema->extends)) {
  54460. $schema->extends = $this->validateUri($schema, $schema->extends);
  54461. }
  54462. if (is_array($schema->extends)) {
  54463. foreach ($schema->extends as $extends) {
  54464. $this->checkUndefined($value, $extends, $path, $i);
  54465. }
  54466. } else {
  54467. $this->checkUndefined($value, $schema->extends, $path, $i);
  54468. }
  54469. }
  54470. if (!$path->fromDefault()) {
  54471. $this->applyDefaultValues($value, $schema, $path);
  54472. }
  54473. if ($this->getTypeCheck()->isObject($value)) {
  54474. if (!($value instanceof self) && isset($schema->required) && is_array($schema->required)) {
  54475. foreach ($schema->required as $required) {
  54476. if (!$this->getTypeCheck()->propertyExists($value, $required)) {
  54477. $this->addError(
  54478. $this->incrementPath($path ?: new JsonPointer(''), $required),
  54479. 'The property ' . $required . ' is required',
  54480. 'required'
  54481. );
  54482. }
  54483. }
  54484. } elseif (isset($schema->required) && !is_array($schema->required)) {
  54485. if ($schema->required && $value instanceof self) {
  54486. $propertyPaths = $path->getPropertyPaths();
  54487. $propertyName = end($propertyPaths);
  54488. $this->addError(
  54489. $path,
  54490. 'The property ' . $propertyName . ' is required',
  54491. 'required'
  54492. );
  54493. }
  54494. } else {
  54495. if ($value instanceof self) {
  54496. return;
  54497. }
  54498. }
  54499. }
  54500. if (!($value instanceof self)) {
  54501. $this->checkType($value, $schema, $path, $i);
  54502. }
  54503. if (isset($schema->disallow)) {
  54504. $initErrors = $this->getErrors();
  54505. $typeSchema = new \stdClass();
  54506. $typeSchema->type = $schema->disallow;
  54507. $this->checkType($value, $typeSchema, $path);
  54508. if (count($this->getErrors()) == count($initErrors)) {
  54509. $this->addError($path, 'Disallowed value was matched', 'disallow');
  54510. } else {
  54511. $this->errors = $initErrors;
  54512. }
  54513. }
  54514. if (isset($schema->not)) {
  54515. $initErrors = $this->getErrors();
  54516. $this->checkUndefined($value, $schema->not, $path, $i);
  54517. if (count($this->getErrors()) == count($initErrors)) {
  54518. $this->addError($path, 'Matched a schema which it should not', 'not');
  54519. } else {
  54520. $this->errors = $initErrors;
  54521. }
  54522. }
  54523. if (isset($schema->dependencies) && $this->getTypeCheck()->isObject($value)) {
  54524. $this->validateDependencies($value, $schema->dependencies, $path);
  54525. }
  54526. }
  54527. private function shouldApplyDefaultValue($requiredOnly, $schema, $name = null, $parentSchema = null)
  54528. {
  54529. if (!$requiredOnly) {
  54530. return true;
  54531. }
  54532. if (
  54533. $name !== null
  54534. && isset($parentSchema->required)
  54535. && is_array($parentSchema->required)
  54536. && in_array($name, $parentSchema->required)
  54537. ) {
  54538. return true;
  54539. }
  54540. if (isset($schema->required) && !is_array($schema->required) && $schema->required) {
  54541. return true;
  54542. }
  54543. return false;
  54544. }
  54545. protected function applyDefaultValues(&$value, $schema, $path)
  54546. {
  54547. if (!$this->factory->getConfig(self::CHECK_MODE_APPLY_DEFAULTS)) {
  54548. return;
  54549. }
  54550. $requiredOnly = $this->factory->getConfig(self::CHECK_MODE_ONLY_REQUIRED_DEFAULTS);
  54551. if (isset($schema->properties) && LooseTypeCheck::isObject($value)) {
  54552. foreach ($schema->properties as $currentProperty => $propertyDefinition) {
  54553. $propertyDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($propertyDefinition);
  54554. if (
  54555. !LooseTypeCheck::propertyExists($value, $currentProperty)
  54556. && property_exists($propertyDefinition, 'default')
  54557. && $this->shouldApplyDefaultValue($requiredOnly, $propertyDefinition, $currentProperty, $schema)
  54558. ) {
  54559. if (is_object($propertyDefinition->default)) {
  54560. LooseTypeCheck::propertySet($value, $currentProperty, clone $propertyDefinition->default);
  54561. } else {
  54562. LooseTypeCheck::propertySet($value, $currentProperty, $propertyDefinition->default);
  54563. }
  54564. $this->appliedDefaults[] = $currentProperty;
  54565. }
  54566. }
  54567. } elseif (isset($schema->items) && LooseTypeCheck::isArray($value)) {
  54568. $items = array();
  54569. if (LooseTypeCheck::isArray($schema->items)) {
  54570. $items = $schema->items;
  54571. } elseif (isset($schema->minItems) && count($value) < $schema->minItems) {
  54572. $items = array_fill(count($value), $schema->minItems - count($value), $schema->items);
  54573. }
  54574. foreach ($items as $currentItem => $itemDefinition) {
  54575. $itemDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($itemDefinition);
  54576. if (
  54577. !array_key_exists($currentItem, $value)
  54578. && property_exists($itemDefinition, 'default')
  54579. && $this->shouldApplyDefaultValue($requiredOnly, $itemDefinition)) {
  54580. if (is_object($itemDefinition->default)) {
  54581. $value[$currentItem] = clone $itemDefinition->default;
  54582. } else {
  54583. $value[$currentItem] = $itemDefinition->default;
  54584. }
  54585. }
  54586. $path->setFromDefault();
  54587. }
  54588. } elseif (
  54589. $value instanceof self
  54590. && property_exists($schema, 'default')
  54591. && $this->shouldApplyDefaultValue($requiredOnly, $schema)) {
  54592. $value = is_object($schema->default) ? clone $schema->default : $schema->default;
  54593. $path->setFromDefault();
  54594. }
  54595. }
  54596. protected function validateOfProperties(&$value, $schema, JsonPointer $path, $i = '')
  54597. {
  54598. if ($value instanceof self) {
  54599. return;
  54600. }
  54601. if (isset($schema->allOf)) {
  54602. $isValid = true;
  54603. foreach ($schema->allOf as $allOf) {
  54604. $initErrors = $this->getErrors();
  54605. $this->checkUndefined($value, $allOf, $path, $i);
  54606. $isValid = $isValid && (count($this->getErrors()) == count($initErrors));
  54607. }
  54608. if (!$isValid) {
  54609. $this->addError($path, 'Failed to match all schemas', 'allOf');
  54610. }
  54611. }
  54612. if (isset($schema->anyOf)) {
  54613. $isValid = false;
  54614. $startErrors = $this->getErrors();
  54615. $caughtException = null;
  54616. foreach ($schema->anyOf as $anyOf) {
  54617. $initErrors = $this->getErrors();
  54618. try {
  54619. $this->checkUndefined($value, $anyOf, $path, $i);
  54620. if ($isValid = (count($this->getErrors()) == count($initErrors))) {
  54621. break;
  54622. }
  54623. } catch (ValidationException $e) {
  54624. $isValid = false;
  54625. }
  54626. }
  54627. if (!$isValid) {
  54628. $this->addError($path, 'Failed to match at least one schema', 'anyOf');
  54629. } else {
  54630. $this->errors = $startErrors;
  54631. }
  54632. }
  54633. if (isset($schema->oneOf)) {
  54634. $allErrors = array();
  54635. $matchedSchemas = 0;
  54636. $startErrors = $this->getErrors();
  54637. foreach ($schema->oneOf as $oneOf) {
  54638. try {
  54639. $this->errors = array();
  54640. $this->checkUndefined($value, $oneOf, $path, $i);
  54641. if (count($this->getErrors()) == 0) {
  54642. $matchedSchemas++;
  54643. }
  54644. $allErrors = array_merge($allErrors, array_values($this->getErrors()));
  54645. } catch (ValidationException $e) {
  54646. }
  54647. }
  54648. if ($matchedSchemas !== 1) {
  54649. $this->addErrors(array_merge($allErrors, $startErrors));
  54650. $this->addError($path, 'Failed to match exactly one schema', 'oneOf');
  54651. } else {
  54652. $this->errors = $startErrors;
  54653. }
  54654. }
  54655. }
  54656. protected function validateDependencies($value, $dependencies, JsonPointer $path, $i = '')
  54657. {
  54658. foreach ($dependencies as $key => $dependency) {
  54659. if ($this->getTypeCheck()->propertyExists($value, $key)) {
  54660. if (is_string($dependency)) {
  54661. if (!$this->getTypeCheck()->propertyExists($value, $dependency)) {
  54662. $this->addError($path, "$key depends on $dependency and $dependency is missing", 'dependencies');
  54663. }
  54664. } elseif (is_array($dependency)) {
  54665. foreach ($dependency as $d) {
  54666. if (!$this->getTypeCheck()->propertyExists($value, $d)) {
  54667. $this->addError($path, "$key depends on $d and $d is missing", 'dependencies');
  54668. }
  54669. }
  54670. } elseif (is_object($dependency)) {
  54671. $this->checkUndefined($value, $dependency, $path, $i);
  54672. }
  54673. }
  54674. }
  54675. }
  54676. protected function validateUri($schema, $schemaUri = null)
  54677. {
  54678. $resolver = new UriResolver();
  54679. $retriever = $this->factory->getUriRetriever();
  54680. $jsonSchema = null;
  54681. if ($resolver->isValid($schemaUri)) {
  54682. $schemaId = property_exists($schema, 'id') ? $schema->id : null;
  54683. $jsonSchema = $retriever->retrieve($schemaId, $schemaUri);
  54684. }
  54685. return $jsonSchema;
  54686. }
  54687. }
  54688. <?php
  54689. namespace JsonSchema\Entity;
  54690. use JsonSchema\Exception\InvalidArgumentException;
  54691. class JsonPointer
  54692. {
  54693. private $filename;
  54694. private $propertyPaths = array();
  54695. private $fromDefault = false;
  54696. public function __construct($value)
  54697. {
  54698. if (!is_string($value)) {
  54699. throw new InvalidArgumentException('Ref value must be a string');
  54700. }
  54701. $splitRef = explode('#', $value, 2);
  54702. $this->filename = $splitRef[0];
  54703. if (array_key_exists(1, $splitRef)) {
  54704. $this->propertyPaths = $this->decodePropertyPaths($splitRef[1]);
  54705. }
  54706. }
  54707. private function decodePropertyPaths($propertyPathString)
  54708. {
  54709. $paths = array();
  54710. foreach (explode('/', trim($propertyPathString, '/')) as $path) {
  54711. $path = $this->decodePath($path);
  54712. if (is_string($path) && '' !== $path) {
  54713. $paths[] = $path;
  54714. }
  54715. }
  54716. return $paths;
  54717. }
  54718. private function encodePropertyPaths()
  54719. {
  54720. return array_map(
  54721. array($this, 'encodePath'),
  54722. $this->getPropertyPaths()
  54723. );
  54724. }
  54725. private function decodePath($path)
  54726. {
  54727. return strtr($path, array('~1' => '/', '~0' => '~', '%25' => '%'));
  54728. }
  54729. private function encodePath($path)
  54730. {
  54731. return strtr($path, array('/' => '~1', '~' => '~0', '%' => '%25'));
  54732. }
  54733. public function getFilename()
  54734. {
  54735. return $this->filename;
  54736. }
  54737. public function getPropertyPaths()
  54738. {
  54739. return $this->propertyPaths;
  54740. }
  54741. public function withPropertyPaths(array $propertyPaths)
  54742. {
  54743. $new = clone $this;
  54744. $new->propertyPaths = $propertyPaths;
  54745. return $new;
  54746. }
  54747. public function getPropertyPathAsString()
  54748. {
  54749. return rtrim('#/' . implode('/', $this->encodePropertyPaths()), '/');
  54750. }
  54751. public function __toString()
  54752. {
  54753. return $this->getFilename() . $this->getPropertyPathAsString();
  54754. }
  54755. public function setFromDefault()
  54756. {
  54757. $this->fromDefault = true;
  54758. }
  54759. public function fromDefault()
  54760. {
  54761. return $this->fromDefault;
  54762. }
  54763. }
  54764. <?php
  54765. namespace JsonSchema\Exception;
  54766. interface ExceptionInterface
  54767. {
  54768. }
  54769. <?php
  54770. namespace JsonSchema\Exception;
  54771. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  54772. {
  54773. }
  54774. <?php
  54775. namespace JsonSchema\Exception;
  54776. class InvalidConfigException extends RuntimeException
  54777. {
  54778. }
  54779. <?php
  54780. namespace JsonSchema\Exception;
  54781. class InvalidSchemaException extends RuntimeException
  54782. {
  54783. }
  54784. <?php
  54785. namespace JsonSchema\Exception;
  54786. class InvalidSchemaMediaTypeException extends RuntimeException
  54787. {
  54788. }
  54789. <?php
  54790. namespace JsonSchema\Exception;
  54791. class InvalidSourceUriException extends InvalidArgumentException
  54792. {
  54793. }
  54794. <?php
  54795. namespace JsonSchema\Exception;
  54796. class JsonDecodingException extends RuntimeException
  54797. {
  54798. public function __construct($code = JSON_ERROR_NONE, \Exception $previous = null)
  54799. {
  54800. switch ($code) {
  54801. case JSON_ERROR_DEPTH:
  54802. $message = 'The maximum stack depth has been exceeded';
  54803. break;
  54804. case JSON_ERROR_STATE_MISMATCH:
  54805. $message = 'Invalid or malformed JSON';
  54806. break;
  54807. case JSON_ERROR_CTRL_CHAR:
  54808. $message = 'Control character error, possibly incorrectly encoded';
  54809. break;
  54810. case JSON_ERROR_UTF8:
  54811. $message = 'Malformed UTF-8 characters, possibly incorrectly encoded';
  54812. break;
  54813. case JSON_ERROR_SYNTAX:
  54814. $message = 'JSON syntax is malformed';
  54815. break;
  54816. default:
  54817. $message = 'Syntax error';
  54818. }
  54819. parent::__construct($message, $code, $previous);
  54820. }
  54821. }
  54822. <?php
  54823. namespace JsonSchema\Exception;
  54824. class ResourceNotFoundException extends RuntimeException
  54825. {
  54826. }
  54827. <?php
  54828. namespace JsonSchema\Exception;
  54829. class RuntimeException extends \RuntimeException implements ExceptionInterface
  54830. {
  54831. }
  54832. <?php
  54833. namespace JsonSchema\Exception;
  54834. class UnresolvableJsonPointerException extends InvalidArgumentException
  54835. {
  54836. }
  54837. <?php
  54838. namespace JsonSchema\Exception;
  54839. class UriResolverException extends RuntimeException
  54840. {
  54841. }
  54842. <?php
  54843. namespace JsonSchema\Exception;
  54844. class ValidationException extends RuntimeException
  54845. {
  54846. }
  54847. <?php
  54848. namespace JsonSchema\Iterator;
  54849. class ObjectIterator implements \Iterator, \Countable
  54850. {
  54851. private $object;
  54852. private $position = 0;
  54853. private $data = array();
  54854. private $initialized = false;
  54855. public function __construct($object)
  54856. {
  54857. $this->object = $object;
  54858. }
  54859. public function current()
  54860. {
  54861. $this->initialize();
  54862. return $this->data[$this->position];
  54863. }
  54864. public function next()
  54865. {
  54866. $this->initialize();
  54867. $this->position++;
  54868. }
  54869. public function key()
  54870. {
  54871. $this->initialize();
  54872. return $this->position;
  54873. }
  54874. public function valid()
  54875. {
  54876. $this->initialize();
  54877. return isset($this->data[$this->position]);
  54878. }
  54879. public function rewind()
  54880. {
  54881. $this->initialize();
  54882. $this->position = 0;
  54883. }
  54884. public function count()
  54885. {
  54886. $this->initialize();
  54887. return count($this->data);
  54888. }
  54889. private function initialize()
  54890. {
  54891. if (!$this->initialized) {
  54892. $this->data = $this->buildDataFromObject($this->object);
  54893. $this->initialized = true;
  54894. }
  54895. }
  54896. private function buildDataFromObject($object)
  54897. {
  54898. $result = array();
  54899. $stack = new \SplStack();
  54900. $stack->push($object);
  54901. while (!$stack->isEmpty()) {
  54902. $current = $stack->pop();
  54903. if (is_object($current)) {
  54904. array_push($result, $current);
  54905. }
  54906. foreach ($this->getDataFromItem($current) as $propertyName => $propertyValue) {
  54907. if (is_object($propertyValue) || is_array($propertyValue)) {
  54908. $stack->push($propertyValue);
  54909. }
  54910. }
  54911. }
  54912. return $result;
  54913. }
  54914. private function getDataFromItem($item)
  54915. {
  54916. if (!is_object($item) && !is_array($item)) {
  54917. return array();
  54918. }
  54919. return is_object($item) ? get_object_vars($item) : $item;
  54920. }
  54921. }
  54922. <?php
  54923. namespace JsonSchema;
  54924. class Rfc3339
  54925. {
  54926. const REGEX = '/^(\d{4}-\d{2}-\d{2}[T ]{1}\d{2}:\d{2}:\d{2})(\.\d+)?(Z|([+-]\d{2}):?(\d{2}))$/';
  54927. public static function createFromString($string)
  54928. {
  54929. if (!preg_match(self::REGEX, strtoupper($string), $matches)) {
  54930. return null;
  54931. }
  54932. $dateAndTime = $matches[1];
  54933. $microseconds = $matches[2] ?: '.000000';
  54934. $timeZone = 'Z' !== $matches[3] ? $matches[4] . ':' . $matches[5] : '+00:00';
  54935. $dateFormat = strpos($dateAndTime, 'T') === false ? 'Y-m-d H:i:s.uP' : 'Y-m-d\TH:i:s.uP';
  54936. $dateTime = \DateTime::createFromFormat($dateFormat, $dateAndTime . $microseconds . $timeZone, new \DateTimeZone('UTC'));
  54937. return $dateTime ?: null;
  54938. }
  54939. }
  54940. <?php
  54941. namespace JsonSchema;
  54942. use JsonSchema\Constraints\BaseConstraint;
  54943. use JsonSchema\Entity\JsonPointer;
  54944. use JsonSchema\Exception\UnresolvableJsonPointerException;
  54945. use JsonSchema\Uri\UriResolver;
  54946. use JsonSchema\Uri\UriRetriever;
  54947. class SchemaStorage implements SchemaStorageInterface
  54948. {
  54949. const INTERNAL_PROVIDED_SCHEMA_URI = 'internal://provided-schema/';
  54950. protected $uriRetriever;
  54951. protected $uriResolver;
  54952. protected $schemas = array();
  54953. public function __construct(
  54954. UriRetrieverInterface $uriRetriever = null,
  54955. UriResolverInterface $uriResolver = null
  54956. ) {
  54957. $this->uriRetriever = $uriRetriever ?: new UriRetriever();
  54958. $this->uriResolver = $uriResolver ?: new UriResolver();
  54959. }
  54960. public function getUriRetriever()
  54961. {
  54962. return $this->uriRetriever;
  54963. }
  54964. public function getUriResolver()
  54965. {
  54966. return $this->uriResolver;
  54967. }
  54968. public function addSchema($id, $schema = null)
  54969. {
  54970. if (is_null($schema) && $id !== self::INTERNAL_PROVIDED_SCHEMA_URI) {
  54971. $schema = $this->uriRetriever->retrieve($id);
  54972. }
  54973. if (is_array($schema)) {
  54974. $schema = BaseConstraint::arrayToObjectRecursive($schema);
  54975. }
  54976. if (is_object($schema) && property_exists($schema, 'id')) {
  54977. if ($schema->id == 'http://json-schema.org/draft-04/schema#') {
  54978. $schema->properties->id->format = 'uri-reference';
  54979. } elseif ($schema->id == 'http://json-schema.org/draft-03/schema#') {
  54980. $schema->properties->id->format = 'uri-reference';
  54981. $schema->properties->{'$ref'}->format = 'uri-reference';
  54982. }
  54983. }
  54984. $this->expandRefs($schema, $id);
  54985. $this->schemas[$id] = $schema;
  54986. }
  54987. private function expandRefs(&$schema, $base = null)
  54988. {
  54989. if (!is_object($schema)) {
  54990. if (is_array($schema)) {
  54991. foreach ($schema as &$member) {
  54992. $this->expandRefs($member, $base);
  54993. }
  54994. }
  54995. return;
  54996. }
  54997. if (property_exists($schema, 'id') && is_string($schema->id) && $base != $schema->id) {
  54998. $base = $this->uriResolver->resolve($schema->id, $base);
  54999. }
  55000. if (property_exists($schema, '$ref') && is_string($schema->{'$ref'})) {
  55001. $refPointer = new JsonPointer($this->uriResolver->resolve($schema->{'$ref'}, $base));
  55002. $schema->{'$ref'} = (string) $refPointer;
  55003. }
  55004. foreach ($schema as &$member) {
  55005. $this->expandRefs($member, $base);
  55006. }
  55007. }
  55008. public function getSchema($id)
  55009. {
  55010. if (!array_key_exists($id, $this->schemas)) {
  55011. $this->addSchema($id);
  55012. }
  55013. return $this->schemas[$id];
  55014. }
  55015. public function resolveRef($ref)
  55016. {
  55017. $jsonPointer = new JsonPointer($ref);
  55018. $fileName = $jsonPointer->getFilename();
  55019. if (!strlen($fileName)) {
  55020. throw new UnresolvableJsonPointerException(sprintf(
  55021. "Could not resolve fragment '%s': no file is defined",
  55022. $jsonPointer->getPropertyPathAsString()
  55023. ));
  55024. }
  55025. $refSchema = $this->getSchema($fileName);
  55026. foreach ($jsonPointer->getPropertyPaths() as $path) {
  55027. if (is_object($refSchema) && property_exists($refSchema, $path)) {
  55028. $refSchema = $this->resolveRefSchema($refSchema->{$path});
  55029. } elseif (is_array($refSchema) && array_key_exists($path, $refSchema)) {
  55030. $refSchema = $this->resolveRefSchema($refSchema[$path]);
  55031. } else {
  55032. throw new UnresolvableJsonPointerException(sprintf(
  55033. 'File: %s is found, but could not resolve fragment: %s',
  55034. $jsonPointer->getFilename(),
  55035. $jsonPointer->getPropertyPathAsString()
  55036. ));
  55037. }
  55038. }
  55039. return $refSchema;
  55040. }
  55041. public function resolveRefSchema($refSchema)
  55042. {
  55043. if (is_object($refSchema) && property_exists($refSchema, '$ref') && is_string($refSchema->{'$ref'})) {
  55044. $newSchema = $this->resolveRef($refSchema->{'$ref'});
  55045. $refSchema = (object) (get_object_vars($refSchema) + get_object_vars($newSchema));
  55046. unset($refSchema->{'$ref'});
  55047. }
  55048. return $refSchema;
  55049. }
  55050. }
  55051. <?php
  55052. namespace JsonSchema;
  55053. interface SchemaStorageInterface
  55054. {
  55055. public function addSchema($id, $schema = null);
  55056. public function getSchema($id);
  55057. public function resolveRef($ref);
  55058. public function resolveRefSchema($refSchema);
  55059. }
  55060. <?php
  55061. namespace JsonSchema\Uri\Retrievers;
  55062. abstract class AbstractRetriever implements UriRetrieverInterface
  55063. {
  55064. protected $contentType;
  55065. public function getContentType()
  55066. {
  55067. return $this->contentType;
  55068. }
  55069. }
  55070. <?php
  55071. namespace JsonSchema\Uri\Retrievers;
  55072. use JsonSchema\Exception\RuntimeException;
  55073. use JsonSchema\Validator;
  55074. class Curl extends AbstractRetriever
  55075. {
  55076. protected $messageBody;
  55077. public function __construct()
  55078. {
  55079. if (!function_exists('curl_init')) {
  55080. throw new RuntimeException('cURL not installed');
  55081. }
  55082. }
  55083. public function retrieve($uri)
  55084. {
  55085. $ch = curl_init();
  55086. curl_setopt($ch, CURLOPT_URL, $uri);
  55087. curl_setopt($ch, CURLOPT_HEADER, true);
  55088. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  55089. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: ' . Validator::SCHEMA_MEDIA_TYPE));
  55090. $response = curl_exec($ch);
  55091. if (false === $response) {
  55092. throw new \JsonSchema\Exception\ResourceNotFoundException('JSON schema not found');
  55093. }
  55094. $this->fetchMessageBody($response);
  55095. $this->fetchContentType($response);
  55096. curl_close($ch);
  55097. return $this->messageBody;
  55098. }
  55099. private function fetchMessageBody($response)
  55100. {
  55101. preg_match("/(?:\r\n){2}(.*)$/ms", $response, $match);
  55102. $this->messageBody = $match[1];
  55103. }
  55104. protected function fetchContentType($response)
  55105. {
  55106. if (0 < preg_match("/Content-Type:(\V*)/ims", $response, $match)) {
  55107. $this->contentType = trim($match[1]);
  55108. return true;
  55109. }
  55110. return false;
  55111. }
  55112. }
  55113. <?php
  55114. namespace JsonSchema\Uri\Retrievers;
  55115. use JsonSchema\Exception\ResourceNotFoundException;
  55116. class FileGetContents extends AbstractRetriever
  55117. {
  55118. protected $messageBody;
  55119. public function retrieve($uri)
  55120. {
  55121. $errorMessage = null;
  55122. set_error_handler(function ($errno, $errstr) use (&$errorMessage) {
  55123. $errorMessage = $errstr;
  55124. });
  55125. $response = file_get_contents($uri);
  55126. restore_error_handler();
  55127. if ($errorMessage) {
  55128. throw new ResourceNotFoundException($errorMessage);
  55129. }
  55130. if (false === $response) {
  55131. throw new ResourceNotFoundException('JSON schema not found at ' . $uri);
  55132. }
  55133. if ($response == ''
  55134. && substr($uri, 0, 7) == 'file://' && substr($uri, -1) == '/'
  55135. ) {
  55136. throw new ResourceNotFoundException('JSON schema not found at ' . $uri);
  55137. }
  55138. $this->messageBody = $response;
  55139. if (!empty($http_response_header)) {
  55140. $this->fetchContentType($http_response_header);
  55141. } else {
  55142. $this->contentType = null;
  55143. }
  55144. return $this->messageBody;
  55145. }
  55146. private function fetchContentType(array $headers)
  55147. {
  55148. foreach ($headers as $header) {
  55149. if ($this->contentType = self::getContentTypeMatchInHeader($header)) {
  55150. return true;
  55151. }
  55152. }
  55153. return false;
  55154. }
  55155. protected static function getContentTypeMatchInHeader($header)
  55156. {
  55157. if (0 < preg_match("/Content-Type:(\V*)/ims", $header, $match)) {
  55158. return trim($match[1]);
  55159. }
  55160. return null;
  55161. }
  55162. }
  55163. <?php
  55164. namespace JsonSchema\Uri\Retrievers;
  55165. use JsonSchema\Validator;
  55166. class PredefinedArray extends AbstractRetriever
  55167. {
  55168. private $schemas;
  55169. public function __construct(array $schemas, $contentType = Validator::SCHEMA_MEDIA_TYPE)
  55170. {
  55171. $this->schemas = $schemas;
  55172. $this->contentType = $contentType;
  55173. }
  55174. public function retrieve($uri)
  55175. {
  55176. if (!array_key_exists($uri, $this->schemas)) {
  55177. throw new \JsonSchema\Exception\ResourceNotFoundException(sprintf(
  55178. 'The JSON schema "%s" was not found.',
  55179. $uri
  55180. ));
  55181. }
  55182. return $this->schemas[$uri];
  55183. }
  55184. }
  55185. <?php
  55186. namespace JsonSchema\Uri\Retrievers;
  55187. interface UriRetrieverInterface
  55188. {
  55189. public function retrieve($uri);
  55190. public function getContentType();
  55191. }
  55192. <?php
  55193. namespace JsonSchema\Uri;
  55194. use JsonSchema\Exception\UriResolverException;
  55195. use JsonSchema\UriResolverInterface;
  55196. class UriResolver implements UriResolverInterface
  55197. {
  55198. public function parse($uri)
  55199. {
  55200. preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
  55201. $components = array();
  55202. if (5 < count($match)) {
  55203. $components = array(
  55204. 'scheme' => $match[2],
  55205. 'authority' => $match[4],
  55206. 'path' => $match[5]
  55207. );
  55208. }
  55209. if (7 < count($match)) {
  55210. $components['query'] = $match[7];
  55211. }
  55212. if (9 < count($match)) {
  55213. $components['fragment'] = $match[9];
  55214. }
  55215. return $components;
  55216. }
  55217. public function generate(array $components)
  55218. {
  55219. $uri = $components['scheme'] . '://'
  55220. . $components['authority']
  55221. . $components['path'];
  55222. if (array_key_exists('query', $components) && strlen($components['query'])) {
  55223. $uri .= '?' . $components['query'];
  55224. }
  55225. if (array_key_exists('fragment', $components)) {
  55226. $uri .= '#' . $components['fragment'];
  55227. }
  55228. return $uri;
  55229. }
  55230. public function resolve($uri, $baseUri = null)
  55231. {
  55232. if (
  55233. !is_null($baseUri) &&
  55234. !filter_var($baseUri, \FILTER_VALIDATE_URL) &&
  55235. !preg_match('|^[^/]+://|u', $baseUri)
  55236. ) {
  55237. if (is_file($baseUri)) {
  55238. $baseUri = 'file://' . realpath($baseUri);
  55239. } elseif (is_dir($baseUri)) {
  55240. $baseUri = 'file://' . realpath($baseUri) . '/';
  55241. } else {
  55242. $baseUri = 'file://' . getcwd() . '/' . $baseUri;
  55243. }
  55244. }
  55245. if ($uri == '') {
  55246. return $baseUri;
  55247. }
  55248. $components = $this->parse($uri);
  55249. $path = $components['path'];
  55250. if (!empty($components['scheme'])) {
  55251. return $uri;
  55252. }
  55253. $baseComponents = $this->parse($baseUri);
  55254. $basePath = $baseComponents['path'];
  55255. $baseComponents['path'] = self::combineRelativePathWithBasePath($path, $basePath);
  55256. if (isset($components['fragment'])) {
  55257. $baseComponents['fragment'] = $components['fragment'];
  55258. }
  55259. return $this->generate($baseComponents);
  55260. }
  55261. public static function combineRelativePathWithBasePath($relativePath, $basePath)
  55262. {
  55263. $relativePath = self::normalizePath($relativePath);
  55264. if ($relativePath == '') {
  55265. return $basePath;
  55266. }
  55267. if ($relativePath[0] == '/') {
  55268. return $relativePath;
  55269. }
  55270. $basePathSegments = explode('/', $basePath);
  55271. preg_match('|^/?(\.\./(?:\./)*)*|', $relativePath, $match);
  55272. $numLevelUp = strlen($match[0]) /3 + 1;
  55273. if ($numLevelUp >= count($basePathSegments)) {
  55274. throw new UriResolverException(sprintf("Unable to resolve URI '%s' from base '%s'", $relativePath, $basePath));
  55275. }
  55276. $basePathSegments = array_slice($basePathSegments, 0, -$numLevelUp);
  55277. $path = preg_replace('|^/?(\.\./(\./)*)*|', '', $relativePath);
  55278. return implode('/', $basePathSegments) . '/' . $path;
  55279. }
  55280. private static function normalizePath($path)
  55281. {
  55282. $path = preg_replace('|((?<!\.)\./)*|', '', $path);
  55283. $path = preg_replace('|//|', '/', $path);
  55284. return $path;
  55285. }
  55286. public function isValid($uri)
  55287. {
  55288. $components = $this->parse($uri);
  55289. return !empty($components);
  55290. }
  55291. }
  55292. <?php
  55293. namespace JsonSchema\Uri;
  55294. use JsonSchema\Exception\InvalidSchemaMediaTypeException;
  55295. use JsonSchema\Exception\JsonDecodingException;
  55296. use JsonSchema\Exception\ResourceNotFoundException;
  55297. use JsonSchema\Uri\Retrievers\FileGetContents;
  55298. use JsonSchema\Uri\Retrievers\UriRetrieverInterface;
  55299. use JsonSchema\UriRetrieverInterface as BaseUriRetrieverInterface;
  55300. use JsonSchema\Validator;
  55301. class UriRetriever implements BaseUriRetrieverInterface
  55302. {
  55303. protected $translationMap = array(
  55304. '|^https?://json-schema.org/draft-(0[34])/schema#?|' => 'package://dist/schema/json-schema-draft-$1.json'
  55305. );
  55306. protected $allowedInvalidContentTypeEndpoints = array(
  55307. 'http://json-schema.org/',
  55308. 'https://json-schema.org/'
  55309. );
  55310. protected $uriRetriever = null;
  55311. private $schemaCache = array();
  55312. public function addInvalidContentTypeEndpoint($endpoint)
  55313. {
  55314. $this->allowedInvalidContentTypeEndpoints[] = $endpoint;
  55315. }
  55316. public function confirmMediaType($uriRetriever, $uri)
  55317. {
  55318. $contentType = $uriRetriever->getContentType();
  55319. if (is_null($contentType)) {
  55320. return;
  55321. }
  55322. if (in_array($contentType, array(Validator::SCHEMA_MEDIA_TYPE, 'application/json'))) {
  55323. return;
  55324. }
  55325. foreach ($this->allowedInvalidContentTypeEndpoints as $endpoint) {
  55326. if (strpos($uri, $endpoint) === 0) {
  55327. return true;
  55328. }
  55329. }
  55330. throw new InvalidSchemaMediaTypeException(sprintf('Media type %s expected', Validator::SCHEMA_MEDIA_TYPE));
  55331. }
  55332. public function getUriRetriever()
  55333. {
  55334. if (is_null($this->uriRetriever)) {
  55335. $this->setUriRetriever(new FileGetContents());
  55336. }
  55337. return $this->uriRetriever;
  55338. }
  55339. public function resolvePointer($jsonSchema, $uri)
  55340. {
  55341. $resolver = new UriResolver();
  55342. $parsed = $resolver->parse($uri);
  55343. if (empty($parsed['fragment'])) {
  55344. return $jsonSchema;
  55345. }
  55346. $path = explode('/', $parsed['fragment']);
  55347. while ($path) {
  55348. $pathElement = array_shift($path);
  55349. if (!empty($pathElement)) {
  55350. $pathElement = str_replace('~1', '/', $pathElement);
  55351. $pathElement = str_replace('~0', '~', $pathElement);
  55352. if (!empty($jsonSchema->$pathElement)) {
  55353. $jsonSchema = $jsonSchema->$pathElement;
  55354. } else {
  55355. throw new ResourceNotFoundException(
  55356. 'Fragment "' . $parsed['fragment'] . '" not found'
  55357. . ' in ' . $uri
  55358. );
  55359. }
  55360. if (!is_object($jsonSchema)) {
  55361. throw new ResourceNotFoundException(
  55362. 'Fragment part "' . $pathElement . '" is no object '
  55363. . ' in ' . $uri
  55364. );
  55365. }
  55366. }
  55367. }
  55368. return $jsonSchema;
  55369. }
  55370. public function retrieve($uri, $baseUri = null, $translate = true)
  55371. {
  55372. $resolver = new UriResolver();
  55373. $resolvedUri = $fetchUri = $resolver->resolve($uri, $baseUri);
  55374. $arParts = $resolver->parse($resolvedUri);
  55375. if (isset($arParts['fragment'])) {
  55376. unset($arParts['fragment']);
  55377. $fetchUri = $resolver->generate($arParts);
  55378. }
  55379. if ($translate) {
  55380. $fetchUri = $this->translate($fetchUri);
  55381. }
  55382. $jsonSchema = $this->loadSchema($fetchUri);
  55383. $jsonSchema = $this->resolvePointer($jsonSchema, $resolvedUri);
  55384. if ($jsonSchema instanceof \stdClass) {
  55385. $jsonSchema->id = $resolvedUri;
  55386. }
  55387. return $jsonSchema;
  55388. }
  55389. protected function loadSchema($fetchUri)
  55390. {
  55391. if (isset($this->schemaCache[$fetchUri])) {
  55392. return $this->schemaCache[$fetchUri];
  55393. }
  55394. $uriRetriever = $this->getUriRetriever();
  55395. $contents = $this->uriRetriever->retrieve($fetchUri);
  55396. $this->confirmMediaType($uriRetriever, $fetchUri);
  55397. $jsonSchema = json_decode($contents);
  55398. if (JSON_ERROR_NONE < $error = json_last_error()) {
  55399. throw new JsonDecodingException($error);
  55400. }
  55401. $this->schemaCache[$fetchUri] = $jsonSchema;
  55402. return $jsonSchema;
  55403. }
  55404. public function setUriRetriever(UriRetrieverInterface $uriRetriever)
  55405. {
  55406. $this->uriRetriever = $uriRetriever;
  55407. return $this;
  55408. }
  55409. public function parse($uri)
  55410. {
  55411. preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
  55412. $components = array();
  55413. if (5 < count($match)) {
  55414. $components = array(
  55415. 'scheme' => $match[2],
  55416. 'authority' => $match[4],
  55417. 'path' => $match[5]
  55418. );
  55419. }
  55420. if (7 < count($match)) {
  55421. $components['query'] = $match[7];
  55422. }
  55423. if (9 < count($match)) {
  55424. $components['fragment'] = $match[9];
  55425. }
  55426. return $components;
  55427. }
  55428. public function generate(array $components)
  55429. {
  55430. $uri = $components['scheme'] . '://'
  55431. . $components['authority']
  55432. . $components['path'];
  55433. if (array_key_exists('query', $components)) {
  55434. $uri .= $components['query'];
  55435. }
  55436. if (array_key_exists('fragment', $components)) {
  55437. $uri .= $components['fragment'];
  55438. }
  55439. return $uri;
  55440. }
  55441. public function resolve($uri, $baseUri = null)
  55442. {
  55443. $components = $this->parse($uri);
  55444. $path = $components['path'];
  55445. if ((array_key_exists('scheme', $components)) && ('http' === $components['scheme'])) {
  55446. return $uri;
  55447. }
  55448. $baseComponents = $this->parse($baseUri);
  55449. $basePath = $baseComponents['path'];
  55450. $baseComponents['path'] = UriResolver::combineRelativePathWithBasePath($path, $basePath);
  55451. return $this->generate($baseComponents);
  55452. }
  55453. public function isValid($uri)
  55454. {
  55455. $components = $this->parse($uri);
  55456. return !empty($components);
  55457. }
  55458. public function setTranslation($from, $to)
  55459. {
  55460. $this->translationMap[$from] = $to;
  55461. }
  55462. public function translate($uri)
  55463. {
  55464. foreach ($this->translationMap as $from => $to) {
  55465. $uri = preg_replace($from, $to, $uri);
  55466. }
  55467. $uri = preg_replace('|^package://|', sprintf('file://%s/', realpath(__DIR__ . '/../../..')), $uri);
  55468. return $uri;
  55469. }
  55470. }
  55471. <?php
  55472. namespace JsonSchema;
  55473. interface UriResolverInterface
  55474. {
  55475. public function resolve($uri, $baseUri = null);
  55476. }
  55477. <?php
  55478. namespace JsonSchema;
  55479. interface UriRetrieverInterface
  55480. {
  55481. public function retrieve($uri, $baseUri = null);
  55482. }
  55483. <?php
  55484. namespace JsonSchema;
  55485. use JsonSchema\Constraints\BaseConstraint;
  55486. use JsonSchema\Constraints\Constraint;
  55487. class Validator extends BaseConstraint
  55488. {
  55489. const SCHEMA_MEDIA_TYPE = 'application/schema+json';
  55490. const ERROR_NONE = 0x00000000;
  55491. const ERROR_ALL = 0xFFFFFFFF;
  55492. const ERROR_DOCUMENT_VALIDATION = 0x00000001;
  55493. const ERROR_SCHEMA_VALIDATION = 0x00000002;
  55494. public function validate(&$value, $schema = null, $checkMode = null)
  55495. {
  55496. if (is_array($schema)) {
  55497. $schema = self::arrayToObjectRecursive($schema);
  55498. }
  55499. $initialCheckMode = $this->factory->getConfig();
  55500. if ($checkMode !== null) {
  55501. $this->factory->setConfig($checkMode);
  55502. }
  55503. if (is_object($schema) && property_exists($schema, 'id')) {
  55504. $schemaURI = $schema->id;
  55505. } else {
  55506. $schemaURI = SchemaStorage::INTERNAL_PROVIDED_SCHEMA_URI;
  55507. }
  55508. $this->factory->getSchemaStorage()->addSchema($schemaURI, $schema);
  55509. $validator = $this->factory->createInstanceFor('schema');
  55510. $validator->check(
  55511. $value,
  55512. $this->factory->getSchemaStorage()->getSchema($schemaURI)
  55513. );
  55514. $this->factory->setConfig($initialCheckMode);
  55515. $this->addErrors(array_unique($validator->getErrors(), SORT_REGULAR));
  55516. return $validator->getErrorMask();
  55517. }
  55518. public function check($value, $schema)
  55519. {
  55520. return $this->validate($value, $schema);
  55521. }
  55522. public function coerce(&$value, $schema)
  55523. {
  55524. return $this->validate($value, $schema, Constraint::CHECK_MODE_COERCE_TYPES);
  55525. }
  55526. }
  55527. Copyright (C) 2015 Composer
  55528. Permission is hereby granted, free of charge, to any person obtaining a copy of
  55529. this software and associated documentation files (the "Software"), to deal in
  55530. the Software without restriction, including without limitation the rights to
  55531. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  55532. of the Software, and to permit persons to whom the Software is furnished to do
  55533. so, subject to the following conditions:
  55534. The above copyright notice and this permission notice shall be included in all
  55535. copies or substantial portions of the Software.
  55536. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  55537. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  55538. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  55539. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  55540. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  55541. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  55542. SOFTWARE.
  55543. <?php
  55544. namespace Composer\Spdx;
  55545. class SpdxLicenses
  55546. {
  55547. const LICENSES_FILE = 'spdx-licenses.json';
  55548. const EXCEPTIONS_FILE = 'spdx-exceptions.json';
  55549. private $licenses;
  55550. private $licensesExpression;
  55551. private $exceptions;
  55552. private $exceptionsExpression;
  55553. public function __construct()
  55554. {
  55555. $this->loadLicenses();
  55556. $this->loadExceptions();
  55557. }
  55558. public function getLicenseByIdentifier($identifier)
  55559. {
  55560. $key = strtolower($identifier);
  55561. if (!isset($this->licenses[$key])) {
  55562. return;
  55563. }
  55564. list($identifier, $name, $isOsiApproved, $isDeprecatedLicenseId) = $this->licenses[$key];
  55565. return array(
  55566. $name,
  55567. $isOsiApproved,
  55568. 'https://spdx.org/licenses/' . $identifier . '.html#licenseText',
  55569. $isDeprecatedLicenseId,
  55570. );
  55571. }
  55572. public function getLicenses()
  55573. {
  55574. return $this->licenses;
  55575. }
  55576. public function getExceptionByIdentifier($identifier)
  55577. {
  55578. $key = strtolower($identifier);
  55579. if (!isset($this->exceptions[$key])) {
  55580. return;
  55581. }
  55582. list($identifier, $name) = $this->exceptions[$key];
  55583. return array(
  55584. $name,
  55585. 'https://spdx.org/licenses/' . $identifier . '.html#licenseExceptionText',
  55586. );
  55587. }
  55588. public function getIdentifierByName($name)
  55589. {
  55590. foreach ($this->licenses as $licenseData) {
  55591. if ($licenseData[1] === $name) {
  55592. return $licenseData[0];
  55593. }
  55594. }
  55595. foreach ($this->exceptions as $licenseData) {
  55596. if ($licenseData[1] === $name) {
  55597. return $licenseData[0];
  55598. }
  55599. }
  55600. }
  55601. public function isOsiApprovedByIdentifier($identifier)
  55602. {
  55603. return $this->licenses[strtolower($identifier)][2];
  55604. }
  55605. public function isDeprecatedByIdentifier($identifier)
  55606. {
  55607. return $this->licenses[strtolower($identifier)][3];
  55608. }
  55609. public function validate($license)
  55610. {
  55611. if (is_array($license)) {
  55612. $count = count($license);
  55613. if ($count !== count(array_filter($license, 'is_string'))) {
  55614. throw new \InvalidArgumentException('Array of strings expected.');
  55615. }
  55616. $license = $count > 1 ? '(' . implode(' OR ', $license) . ')' : (string) reset($license);
  55617. }
  55618. if (!is_string($license)) {
  55619. throw new \InvalidArgumentException(sprintf(
  55620. 'Array or String expected, %s given.',
  55621. gettype($license)
  55622. ));
  55623. }
  55624. return $this->isValidLicenseString($license);
  55625. }
  55626. public static function getResourcesDir()
  55627. {
  55628. return dirname(__DIR__) . '/res';
  55629. }
  55630. private function loadLicenses()
  55631. {
  55632. if (null !== $this->licenses) {
  55633. return;
  55634. }
  55635. $json = file_get_contents(self::getResourcesDir() . '/' . self::LICENSES_FILE);
  55636. $this->licenses = array();
  55637. foreach (json_decode($json, true) as $identifier => $license) {
  55638. $this->licenses[strtolower($identifier)] = array($identifier, $license[0], $license[1], $license[2]);
  55639. }
  55640. }
  55641. private function loadExceptions()
  55642. {
  55643. if (null !== $this->exceptions) {
  55644. return;
  55645. }
  55646. $json = file_get_contents(self::getResourcesDir() . '/' . self::EXCEPTIONS_FILE);
  55647. $this->exceptions = array();
  55648. foreach (json_decode($json, true) as $identifier => $exception) {
  55649. $this->exceptions[strtolower($identifier)] = array($identifier, $exception[0]);
  55650. }
  55651. }
  55652. private function getLicensesExpression()
  55653. {
  55654. if (null === $this->licensesExpression) {
  55655. $licenses = array_map('preg_quote', array_keys($this->licenses));
  55656. rsort($licenses);
  55657. $licenses = implode('|', $licenses);
  55658. $this->licensesExpression = $licenses;
  55659. }
  55660. return $this->licensesExpression;
  55661. }
  55662. private function getExceptionsExpression()
  55663. {
  55664. if (null === $this->exceptionsExpression) {
  55665. $exceptions = array_map('preg_quote', array_keys($this->exceptions));
  55666. rsort($exceptions);
  55667. $exceptions = implode('|', $exceptions);
  55668. $this->exceptionsExpression = $exceptions;
  55669. }
  55670. return $this->exceptionsExpression;
  55671. }
  55672. private function isValidLicenseString($license)
  55673. {
  55674. if (isset($this->licenses[strtolower($license)])) {
  55675. return true;
  55676. }
  55677. $licenses = $this->getLicensesExpression();
  55678. $exceptions = $this->getExceptionsExpression();
  55679. $regex = <<<REGEX
  55680. {
  55681. (?(DEFINE)
  55682. # idstring: 1*( ALPHA / DIGIT / - / . )
  55683. (?<idstring>[\pL\pN.-]{1,})
  55684. # license-id: taken from list
  55685. (?<licenseid>${licenses})
  55686. # license-exception-id: taken from list
  55687. (?<licenseexceptionid>${exceptions})
  55688. # license-ref: [DocumentRef-1*(idstring):]LicenseRef-1*(idstring)
  55689. (?<licenseref>(?:DocumentRef-(?&idstring):)?LicenseRef-(?&idstring))
  55690. # simple-expresssion: license-id / license-id+ / license-ref
  55691. (?<simple_expression>(?&licenseid)\+? | (?&licenseid) | (?&licenseref))
  55692. # compound-expression: 1*(
  55693. # simple-expression /
  55694. # simple-expression WITH license-exception-id /
  55695. # compound-expression AND compound-expression /
  55696. # compound-expression OR compound-expression
  55697. # ) / ( compound-expression ) )
  55698. (?<compound_head>
  55699. (?&simple_expression) ( \s+ WITH \s+ (?&licenseexceptionid))?
  55700. | \( \s* (?&compound_expression) \s* \)
  55701. )
  55702. (?<compound_expression>
  55703. (?&compound_head) (?: \s+ (?:AND|OR) \s+ (?&compound_expression))?
  55704. )
  55705. # license-expression: 1*1(simple-expression / compound-expression)
  55706. (?<license_expression>(?&compound_expression) | (?&simple_expression))
  55707. ) # end of define
  55708. ^(NONE | NOASSERTION | (?&license_expression))$
  55709. }xi
  55710. REGEX;
  55711. $match = preg_match($regex, $license);
  55712. if (0 === $match) {
  55713. return false;
  55714. }
  55715. if (false === $match) {
  55716. throw new \RuntimeException('Regex failed to compile/run.');
  55717. }
  55718. return true;
  55719. }
  55720. }
  55721. Copyright (C) 2015 Composer
  55722. Permission is hereby granted, free of charge, to any person obtaining a copy of
  55723. this software and associated documentation files (the "Software"), to deal in
  55724. the Software without restriction, including without limitation the rights to
  55725. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  55726. of the Software, and to permit persons to whom the Software is furnished to do
  55727. so, subject to the following conditions:
  55728. The above copyright notice and this permission notice shall be included in all
  55729. copies or substantial portions of the Software.
  55730. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  55731. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  55732. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  55733. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  55734. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  55735. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  55736. SOFTWARE.
  55737. <?php
  55738. namespace Composer\Semver;
  55739. use Composer\Semver\Constraint\Constraint;
  55740. class Comparator
  55741. {
  55742. public static function greaterThan($version1, $version2)
  55743. {
  55744. return self::compare($version1, '>', $version2);
  55745. }
  55746. public static function greaterThanOrEqualTo($version1, $version2)
  55747. {
  55748. return self::compare($version1, '>=', $version2);
  55749. }
  55750. public static function lessThan($version1, $version2)
  55751. {
  55752. return self::compare($version1, '<', $version2);
  55753. }
  55754. public static function lessThanOrEqualTo($version1, $version2)
  55755. {
  55756. return self::compare($version1, '<=', $version2);
  55757. }
  55758. public static function equalTo($version1, $version2)
  55759. {
  55760. return self::compare($version1, '==', $version2);
  55761. }
  55762. public static function notEqualTo($version1, $version2)
  55763. {
  55764. return self::compare($version1, '!=', $version2);
  55765. }
  55766. public static function compare($version1, $operator, $version2)
  55767. {
  55768. $constraint = new Constraint($operator, $version2);
  55769. return $constraint->matchSpecific(new Constraint('==', $version1), true);
  55770. }
  55771. }
  55772. <?php
  55773. namespace Composer\Semver;
  55774. use Composer\Semver\Constraint\Constraint;
  55775. use Composer\Semver\Constraint\ConstraintInterface;
  55776. class CompilingMatcher
  55777. {
  55778. private static $compiledCheckerCache = array();
  55779. private static $enabled;
  55780. private static $transOpInt = array(
  55781. Constraint::OP_EQ => '==',
  55782. Constraint::OP_LT => '<',
  55783. Constraint::OP_LE => '<=',
  55784. Constraint::OP_GT => '>',
  55785. Constraint::OP_GE => '>=',
  55786. Constraint::OP_NE => '!=',
  55787. );
  55788. public static function match(ConstraintInterface $constraint, $operator, $version)
  55789. {
  55790. if (self::$enabled === null) {
  55791. self::$enabled = !\in_array('eval', explode(',', ini_get('disable_functions')), true);
  55792. }
  55793. if (!self::$enabled) {
  55794. return $constraint->matches(new Constraint(self::$transOpInt[$operator], $version));
  55795. }
  55796. $cacheKey = $operator.$constraint;
  55797. if (!isset(self::$compiledCheckerCache[$cacheKey])) {
  55798. $code = $constraint->compile($operator);
  55799. self::$compiledCheckerCache[$cacheKey] = $function = eval('return function($v, $b){return '.$code.';};');
  55800. } else {
  55801. $function = self::$compiledCheckerCache[$cacheKey];
  55802. }
  55803. return $function($version, strpos($version, 'dev-') === 0);
  55804. }
  55805. }
  55806. <?php
  55807. namespace Composer\Semver\Constraint;
  55808. class Bound
  55809. {
  55810. private $version;
  55811. private $isInclusive;
  55812. public function __construct($version, $isInclusive)
  55813. {
  55814. $this->version = $version;
  55815. $this->isInclusive = $isInclusive;
  55816. }
  55817. public function getVersion()
  55818. {
  55819. return $this->version;
  55820. }
  55821. public function isInclusive()
  55822. {
  55823. return $this->isInclusive;
  55824. }
  55825. public function isZero()
  55826. {
  55827. return $this->getVersion() === '0.0.0.0-dev' && $this->isInclusive();
  55828. }
  55829. public function isPositiveInfinity()
  55830. {
  55831. return $this->getVersion() === PHP_INT_MAX.'.0.0.0' && !$this->isInclusive();
  55832. }
  55833. public function compareTo(Bound $other, $operator)
  55834. {
  55835. if (!\in_array($operator, array('<', '>'), true)) {
  55836. throw new \InvalidArgumentException('Does not support any other operator other than > or <.');
  55837. }
  55838. if ($this == $other) {
  55839. return false;
  55840. }
  55841. $compareResult = version_compare($this->getVersion(), $other->getVersion());
  55842. if (0 !== $compareResult) {
  55843. return (('>' === $operator) ? 1 : -1) === $compareResult;
  55844. }
  55845. return '>' === $operator ? $other->isInclusive() : !$other->isInclusive();
  55846. }
  55847. public function __toString()
  55848. {
  55849. return sprintf(
  55850. '%s [%s]',
  55851. $this->getVersion(),
  55852. $this->isInclusive() ? 'inclusive' : 'exclusive'
  55853. );
  55854. }
  55855. public static function zero()
  55856. {
  55857. return new Bound('0.0.0.0-dev', true);
  55858. }
  55859. public static function positiveInfinity()
  55860. {
  55861. return new Bound(PHP_INT_MAX.'.0.0.0', false);
  55862. }
  55863. }
  55864. <?php
  55865. namespace Composer\Semver\Constraint;
  55866. class Constraint implements ConstraintInterface
  55867. {
  55868. const OP_EQ = 0;
  55869. const OP_LT = 1;
  55870. const OP_LE = 2;
  55871. const OP_GT = 3;
  55872. const OP_GE = 4;
  55873. const OP_NE = 5;
  55874. private static $transOpStr = array(
  55875. '=' => self::OP_EQ,
  55876. '==' => self::OP_EQ,
  55877. '<' => self::OP_LT,
  55878. '<=' => self::OP_LE,
  55879. '>' => self::OP_GT,
  55880. '>=' => self::OP_GE,
  55881. '<>' => self::OP_NE,
  55882. '!=' => self::OP_NE,
  55883. );
  55884. private static $transOpInt = array(
  55885. self::OP_EQ => '==',
  55886. self::OP_LT => '<',
  55887. self::OP_LE => '<=',
  55888. self::OP_GT => '>',
  55889. self::OP_GE => '>=',
  55890. self::OP_NE => '!=',
  55891. );
  55892. protected $operator;
  55893. protected $version;
  55894. protected $prettyString;
  55895. protected $lowerBound;
  55896. protected $upperBound;
  55897. public function __construct($operator, $version)
  55898. {
  55899. if (!isset(self::$transOpStr[$operator])) {
  55900. throw new \InvalidArgumentException(sprintf(
  55901. 'Invalid operator "%s" given, expected one of: %s',
  55902. $operator,
  55903. implode(', ', self::getSupportedOperators())
  55904. ));
  55905. }
  55906. $this->operator = self::$transOpStr[$operator];
  55907. $this->version = $version;
  55908. }
  55909. public function getVersion()
  55910. {
  55911. return $this->version;
  55912. }
  55913. public function getOperator()
  55914. {
  55915. return self::$transOpInt[$this->operator];
  55916. }
  55917. public function matches(ConstraintInterface $provider)
  55918. {
  55919. if ($provider instanceof self) {
  55920. return $this->matchSpecific($provider);
  55921. }
  55922. return $provider->matches($this);
  55923. }
  55924. public function setPrettyString($prettyString)
  55925. {
  55926. $this->prettyString = $prettyString;
  55927. }
  55928. public function getPrettyString()
  55929. {
  55930. if ($this->prettyString) {
  55931. return $this->prettyString;
  55932. }
  55933. return $this->__toString();
  55934. }
  55935. public static function getSupportedOperators()
  55936. {
  55937. return array_keys(self::$transOpStr);
  55938. }
  55939. public static function getOperatorConstant($operator)
  55940. {
  55941. return self::$transOpStr[$operator];
  55942. }
  55943. public function versionCompare($a, $b, $operator, $compareBranches = false)
  55944. {
  55945. if (!isset(self::$transOpStr[$operator])) {
  55946. throw new \InvalidArgumentException(sprintf(
  55947. 'Invalid operator "%s" given, expected one of: %s',
  55948. $operator,
  55949. implode(', ', self::getSupportedOperators())
  55950. ));
  55951. }
  55952. $aIsBranch = strpos($a, 'dev-') === 0;
  55953. $bIsBranch = strpos($b, 'dev-') === 0;
  55954. if ($operator === '!=' && ($aIsBranch || $bIsBranch)) {
  55955. return $a !== $b;
  55956. }
  55957. if ($aIsBranch && $bIsBranch) {
  55958. return $operator === '==' && $a === $b;
  55959. }
  55960. if (!$compareBranches && ($aIsBranch || $bIsBranch)) {
  55961. return false;
  55962. }
  55963. return \version_compare($a, $b, $operator);
  55964. }
  55965. public function compile($otherOperator)
  55966. {
  55967. if (strpos($this->version, 'dev-') === 0) {
  55968. if (self::OP_EQ === $this->operator) {
  55969. if (self::OP_EQ === $otherOperator) {
  55970. return sprintf('$b && $v === %s', \var_export($this->version, true));
  55971. }
  55972. if (self::OP_NE === $otherOperator) {
  55973. return sprintf('!$b || $v !== %s', \var_export($this->version, true));
  55974. }
  55975. return 'false';
  55976. }
  55977. if (self::OP_NE === $this->operator) {
  55978. if (self::OP_EQ === $otherOperator) {
  55979. return sprintf('!$b || $v !== %s', \var_export($this->version, true));
  55980. }
  55981. if (self::OP_NE === $otherOperator) {
  55982. return 'true';
  55983. }
  55984. return '!$b';
  55985. }
  55986. return 'false';
  55987. }
  55988. if (self::OP_EQ === $this->operator) {
  55989. if (self::OP_EQ === $otherOperator) {
  55990. return sprintf('\version_compare($v, %s, \'==\')', \var_export($this->version, true));
  55991. }
  55992. if (self::OP_NE === $otherOperator) {
  55993. return sprintf('$b || \version_compare($v, %s, \'!=\')', \var_export($this->version, true));
  55994. }
  55995. return sprintf('!$b && \version_compare(%s, $v, \'%s\')', \var_export($this->version, true), self::$transOpInt[$otherOperator]);
  55996. }
  55997. if (self::OP_NE === $this->operator) {
  55998. if (self::OP_EQ === $otherOperator) {
  55999. return sprintf('$b || (!$b && \version_compare($v, %s, \'!=\'))', \var_export($this->version, true));
  56000. }
  56001. if (self::OP_NE === $otherOperator) {
  56002. return 'true';
  56003. }
  56004. return '!$b';
  56005. }
  56006. if (self::OP_LT === $this->operator || self::OP_LE === $this->operator) {
  56007. if (self::OP_LT === $otherOperator || self::OP_LE === $otherOperator) {
  56008. return '!$b';
  56009. }
  56010. } elseif (self::OP_GT === $this->operator || self::OP_GE === $this->operator) {
  56011. if (self::OP_GT === $otherOperator || self::OP_GE === $otherOperator) {
  56012. return '!$b';
  56013. }
  56014. }
  56015. if (self::OP_NE === $otherOperator) {
  56016. return 'true';
  56017. }
  56018. $codeComparison = sprintf('\version_compare($v, %s, \'%s\')', \var_export($this->version, true), self::$transOpInt[$this->operator]);
  56019. if ($this->operator === self::OP_LE) {
  56020. if ($otherOperator === self::OP_GT) {
  56021. return sprintf('!$b && \version_compare($v, %s, \'!=\') && ', \var_export($this->version, true)) . $codeComparison;
  56022. }
  56023. } elseif ($this->operator === self::OP_GE) {
  56024. if ($otherOperator === self::OP_LT) {
  56025. return sprintf('!$b && \version_compare($v, %s, \'!=\') && ', \var_export($this->version, true)) . $codeComparison;
  56026. }
  56027. }
  56028. return sprintf('!$b && %s', $codeComparison);
  56029. }
  56030. public function matchSpecific(Constraint $provider, $compareBranches = false)
  56031. {
  56032. $noEqualOp = str_replace('=', '', self::$transOpInt[$this->operator]);
  56033. $providerNoEqualOp = str_replace('=', '', self::$transOpInt[$provider->operator]);
  56034. $isEqualOp = self::OP_EQ === $this->operator;
  56035. $isNonEqualOp = self::OP_NE === $this->operator;
  56036. $isProviderEqualOp = self::OP_EQ === $provider->operator;
  56037. $isProviderNonEqualOp = self::OP_NE === $provider->operator;
  56038. if ($isNonEqualOp || $isProviderNonEqualOp) {
  56039. if ($isNonEqualOp && !$isProviderNonEqualOp && !$isProviderEqualOp && strpos($provider->version, 'dev-') === 0) {
  56040. return false;
  56041. }
  56042. if ($isProviderNonEqualOp && !$isNonEqualOp && !$isEqualOp && strpos($this->version, 'dev-') === 0) {
  56043. return false;
  56044. }
  56045. if (!$isEqualOp && !$isProviderEqualOp) {
  56046. return true;
  56047. }
  56048. return $this->versionCompare($provider->version, $this->version, '!=', $compareBranches);
  56049. }
  56050. if ($this->operator !== self::OP_EQ && $noEqualOp === $providerNoEqualOp) {
  56051. return !(strpos($this->version, 'dev-') === 0 || strpos($provider->version, 'dev-') === 0);
  56052. }
  56053. $version1 = $isEqualOp ? $this->version : $provider->version;
  56054. $version2 = $isEqualOp ? $provider->version : $this->version;
  56055. $operator = $isEqualOp ? $provider->operator : $this->operator;
  56056. if ($this->versionCompare($version1, $version2, self::$transOpInt[$operator], $compareBranches)) {
  56057. return !(self::$transOpInt[$provider->operator] === $providerNoEqualOp
  56058. && self::$transOpInt[$this->operator] !== $noEqualOp
  56059. && \version_compare($provider->version, $this->version, '=='));
  56060. }
  56061. return false;
  56062. }
  56063. public function __toString()
  56064. {
  56065. return self::$transOpInt[$this->operator] . ' ' . $this->version;
  56066. }
  56067. public function getLowerBound()
  56068. {
  56069. $this->extractBounds();
  56070. return $this->lowerBound;
  56071. }
  56072. public function getUpperBound()
  56073. {
  56074. $this->extractBounds();
  56075. return $this->upperBound;
  56076. }
  56077. private function extractBounds()
  56078. {
  56079. if (null !== $this->lowerBound) {
  56080. return;
  56081. }
  56082. if (strpos($this->version, 'dev-') === 0) {
  56083. $this->lowerBound = Bound::zero();
  56084. $this->upperBound = Bound::positiveInfinity();
  56085. return;
  56086. }
  56087. switch ($this->operator) {
  56088. case self::OP_EQ:
  56089. $this->lowerBound = new Bound($this->version, true);
  56090. $this->upperBound = new Bound($this->version, true);
  56091. break;
  56092. case self::OP_LT:
  56093. $this->lowerBound = Bound::zero();
  56094. $this->upperBound = new Bound($this->version, false);
  56095. break;
  56096. case self::OP_LE:
  56097. $this->lowerBound = Bound::zero();
  56098. $this->upperBound = new Bound($this->version, true);
  56099. break;
  56100. case self::OP_GT:
  56101. $this->lowerBound = new Bound($this->version, false);
  56102. $this->upperBound = Bound::positiveInfinity();
  56103. break;
  56104. case self::OP_GE:
  56105. $this->lowerBound = new Bound($this->version, true);
  56106. $this->upperBound = Bound::positiveInfinity();
  56107. break;
  56108. case self::OP_NE:
  56109. $this->lowerBound = Bound::zero();
  56110. $this->upperBound = Bound::positiveInfinity();
  56111. break;
  56112. }
  56113. }
  56114. }
  56115. <?php
  56116. namespace Composer\Semver\Constraint;
  56117. interface ConstraintInterface
  56118. {
  56119. public function matches(ConstraintInterface $provider);
  56120. public function compile($operator);
  56121. public function getUpperBound();
  56122. public function getLowerBound();
  56123. public function getPrettyString();
  56124. public function setPrettyString($prettyString);
  56125. public function __toString();
  56126. }
  56127. <?php
  56128. namespace Composer\Semver\Constraint;
  56129. class MatchAllConstraint implements ConstraintInterface
  56130. {
  56131. protected $prettyString;
  56132. public function matches(ConstraintInterface $provider)
  56133. {
  56134. return true;
  56135. }
  56136. public function compile($operator)
  56137. {
  56138. return 'true';
  56139. }
  56140. public function setPrettyString($prettyString)
  56141. {
  56142. $this->prettyString = $prettyString;
  56143. }
  56144. public function getPrettyString()
  56145. {
  56146. if ($this->prettyString) {
  56147. return $this->prettyString;
  56148. }
  56149. return (string) $this;
  56150. }
  56151. public function __toString()
  56152. {
  56153. return '*';
  56154. }
  56155. public function getUpperBound()
  56156. {
  56157. return Bound::positiveInfinity();
  56158. }
  56159. public function getLowerBound()
  56160. {
  56161. return Bound::zero();
  56162. }
  56163. }
  56164. <?php
  56165. namespace Composer\Semver\Constraint;
  56166. class MatchNoneConstraint implements ConstraintInterface
  56167. {
  56168. protected $prettyString;
  56169. public function matches(ConstraintInterface $provider)
  56170. {
  56171. return false;
  56172. }
  56173. public function compile($operator)
  56174. {
  56175. return 'false';
  56176. }
  56177. public function setPrettyString($prettyString)
  56178. {
  56179. $this->prettyString = $prettyString;
  56180. }
  56181. public function getPrettyString()
  56182. {
  56183. if ($this->prettyString) {
  56184. return $this->prettyString;
  56185. }
  56186. return (string) $this;
  56187. }
  56188. public function __toString()
  56189. {
  56190. return '[]';
  56191. }
  56192. public function getUpperBound()
  56193. {
  56194. return new Bound('0.0.0.0-dev', false);
  56195. }
  56196. public function getLowerBound()
  56197. {
  56198. return new Bound('0.0.0.0-dev', false);
  56199. }
  56200. }
  56201. <?php
  56202. namespace Composer\Semver\Constraint;
  56203. class MultiConstraint implements ConstraintInterface
  56204. {
  56205. protected $constraints;
  56206. protected $prettyString;
  56207. protected $string;
  56208. protected $conjunctive;
  56209. protected $lowerBound;
  56210. protected $upperBound;
  56211. public function __construct(array $constraints, $conjunctive = true)
  56212. {
  56213. if (\count($constraints) < 2) {
  56214. throw new \InvalidArgumentException(
  56215. 'Must provide at least two constraints for a MultiConstraint. Use '.
  56216. 'the regular Constraint class for one constraint only or MatchAllConstraint for none. You may use '.
  56217. 'MultiConstraint::create() which optimizes and handles those cases automatically.'
  56218. );
  56219. }
  56220. $this->constraints = $constraints;
  56221. $this->conjunctive = $conjunctive;
  56222. }
  56223. public function getConstraints()
  56224. {
  56225. return $this->constraints;
  56226. }
  56227. public function isConjunctive()
  56228. {
  56229. return $this->conjunctive;
  56230. }
  56231. public function isDisjunctive()
  56232. {
  56233. return !$this->conjunctive;
  56234. }
  56235. public function compile($otherOperator)
  56236. {
  56237. $parts = array();
  56238. foreach ($this->constraints as $constraint) {
  56239. $code = $constraint->compile($otherOperator);
  56240. if ($code === 'true') {
  56241. if (!$this->conjunctive) {
  56242. return 'true';
  56243. }
  56244. } elseif ($code === 'false') {
  56245. if ($this->conjunctive) {
  56246. return 'false';
  56247. }
  56248. } else {
  56249. $parts[] = '('.$code.')';
  56250. }
  56251. }
  56252. if (!$parts) {
  56253. return $this->conjunctive ? 'true' : 'false';
  56254. }
  56255. return $this->conjunctive ? implode('&&', $parts) : implode('||', $parts);
  56256. }
  56257. public function matches(ConstraintInterface $provider)
  56258. {
  56259. if (false === $this->conjunctive) {
  56260. foreach ($this->constraints as $constraint) {
  56261. if ($provider->matches($constraint)) {
  56262. return true;
  56263. }
  56264. }
  56265. return false;
  56266. }
  56267. foreach ($this->constraints as $constraint) {
  56268. if (!$provider->matches($constraint)) {
  56269. return false;
  56270. }
  56271. }
  56272. return true;
  56273. }
  56274. public function setPrettyString($prettyString)
  56275. {
  56276. $this->prettyString = $prettyString;
  56277. }
  56278. public function getPrettyString()
  56279. {
  56280. if ($this->prettyString) {
  56281. return $this->prettyString;
  56282. }
  56283. return (string) $this;
  56284. }
  56285. public function __toString()
  56286. {
  56287. if ($this->string !== null) {
  56288. return $this->string;
  56289. }
  56290. $constraints = array();
  56291. foreach ($this->constraints as $constraint) {
  56292. $constraints[] = (string) $constraint;
  56293. }
  56294. return $this->string = '[' . implode($this->conjunctive ? ' ' : ' || ', $constraints) . ']';
  56295. }
  56296. public function getLowerBound()
  56297. {
  56298. $this->extractBounds();
  56299. return $this->lowerBound;
  56300. }
  56301. public function getUpperBound()
  56302. {
  56303. $this->extractBounds();
  56304. return $this->upperBound;
  56305. }
  56306. public static function create(array $constraints, $conjunctive = true)
  56307. {
  56308. if (0 === \count($constraints)) {
  56309. return new MatchAllConstraint();
  56310. }
  56311. if (1 === \count($constraints)) {
  56312. return $constraints[0];
  56313. }
  56314. $optimized = self::optimizeConstraints($constraints, $conjunctive);
  56315. if ($optimized !== null) {
  56316. list($constraints, $conjunctive) = $optimized;
  56317. if (\count($constraints) === 1) {
  56318. return $constraints[0];
  56319. }
  56320. }
  56321. return new self($constraints, $conjunctive);
  56322. }
  56323. private static function optimizeConstraints(array $constraints, $conjunctive)
  56324. {
  56325. if (!$conjunctive) {
  56326. $left = $constraints[0];
  56327. $mergedConstraints = array();
  56328. $optimized = false;
  56329. for ($i = 1, $l = \count($constraints); $i < $l; $i++) {
  56330. $right = $constraints[$i];
  56331. if (
  56332. $left instanceof self
  56333. && $left->conjunctive
  56334. && $right instanceof self
  56335. && $right->conjunctive
  56336. && ($left0 = (string) $left->constraints[0])
  56337. && $left0[0] === '>' && $left0[1] === '='
  56338. && ($left1 = (string) $left->constraints[1])
  56339. && $left1[0] === '<'
  56340. && ($right0 = (string) $right->constraints[0])
  56341. && $right0[0] === '>' && $right0[1] === '='
  56342. && ($right1 = (string) $right->constraints[1])
  56343. && $right1[0] === '<'
  56344. && substr($left1, 2) === substr($right0, 3)
  56345. ) {
  56346. $optimized = true;
  56347. $left = new MultiConstraint(
  56348. array_merge(
  56349. array(
  56350. $left->constraints[0],
  56351. $right->constraints[1],
  56352. ),
  56353. \array_slice($left->constraints, 2),
  56354. \array_slice($right->constraints, 2)
  56355. ),
  56356. true);
  56357. } else {
  56358. $mergedConstraints[] = $left;
  56359. $left = $right;
  56360. }
  56361. }
  56362. if ($optimized) {
  56363. $mergedConstraints[] = $left;
  56364. return array($mergedConstraints, false);
  56365. }
  56366. }
  56367. return null;
  56368. }
  56369. private function extractBounds()
  56370. {
  56371. if (null !== $this->lowerBound) {
  56372. return;
  56373. }
  56374. foreach ($this->constraints as $constraint) {
  56375. if (null === $this->lowerBound && null === $this->upperBound) {
  56376. $this->lowerBound = $constraint->getLowerBound();
  56377. $this->upperBound = $constraint->getUpperBound();
  56378. continue;
  56379. }
  56380. if ($constraint->getLowerBound()->compareTo($this->lowerBound, $this->isConjunctive() ? '>' : '<')) {
  56381. $this->lowerBound = $constraint->getLowerBound();
  56382. }
  56383. if ($constraint->getUpperBound()->compareTo($this->upperBound, $this->isConjunctive() ? '<' : '>')) {
  56384. $this->upperBound = $constraint->getUpperBound();
  56385. }
  56386. }
  56387. }
  56388. }
  56389. <?php
  56390. namespace Composer\Semver;
  56391. use Composer\Semver\Constraint\Constraint;
  56392. class Interval
  56393. {
  56394. private $start;
  56395. private $end;
  56396. public function __construct(Constraint $start, Constraint $end)
  56397. {
  56398. $this->start = $start;
  56399. $this->end = $end;
  56400. }
  56401. public function getStart()
  56402. {
  56403. return $this->start;
  56404. }
  56405. public function getEnd()
  56406. {
  56407. return $this->end;
  56408. }
  56409. public static function fromZero()
  56410. {
  56411. static $zero;
  56412. if (null === $zero) {
  56413. $zero = new Constraint('>=', '0.0.0.0-dev');
  56414. }
  56415. return $zero;
  56416. }
  56417. public static function untilPositiveInfinity()
  56418. {
  56419. static $positiveInfinity;
  56420. if (null === $positiveInfinity) {
  56421. $positiveInfinity = new Constraint('<', PHP_INT_MAX.'.0.0.0');
  56422. }
  56423. return $positiveInfinity;
  56424. }
  56425. public static function any()
  56426. {
  56427. return new self(self::fromZero(), self::untilPositiveInfinity());
  56428. }
  56429. public static function anyDev()
  56430. {
  56431. return array('names' => array(), 'exclude' => true);
  56432. }
  56433. public static function noDev()
  56434. {
  56435. return array('names' => array(), 'exclude' => false);
  56436. }
  56437. }
  56438. <?php
  56439. namespace Composer\Semver;
  56440. use Composer\Semver\Constraint\Constraint;
  56441. use Composer\Semver\Constraint\ConstraintInterface;
  56442. use Composer\Semver\Constraint\MatchAllConstraint;
  56443. use Composer\Semver\Constraint\MatchNoneConstraint;
  56444. use Composer\Semver\Constraint\MultiConstraint;
  56445. class Intervals
  56446. {
  56447. private static $intervalsCache = array();
  56448. private static $opSortOrder = array(
  56449. '>=' => -3,
  56450. '<' => -2,
  56451. '>' => 2,
  56452. '<=' => 3,
  56453. );
  56454. public static function clear()
  56455. {
  56456. self::$intervalsCache = array();
  56457. }
  56458. public static function isSubsetOf(ConstraintInterface $candidate, ConstraintInterface $constraint)
  56459. {
  56460. if ($constraint instanceof MatchAllConstraint) {
  56461. return true;
  56462. }
  56463. if ($candidate instanceof MatchNoneConstraint || $constraint instanceof MatchNoneConstraint) {
  56464. return false;
  56465. }
  56466. $intersectionIntervals = self::get(new MultiConstraint(array($candidate, $constraint), true));
  56467. $candidateIntervals = self::get($candidate);
  56468. if (\count($intersectionIntervals['numeric']) !== \count($candidateIntervals['numeric'])) {
  56469. return false;
  56470. }
  56471. foreach ($intersectionIntervals['numeric'] as $index => $interval) {
  56472. if (!isset($candidateIntervals['numeric'][$index])) {
  56473. return false;
  56474. }
  56475. if ((string) $candidateIntervals['numeric'][$index]->getStart() !== (string) $interval->getStart()) {
  56476. return false;
  56477. }
  56478. if ((string) $candidateIntervals['numeric'][$index]->getEnd() !== (string) $interval->getEnd()) {
  56479. return false;
  56480. }
  56481. }
  56482. if ($intersectionIntervals['branches']['exclude'] !== $candidateIntervals['branches']['exclude']) {
  56483. return false;
  56484. }
  56485. if (\count($intersectionIntervals['branches']['names']) !== \count($candidateIntervals['branches']['names'])) {
  56486. return false;
  56487. }
  56488. foreach ($intersectionIntervals['branches']['names'] as $index => $name) {
  56489. if ($name !== $candidateIntervals['branches']['names'][$index]) {
  56490. return false;
  56491. }
  56492. }
  56493. return true;
  56494. }
  56495. public static function haveIntersections(ConstraintInterface $a, ConstraintInterface $b)
  56496. {
  56497. if ($a instanceof MatchAllConstraint || $b instanceof MatchAllConstraint) {
  56498. return true;
  56499. }
  56500. if ($a instanceof MatchNoneConstraint || $b instanceof MatchNoneConstraint) {
  56501. return false;
  56502. }
  56503. $intersectionIntervals = self::generateIntervals(new MultiConstraint(array($a, $b), true), true);
  56504. return \count($intersectionIntervals['numeric']) > 0 || $intersectionIntervals['branches']['exclude'] || \count($intersectionIntervals['branches']['names']) > 0;
  56505. }
  56506. public static function compactConstraint(ConstraintInterface $constraint)
  56507. {
  56508. if (!$constraint instanceof MultiConstraint) {
  56509. return $constraint;
  56510. }
  56511. $intervals = self::generateIntervals($constraint);
  56512. $constraints = array();
  56513. $hasNumericMatchAll = false;
  56514. if (\count($intervals['numeric']) === 1 && (string) $intervals['numeric'][0]->getStart() === (string) Interval::fromZero() && (string) $intervals['numeric'][0]->getEnd() === (string) Interval::untilPositiveInfinity()) {
  56515. $constraints[] = $intervals['numeric'][0]->getStart();
  56516. $hasNumericMatchAll = true;
  56517. } else {
  56518. $unEqualConstraints = array();
  56519. for ($i = 0, $count = \count($intervals['numeric']); $i < $count; $i++) {
  56520. $interval = $intervals['numeric'][$i];
  56521. if ($interval->getEnd()->getOperator() === '<' && $i+1 < $count) {
  56522. $nextInterval = $intervals['numeric'][$i+1];
  56523. if ($interval->getEnd()->getVersion() === $nextInterval->getStart()->getVersion() && $nextInterval->getStart()->getOperator() === '>') {
  56524. if (\count($unEqualConstraints) === 0 && (string) $interval->getStart() !== (string) Interval::fromZero()) {
  56525. $unEqualConstraints[] = $interval->getStart();
  56526. }
  56527. $unEqualConstraints[] = new Constraint('!=', $interval->getEnd()->getVersion());
  56528. continue;
  56529. }
  56530. }
  56531. if (\count($unEqualConstraints) > 0) {
  56532. if ((string) $interval->getEnd() !== (string) Interval::untilPositiveInfinity()) {
  56533. $unEqualConstraints[] = $interval->getEnd();
  56534. }
  56535. if (\count($unEqualConstraints) > 1) {
  56536. $constraints[] = new MultiConstraint($unEqualConstraints, true);
  56537. } else {
  56538. $constraints[] = $unEqualConstraints[0];
  56539. }
  56540. $unEqualConstraints = array();
  56541. continue;
  56542. }
  56543. if ($interval->getStart()->getVersion() === $interval->getEnd()->getVersion() && $interval->getStart()->getOperator() === '>=' && $interval->getEnd()->getOperator() === '<=') {
  56544. $constraints[] = new Constraint('==', $interval->getStart()->getVersion());
  56545. continue;
  56546. }
  56547. if ((string) $interval->getStart() === (string) Interval::fromZero()) {
  56548. $constraints[] = $interval->getEnd();
  56549. } elseif ((string) $interval->getEnd() === (string) Interval::untilPositiveInfinity()) {
  56550. $constraints[] = $interval->getStart();
  56551. } else {
  56552. $constraints[] = new MultiConstraint(array($interval->getStart(), $interval->getEnd()), true);
  56553. }
  56554. }
  56555. }
  56556. $devConstraints = array();
  56557. if (0 === \count($intervals['branches']['names'])) {
  56558. if ($intervals['branches']['exclude']) {
  56559. if ($hasNumericMatchAll) {
  56560. return new MatchAllConstraint;
  56561. }
  56562. }
  56563. } else {
  56564. foreach ($intervals['branches']['names'] as $branchName) {
  56565. if ($intervals['branches']['exclude']) {
  56566. $devConstraints[] = new Constraint('!=', $branchName);
  56567. } else {
  56568. $devConstraints[] = new Constraint('==', $branchName);
  56569. }
  56570. }
  56571. if ($intervals['branches']['exclude']) {
  56572. if (\count($constraints) > 1) {
  56573. return new MultiConstraint(array_merge(
  56574. array(new MultiConstraint($constraints, false)),
  56575. $devConstraints
  56576. ), true);
  56577. }
  56578. if (\count($constraints) === 1 && (string)$constraints[0] === (string)Interval::fromZero()) {
  56579. if (\count($devConstraints) > 1) {
  56580. return new MultiConstraint($devConstraints, true);
  56581. }
  56582. return $devConstraints[0];
  56583. }
  56584. return new MultiConstraint(array_merge($constraints, $devConstraints), true);
  56585. }
  56586. $constraints = array_merge($constraints, $devConstraints);
  56587. }
  56588. if (\count($constraints) > 1) {
  56589. return new MultiConstraint($constraints, false);
  56590. }
  56591. if (\count($constraints) === 1) {
  56592. return $constraints[0];
  56593. }
  56594. return new MatchNoneConstraint;
  56595. }
  56596. public static function get(ConstraintInterface $constraint)
  56597. {
  56598. $key = (string) $constraint;
  56599. if (!isset(self::$intervalsCache[$key])) {
  56600. self::$intervalsCache[$key] = self::generateIntervals($constraint);
  56601. }
  56602. return self::$intervalsCache[$key];
  56603. }
  56604. private static function generateIntervals(ConstraintInterface $constraint, $stopOnFirstValidInterval = false)
  56605. {
  56606. if ($constraint instanceof MatchAllConstraint) {
  56607. return array('numeric' => array(new Interval(Interval::fromZero(), Interval::untilPositiveInfinity())), 'branches' => Interval::anyDev());
  56608. }
  56609. if ($constraint instanceof MatchNoneConstraint) {
  56610. return array('numeric' => array(), 'branches' => array('names' => array(), 'exclude' => false));
  56611. }
  56612. if ($constraint instanceof Constraint) {
  56613. return self::generateSingleConstraintIntervals($constraint);
  56614. }
  56615. if (!$constraint instanceof MultiConstraint) {
  56616. throw new \UnexpectedValueException('The constraint passed in should be an MatchAllConstraint, Constraint or MultiConstraint instance, got '.\get_class($constraint).'.');
  56617. }
  56618. $constraints = $constraint->getConstraints();
  56619. $numericGroups = array();
  56620. $constraintBranches = array();
  56621. foreach ($constraints as $c) {
  56622. $res = self::get($c);
  56623. $numericGroups[] = $res['numeric'];
  56624. $constraintBranches[] = $res['branches'];
  56625. }
  56626. if ($constraint->isDisjunctive()) {
  56627. $branches = Interval::noDev();
  56628. foreach ($constraintBranches as $b) {
  56629. if ($b['exclude']) {
  56630. if ($branches['exclude']) {
  56631. $branches['names'] = array_intersect($branches['names'], $b['names']);
  56632. } else {
  56633. $branches['exclude'] = true;
  56634. $branches['names'] = array_diff($b['names'], $branches['names']);
  56635. }
  56636. } else {
  56637. if ($branches['exclude']) {
  56638. $branches['names'] = array_diff($branches['names'], $b['names']);
  56639. } else {
  56640. $branches['names'] = array_merge($branches['names'], $b['names']);
  56641. }
  56642. }
  56643. }
  56644. } else {
  56645. $branches = Interval::anyDev();
  56646. foreach ($constraintBranches as $b) {
  56647. if ($b['exclude']) {
  56648. if ($branches['exclude']) {
  56649. $branches['names'] = array_merge($branches['names'], $b['names']);
  56650. } else {
  56651. $branches['names'] = array_diff($branches['names'], $b['names']);
  56652. }
  56653. } else {
  56654. if ($branches['exclude']) {
  56655. $branches['names'] = array_diff($b['names'], $branches['names']);
  56656. $branches['exclude'] = false;
  56657. } else {
  56658. $branches['names'] = array_intersect($branches['names'], $b['names']);
  56659. }
  56660. }
  56661. }
  56662. }
  56663. $branches['names'] = array_unique($branches['names']);
  56664. if (\count($numericGroups) === 1) {
  56665. return array('numeric' => $numericGroups[0], 'branches' => $branches);
  56666. }
  56667. $borders = array();
  56668. foreach ($numericGroups as $group) {
  56669. foreach ($group as $interval) {
  56670. $borders[] = array('version' => $interval->getStart()->getVersion(), 'operator' => $interval->getStart()->getOperator(), 'side' => 'start');
  56671. $borders[] = array('version' => $interval->getEnd()->getVersion(), 'operator' => $interval->getEnd()->getOperator(), 'side' => 'end');
  56672. }
  56673. }
  56674. $opSortOrder = self::$opSortOrder;
  56675. usort($borders, function ($a, $b) use ($opSortOrder) {
  56676. $order = version_compare($a['version'], $b['version']);
  56677. if ($order === 0) {
  56678. return $opSortOrder[$a['operator']] - $opSortOrder[$b['operator']];
  56679. }
  56680. return $order;
  56681. });
  56682. $activeIntervals = 0;
  56683. $intervals = array();
  56684. $index = 0;
  56685. $activationThreshold = $constraint->isConjunctive() ? \count($numericGroups) : 1;
  56686. $active = false;
  56687. $start = null;
  56688. foreach ($borders as $border) {
  56689. if ($border['side'] === 'start') {
  56690. $activeIntervals++;
  56691. } else {
  56692. $activeIntervals--;
  56693. }
  56694. if (!$active && $activeIntervals >= $activationThreshold) {
  56695. $start = new Constraint($border['operator'], $border['version']);
  56696. $active = true;
  56697. }
  56698. if ($active && $activeIntervals < $activationThreshold) {
  56699. $active = false;
  56700. if (
  56701. version_compare($start->getVersion(), $border['version'], '=')
  56702. && (
  56703. ($start->getOperator() === '>' && $border['operator'] === '<=')
  56704. || ($start->getOperator() === '>=' && $border['operator'] === '<')
  56705. )
  56706. ) {
  56707. unset($intervals[$index]);
  56708. } else {
  56709. $intervals[$index] = new Interval($start, new Constraint($border['operator'], $border['version']));
  56710. $index++;
  56711. if ($stopOnFirstValidInterval) {
  56712. break;
  56713. }
  56714. }
  56715. $start = null;
  56716. }
  56717. }
  56718. return array('numeric' => $intervals, 'branches' => $branches);
  56719. }
  56720. private static function generateSingleConstraintIntervals(Constraint $constraint)
  56721. {
  56722. $op = $constraint->getOperator();
  56723. if (strpos($constraint->getVersion(), 'dev-') === 0) {
  56724. $intervals = array();
  56725. $branches = array('names' => array(), 'exclude' => false);
  56726. if ($op === '!=') {
  56727. $intervals[] = new Interval(Interval::fromZero(), Interval::untilPositiveInfinity());
  56728. $branches = array('names' => array($constraint->getVersion()), 'exclude' => true);
  56729. } elseif ($op === '==') {
  56730. $branches['names'][] = $constraint->getVersion();
  56731. }
  56732. return array(
  56733. 'numeric' => $intervals,
  56734. 'branches' => $branches,
  56735. );
  56736. }
  56737. if ($op[0] === '>') {
  56738. return array('numeric' => array(new Interval($constraint, Interval::untilPositiveInfinity())), 'branches' => Interval::noDev());
  56739. }
  56740. if ($op[0] === '<') {
  56741. return array('numeric' => array(new Interval(Interval::fromZero(), $constraint)), 'branches' => Interval::noDev());
  56742. }
  56743. if ($op === '!=') {
  56744. return array('numeric' => array(
  56745. new Interval(Interval::fromZero(), new Constraint('<', $constraint->getVersion())),
  56746. new Interval(new Constraint('>', $constraint->getVersion()), Interval::untilPositiveInfinity()),
  56747. ), 'branches' => Interval::anyDev());
  56748. }
  56749. return array('numeric' => array(
  56750. new Interval(new Constraint('>=', $constraint->getVersion()), new Constraint('<=', $constraint->getVersion())),
  56751. ), 'branches' => Interval::noDev());
  56752. }
  56753. }
  56754. <?php
  56755. namespace Composer\Semver;
  56756. use Composer\Semver\Constraint\Constraint;
  56757. class Semver
  56758. {
  56759. const SORT_ASC = 1;
  56760. const SORT_DESC = -1;
  56761. private static $versionParser;
  56762. public static function satisfies($version, $constraints)
  56763. {
  56764. if (null === self::$versionParser) {
  56765. self::$versionParser = new VersionParser();
  56766. }
  56767. $versionParser = self::$versionParser;
  56768. $provider = new Constraint('==', $versionParser->normalize($version));
  56769. $parsedConstraints = $versionParser->parseConstraints($constraints);
  56770. return $parsedConstraints->matches($provider);
  56771. }
  56772. public static function satisfiedBy(array $versions, $constraints)
  56773. {
  56774. $versions = array_filter($versions, function ($version) use ($constraints) {
  56775. return Semver::satisfies($version, $constraints);
  56776. });
  56777. return array_values($versions);
  56778. }
  56779. public static function sort(array $versions)
  56780. {
  56781. return self::usort($versions, self::SORT_ASC);
  56782. }
  56783. public static function rsort(array $versions)
  56784. {
  56785. return self::usort($versions, self::SORT_DESC);
  56786. }
  56787. private static function usort(array $versions, $direction)
  56788. {
  56789. if (null === self::$versionParser) {
  56790. self::$versionParser = new VersionParser();
  56791. }
  56792. $versionParser = self::$versionParser;
  56793. $normalized = array();
  56794. foreach ($versions as $key => $version) {
  56795. $normalizedVersion = $versionParser->normalize($version);
  56796. $normalizedVersion = $versionParser->normalizeDefaultBranch($normalizedVersion);
  56797. $normalized[] = array($normalizedVersion, $key);
  56798. }
  56799. usort($normalized, function (array $left, array $right) use ($direction) {
  56800. if ($left[0] === $right[0]) {
  56801. return 0;
  56802. }
  56803. if (Comparator::lessThan($left[0], $right[0])) {
  56804. return -$direction;
  56805. }
  56806. return $direction;
  56807. });
  56808. $sorted = array();
  56809. foreach ($normalized as $item) {
  56810. $sorted[] = $versions[$item[1]];
  56811. }
  56812. return $sorted;
  56813. }
  56814. }
  56815. <?php
  56816. namespace Composer\Semver;
  56817. use Composer\Semver\Constraint\ConstraintInterface;
  56818. use Composer\Semver\Constraint\MatchAllConstraint;
  56819. use Composer\Semver\Constraint\MultiConstraint;
  56820. use Composer\Semver\Constraint\Constraint;
  56821. class VersionParser
  56822. {
  56823. private static $modifierRegex = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)((?:[.-]?\d+)*+)?)?([.-]?dev)?';
  56824. private static $stabilitiesRegex = 'stable|RC|beta|alpha|dev';
  56825. public static function parseStability($version)
  56826. {
  56827. $version = preg_replace('{#.+$}', '', $version);
  56828. if (strpos($version, 'dev-') === 0 || '-dev' === substr($version, -4)) {
  56829. return 'dev';
  56830. }
  56831. preg_match('{' . self::$modifierRegex . '(?:\+.*)?$}i', strtolower($version), $match);
  56832. if (!empty($match[3])) {
  56833. return 'dev';
  56834. }
  56835. if (!empty($match[1])) {
  56836. if ('beta' === $match[1] || 'b' === $match[1]) {
  56837. return 'beta';
  56838. }
  56839. if ('alpha' === $match[1] || 'a' === $match[1]) {
  56840. return 'alpha';
  56841. }
  56842. if ('rc' === $match[1]) {
  56843. return 'RC';
  56844. }
  56845. }
  56846. return 'stable';
  56847. }
  56848. public static function normalizeStability($stability)
  56849. {
  56850. $stability = strtolower($stability);
  56851. return $stability === 'rc' ? 'RC' : $stability;
  56852. }
  56853. public function normalize($version, $fullVersion = null)
  56854. {
  56855. $version = trim($version);
  56856. $origVersion = $version;
  56857. if (null === $fullVersion) {
  56858. $fullVersion = $version;
  56859. }
  56860. if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $version, $match)) {
  56861. $version = $match[1];
  56862. }
  56863. if (preg_match('{@(?:' . self::$stabilitiesRegex . ')$}i', $version, $match)) {
  56864. $version = substr($version, 0, strlen($version) - strlen($match[0]));
  56865. }
  56866. if (\in_array($version, array('master', 'trunk', 'default'), true)) {
  56867. $version = 'dev-' . $version;
  56868. }
  56869. if (stripos($version, 'dev-') === 0) {
  56870. return 'dev-' . substr($version, 4);
  56871. }
  56872. if (preg_match('{^([^,\s+]++)\+[^\s]++$}', $version, $match)) {
  56873. $version = $match[1];
  56874. }
  56875. if (preg_match('{^v?(\d{1,5})(\.\d++)?(\.\d++)?(\.\d++)?' . self::$modifierRegex . '$}i', $version, $matches)) {
  56876. $version = $matches[1]
  56877. . (!empty($matches[2]) ? $matches[2] : '.0')
  56878. . (!empty($matches[3]) ? $matches[3] : '.0')
  56879. . (!empty($matches[4]) ? $matches[4] : '.0');
  56880. $index = 5;
  56881. } elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)' . self::$modifierRegex . '$}i', $version, $matches)) {
  56882. $version = preg_replace('{\D}', '.', $matches[1]);
  56883. $index = 2;
  56884. }
  56885. if (isset($index)) {
  56886. if (!empty($matches[$index])) {
  56887. if ('stable' === $matches[$index]) {
  56888. return $version;
  56889. }
  56890. $version .= '-' . $this->expandStability($matches[$index]) . (isset($matches[$index + 1]) && '' !== $matches[$index + 1] ? ltrim($matches[$index + 1], '.-') : '');
  56891. }
  56892. if (!empty($matches[$index + 2])) {
  56893. $version .= '-dev';
  56894. }
  56895. return $version;
  56896. }
  56897. if (preg_match('{(.*?)[.-]?dev$}i', $version, $match)) {
  56898. try {
  56899. $normalized = $this->normalizeBranch($match[1]);
  56900. if (strpos($normalized, 'dev-') === false) {
  56901. return $normalized;
  56902. }
  56903. } catch (\Exception $e) {
  56904. }
  56905. }
  56906. $extraMessage = '';
  56907. if (preg_match('{ +as +' . preg_quote($version) . '(?:@(?:'.self::$stabilitiesRegex.'))?$}', $fullVersion)) {
  56908. $extraMessage = ' in "' . $fullVersion . '", the alias must be an exact version';
  56909. } elseif (preg_match('{^' . preg_quote($version) . '(?:@(?:'.self::$stabilitiesRegex.'))? +as +}', $fullVersion)) {
  56910. $extraMessage = ' in "' . $fullVersion . '", the alias source must be an exact version, if it is a branch name you should prefix it with dev-';
  56911. }
  56912. throw new \UnexpectedValueException('Invalid version string "' . $origVersion . '"' . $extraMessage);
  56913. }
  56914. public function parseNumericAliasPrefix($branch)
  56915. {
  56916. if (preg_match('{^(?P<version>(\d++\\.)*\d++)(?:\.x)?-dev$}i', $branch, $matches)) {
  56917. return $matches['version'] . '.';
  56918. }
  56919. return false;
  56920. }
  56921. public function normalizeBranch($name)
  56922. {
  56923. $name = trim($name);
  56924. if (preg_match('{^v?(\d++)(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?$}i', $name, $matches)) {
  56925. $version = '';
  56926. for ($i = 1; $i < 5; ++$i) {
  56927. $version .= isset($matches[$i]) ? str_replace(array('*', 'X'), 'x', $matches[$i]) : '.x';
  56928. }
  56929. return str_replace('x', '9999999', $version) . '-dev';
  56930. }
  56931. return 'dev-' . $name;
  56932. }
  56933. public function normalizeDefaultBranch($name)
  56934. {
  56935. if ($name === 'dev-master' || $name === 'dev-default' || $name === 'dev-trunk') {
  56936. return '9999999-dev';
  56937. }
  56938. return $name;
  56939. }
  56940. public function parseConstraints($constraints)
  56941. {
  56942. $prettyConstraint = $constraints;
  56943. $orConstraints = preg_split('{\s*\|\|?\s*}', trim($constraints));
  56944. $orGroups = array();
  56945. foreach ($orConstraints as $constraints) {
  56946. $andConstraints = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $constraints);
  56947. if (\count($andConstraints) > 1) {
  56948. $constraintObjects = array();
  56949. foreach ($andConstraints as $constraint) {
  56950. foreach ($this->parseConstraint($constraint) as $parsedConstraint) {
  56951. $constraintObjects[] = $parsedConstraint;
  56952. }
  56953. }
  56954. } else {
  56955. $constraintObjects = $this->parseConstraint($andConstraints[0]);
  56956. }
  56957. if (1 === \count($constraintObjects)) {
  56958. $constraint = $constraintObjects[0];
  56959. } else {
  56960. $constraint = new MultiConstraint($constraintObjects);
  56961. }
  56962. $orGroups[] = $constraint;
  56963. }
  56964. $constraint = MultiConstraint::create($orGroups, false);
  56965. $constraint->setPrettyString($prettyConstraint);
  56966. return $constraint;
  56967. }
  56968. private function parseConstraint($constraint)
  56969. {
  56970. if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $constraint, $match)) {
  56971. $constraint = $match[1];
  56972. }
  56973. if (preg_match('{^([^,\s]*?)@(' . self::$stabilitiesRegex . ')$}i', $constraint, $match)) {
  56974. $constraint = '' !== $match[1] ? $match[1] : '*';
  56975. if ($match[2] !== 'stable') {
  56976. $stabilityModifier = $match[2];
  56977. }
  56978. }
  56979. if (preg_match('{^(dev-[^,\s@]+?|[^,\s@]+?\.x-dev)#.+$}i', $constraint, $match)) {
  56980. $constraint = $match[1];
  56981. }
  56982. if (preg_match('{^(v)?[xX*](\.[xX*])*$}i', $constraint, $match)) {
  56983. if (!empty($match[1]) || !empty($match[2])) {
  56984. return array(new Constraint('>=', '0.0.0.0-dev'));
  56985. }
  56986. return array(new MatchAllConstraint());
  56987. }
  56988. $versionRegex = 'v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.(\d++))?(?:' . self::$modifierRegex . '|\.([xX*][.-]?dev))(?:\+[^\s]+)?';
  56989. if (preg_match('{^~>?' . $versionRegex . '$}i', $constraint, $matches)) {
  56990. if (strpos($constraint, '~>') === 0) {
  56991. throw new \UnexpectedValueException(
  56992. 'Could not parse version constraint ' . $constraint . ': ' .
  56993. 'Invalid operator "~>", you probably meant to use the "~" operator'
  56994. );
  56995. }
  56996. if (isset($matches[4]) && '' !== $matches[4] && null !== $matches[4]) {
  56997. $position = 4;
  56998. } elseif (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
  56999. $position = 3;
  57000. } elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
  57001. $position = 2;
  57002. } else {
  57003. $position = 1;
  57004. }
  57005. if (!empty($matches[8])) {
  57006. $position++;
  57007. }
  57008. $stabilitySuffix = '';
  57009. if (empty($matches[5]) && empty($matches[7]) && empty($matches[8])) {
  57010. $stabilitySuffix .= '-dev';
  57011. }
  57012. $lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
  57013. $lowerBound = new Constraint('>=', $lowVersion);
  57014. $highPosition = max(1, $position - 1);
  57015. $highVersion = $this->manipulateVersionString($matches, $highPosition, 1) . '-dev';
  57016. $upperBound = new Constraint('<', $highVersion);
  57017. return array(
  57018. $lowerBound,
  57019. $upperBound,
  57020. );
  57021. }
  57022. if (preg_match('{^\^' . $versionRegex . '($)}i', $constraint, $matches)) {
  57023. if ('0' !== $matches[1] || '' === $matches[2] || null === $matches[2]) {
  57024. $position = 1;
  57025. } elseif ('0' !== $matches[2] || '' === $matches[3] || null === $matches[3]) {
  57026. $position = 2;
  57027. } else {
  57028. $position = 3;
  57029. }
  57030. $stabilitySuffix = '';
  57031. if (empty($matches[5]) && empty($matches[7]) && empty($matches[8])) {
  57032. $stabilitySuffix .= '-dev';
  57033. }
  57034. $lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
  57035. $lowerBound = new Constraint('>=', $lowVersion);
  57036. $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
  57037. $upperBound = new Constraint('<', $highVersion);
  57038. return array(
  57039. $lowerBound,
  57040. $upperBound,
  57041. );
  57042. }
  57043. if (preg_match('{^v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.[xX*])++$}', $constraint, $matches)) {
  57044. if (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
  57045. $position = 3;
  57046. } elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
  57047. $position = 2;
  57048. } else {
  57049. $position = 1;
  57050. }
  57051. $lowVersion = $this->manipulateVersionString($matches, $position) . '-dev';
  57052. $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
  57053. if ($lowVersion === '0.0.0.0-dev') {
  57054. return array(new Constraint('<', $highVersion));
  57055. }
  57056. return array(
  57057. new Constraint('>=', $lowVersion),
  57058. new Constraint('<', $highVersion),
  57059. );
  57060. }
  57061. if (preg_match('{^(?P<from>' . $versionRegex . ') +- +(?P<to>' . $versionRegex . ')($)}i', $constraint, $matches)) {
  57062. $lowStabilitySuffix = '';
  57063. if (empty($matches[6]) && empty($matches[8]) && empty($matches[9])) {
  57064. $lowStabilitySuffix = '-dev';
  57065. }
  57066. $lowVersion = $this->normalize($matches['from']);
  57067. $lowerBound = new Constraint('>=', $lowVersion . $lowStabilitySuffix);
  57068. $empty = function ($x) {
  57069. return ($x === 0 || $x === '0') ? false : empty($x);
  57070. };
  57071. if ((!$empty($matches[12]) && !$empty($matches[13])) || !empty($matches[15]) || !empty($matches[17]) || !empty($matches[18])) {
  57072. $highVersion = $this->normalize($matches['to']);
  57073. $upperBound = new Constraint('<=', $highVersion);
  57074. } else {
  57075. $highMatch = array('', $matches[11], $matches[12], $matches[13], $matches[14]);
  57076. $this->normalize($matches['to']);
  57077. $highVersion = $this->manipulateVersionString($highMatch, $empty($matches[12]) ? 1 : 2, 1) . '-dev';
  57078. $upperBound = new Constraint('<', $highVersion);
  57079. }
  57080. return array(
  57081. $lowerBound,
  57082. $upperBound,
  57083. );
  57084. }
  57085. if (preg_match('{^(<>|!=|>=?|<=?|==?)?\s*(.*)}', $constraint, $matches)) {
  57086. try {
  57087. try {
  57088. $version = $this->normalize($matches[2]);
  57089. } catch (\UnexpectedValueException $e) {
  57090. if (substr($matches[2], -4) === '-dev' && preg_match('{^[0-9a-zA-Z-./]+$}', $matches[2])) {
  57091. $version = $this->normalize('dev-'.substr($matches[2], 0, -4));
  57092. } else {
  57093. throw $e;
  57094. }
  57095. }
  57096. $op = $matches[1] ?: '=';
  57097. if ($op !== '==' && $op !== '=' && !empty($stabilityModifier) && self::parseStability($version) === 'stable') {
  57098. $version .= '-' . $stabilityModifier;
  57099. } elseif ('<' === $op || '>=' === $op) {
  57100. if (!preg_match('/-' . self::$modifierRegex . '$/', strtolower($matches[2]))) {
  57101. if (strpos($matches[2], 'dev-') !== 0) {
  57102. $version .= '-dev';
  57103. }
  57104. }
  57105. }
  57106. return array(new Constraint($matches[1] ?: '=', $version));
  57107. } catch (\Exception $e) {
  57108. }
  57109. }
  57110. $message = 'Could not parse version constraint ' . $constraint;
  57111. if (isset($e)) {
  57112. $message .= ': ' . $e->getMessage();
  57113. }
  57114. throw new \UnexpectedValueException($message);
  57115. }
  57116. private function manipulateVersionString($matches, $position, $increment = 0, $pad = '0')
  57117. {
  57118. for ($i = 4; $i > 0; --$i) {
  57119. if ($i > $position) {
  57120. $matches[$i] = $pad;
  57121. } elseif ($i === $position && $increment) {
  57122. $matches[$i] += $increment;
  57123. if ($matches[$i] < 0) {
  57124. $matches[$i] = $pad;
  57125. --$position;
  57126. if ($i === 1) {
  57127. return null;
  57128. }
  57129. }
  57130. }
  57131. }
  57132. return $matches[1] . '.' . $matches[2] . '.' . $matches[3] . '.' . $matches[4];
  57133. }
  57134. private function expandStability($stability)
  57135. {
  57136. $stability = strtolower($stability);
  57137. switch ($stability) {
  57138. case 'a':
  57139. return 'alpha';
  57140. case 'b':
  57141. return 'beta';
  57142. case 'p':
  57143. case 'pl':
  57144. return 'patch';
  57145. case 'rc':
  57146. return 'RC';
  57147. default:
  57148. return $stability;
  57149. }
  57150. }
  57151. }
  57152. Copyright (C) 2016 Composer
  57153. Permission is hereby granted, free of charge, to any person obtaining a copy of
  57154. this software and associated documentation files (the "Software"), to deal in
  57155. the Software without restriction, including without limitation the rights to
  57156. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  57157. of the Software, and to permit persons to whom the Software is furnished to do
  57158. so, subject to the following conditions:
  57159. The above copyright notice and this permission notice shall be included in all
  57160. copies or substantial portions of the Software.
  57161. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  57162. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  57163. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  57164. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  57165. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  57166. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  57167. SOFTWARE.
  57168. <?php
  57169. namespace Composer\CaBundle;
  57170. use Psr\Log\LoggerInterface;
  57171. use Symfony\Component\Process\PhpProcess;
  57172. class CaBundle
  57173. {
  57174. private static $caPath;
  57175. private static $caFileValidity = array();
  57176. private static $useOpensslParse;
  57177. public static function getSystemCaRootBundlePath(LoggerInterface $logger = null)
  57178. {
  57179. if (self::$caPath !== null) {
  57180. return self::$caPath;
  57181. }
  57182. $caBundlePaths = array();
  57183. $caBundlePaths[] = self::getEnvVariable('SSL_CERT_FILE');
  57184. $caBundlePaths[] = self::getEnvVariable('SSL_CERT_DIR');
  57185. $caBundlePaths[] = ini_get('openssl.cafile');
  57186. $caBundlePaths[] = ini_get('openssl.capath');
  57187. $otherLocations = array(
  57188. '/etc/pki/tls/certs/ca-bundle.crt',
  57189. '/etc/ssl/certs/ca-certificates.crt',
  57190. '/etc/ssl/ca-bundle.pem',
  57191. '/usr/local/share/certs/ca-root-nss.crt',
  57192. '/usr/ssl/certs/ca-bundle.crt',
  57193. '/opt/local/share/curl/curl-ca-bundle.crt',
  57194. '/usr/local/share/curl/curl-ca-bundle.crt',
  57195. '/usr/share/ssl/certs/ca-bundle.crt',
  57196. '/etc/ssl/cert.pem',
  57197. '/usr/local/etc/ssl/cert.pem',
  57198. '/usr/local/etc/openssl/cert.pem',
  57199. '/usr/local/etc/openssl@1.1/cert.pem',
  57200. );
  57201. foreach($otherLocations as $location) {
  57202. $otherLocations[] = dirname($location);
  57203. }
  57204. $caBundlePaths = array_merge($caBundlePaths, $otherLocations);
  57205. foreach ($caBundlePaths as $caBundle) {
  57206. if (self::caFileUsable($caBundle, $logger)) {
  57207. return self::$caPath = $caBundle;
  57208. }
  57209. if (self::caDirUsable($caBundle)) {
  57210. return self::$caPath = $caBundle;
  57211. }
  57212. }
  57213. return self::$caPath = static::getBundledCaBundlePath();
  57214. }
  57215. public static function getBundledCaBundlePath()
  57216. {
  57217. $caBundleFile = __DIR__.'/../res/cacert.pem';
  57218. if (0 === strpos($caBundleFile, 'phar://')) {
  57219. file_put_contents(
  57220. $tempCaBundleFile = tempnam(sys_get_temp_dir(), 'openssl-ca-bundle-'),
  57221. file_get_contents($caBundleFile)
  57222. );
  57223. register_shutdown_function(function() use ($tempCaBundleFile) {
  57224. @unlink($tempCaBundleFile);
  57225. });
  57226. $caBundleFile = $tempCaBundleFile;
  57227. }
  57228. return $caBundleFile;
  57229. }
  57230. public static function validateCaFile($filename, LoggerInterface $logger = null)
  57231. {
  57232. static $warned = false;
  57233. if (isset(self::$caFileValidity[$filename])) {
  57234. return self::$caFileValidity[$filename];
  57235. }
  57236. $contents = file_get_contents($filename);
  57237. if (!static::isOpensslParseSafe()) {
  57238. if (!$warned && $logger) {
  57239. $logger->warning(sprintf(
  57240. 'Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.',
  57241. PHP_VERSION
  57242. ));
  57243. $warned = true;
  57244. }
  57245. $isValid = !empty($contents);
  57246. } else {
  57247. $contents = preg_replace("/^(\\-+(?:BEGIN|END))\\s+TRUSTED\\s+(CERTIFICATE\\-+)\$/m", '$1 $2', $contents);
  57248. $isValid = (bool) openssl_x509_parse($contents);
  57249. }
  57250. if ($logger) {
  57251. $logger->debug('Checked CA file '.realpath($filename).': '.($isValid ? 'valid' : 'invalid'));
  57252. }
  57253. return self::$caFileValidity[$filename] = $isValid;
  57254. }
  57255. public static function isOpensslParseSafe()
  57256. {
  57257. if (null !== self::$useOpensslParse) {
  57258. return self::$useOpensslParse;
  57259. }
  57260. if (PHP_VERSION_ID >= 50600) {
  57261. return self::$useOpensslParse = true;
  57262. }
  57263. if (
  57264. (PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50328)
  57265. || (PHP_VERSION_ID < 50500 && PHP_VERSION_ID >= 50423)
  57266. || (PHP_VERSION_ID < 50600 && PHP_VERSION_ID >= 50507)
  57267. ) {
  57268. return self::$useOpensslParse = true;
  57269. }
  57270. if (defined('PHP_WINDOWS_VERSION_BUILD')) {
  57271. return self::$useOpensslParse = false;
  57272. }
  57273. $compareDistroVersionPrefix = function ($prefix, $fixedVersion) {
  57274. $regex = '{^'.preg_quote($prefix).'([0-9]+)$}';
  57275. if (preg_match($regex, PHP_VERSION, $m)) {
  57276. return ((int) $m[1]) >= $fixedVersion;
  57277. }
  57278. return false;
  57279. };
  57280. if (
  57281. $compareDistroVersionPrefix('5.3.3-7+squeeze', 18)
  57282. || $compareDistroVersionPrefix('5.4.4-14+deb7u', 7)
  57283. || $compareDistroVersionPrefix('5.3.10-1ubuntu3.', 9)
  57284. ) {
  57285. return self::$useOpensslParse = true;
  57286. }
  57287. if (!class_exists('Symfony\Component\Process\PhpProcess')) {
  57288. return self::$useOpensslParse = false;
  57289. }
  57290. $cert = 'LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUVwRENDQTR5Z0F3SUJBZ0lKQUp6dThyNnU2ZUJjTUEwR0NTcUdTSWIzRFFFQkJRVUFNSUhETVFzd0NRWUQKVlFRR0V3SkVSVEVjTUJvR0ExVUVDQXdUVG05eVpISm9aV2x1TFZkbGMzUm1ZV3hsYmpFUU1BNEdBMVVFQnd3SApTOE9Ed3Jac2JqRVVNQklHQTFVRUNnd0xVMlZyZEdsdmJrVnBibk14SHpBZEJnTlZCQXNNRmsxaGJHbGphVzkxCmN5QkRaWEowSUZObFkzUnBiMjR4SVRBZkJnTlZCQU1NR0cxaGJHbGphVzkxY3k1elpXdDBhVzl1WldsdWN5NWsKWlRFcU1DZ0dDU3FHU0liM0RRRUpBUlliYzNSbFptRnVMbVZ6YzJWeVFITmxhM1JwYjI1bGFXNXpMbVJsTUhVWQpaREU1TnpBd01UQXhNREF3TURBd1dnQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBCkFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUEKQUFBQUFBQVhEVEUwTVRFeU9ERXhNemt6TlZvd2djTXhDekFKQmdOVkJBWVRBa1JGTVJ3d0dnWURWUVFJREJOTwpiM0prY21obGFXNHRWMlZ6ZEdaaGJHVnVNUkF3RGdZRFZRUUhEQWRMdzRQQ3RteHVNUlF3RWdZRFZRUUtEQXRUClpXdDBhVzl1UldsdWN6RWZNQjBHQTFVRUN3d1dUV0ZzYVdOcGIzVnpJRU5sY25RZ1UyVmpkR2x2YmpFaE1COEcKQTFVRUF3d1liV0ZzYVdOcGIzVnpMbk5sYTNScGIyNWxhVzV6TG1SbE1Tb3dLQVlKS29aSWh2Y05BUWtCRmh0egpkR1ZtWVc0dVpYTnpaWEpBYzJWcmRHbHZibVZwYm5NdVpHVXdnZ0VpTUEwR0NTcUdTSWIzRFFFQkFRVUFBNElCCkR3QXdnZ0VLQW9JQkFRRERBZjNobDdKWTBYY0ZuaXlFSnBTU0RxbjBPcUJyNlFQNjV1c0pQUnQvOFBhRG9xQnUKd0VZVC9OYSs2ZnNnUGpDMHVLOURaZ1dnMnRIV1dvYW5TYmxBTW96NVBINlorUzRTSFJaN2UyZERJalBqZGhqaAowbUxnMlVNTzV5cDBWNzk3R2dzOWxOdDZKUmZIODFNTjJvYlhXczROdHp0TE11RDZlZ3FwcjhkRGJyMzRhT3M4CnBrZHVpNVVhd1Raa3N5NXBMUEhxNWNNaEZHbTA2djY1Q0xvMFYyUGQ5K0tBb2tQclBjTjVLTEtlYno3bUxwazYKU01lRVhPS1A0aWRFcXh5UTdPN2ZCdUhNZWRzUWh1K3ByWTNzaTNCVXlLZlF0UDVDWm5YMmJwMHdLSHhYMTJEWAoxbmZGSXQ5RGJHdkhUY3lPdU4rblpMUEJtM3ZXeG50eUlJdlZBZ01CQUFHalFqQkFNQWtHQTFVZEV3UUNNQUF3CkVRWUpZSVpJQVliNFFnRUJCQVFEQWdlQU1Bc0dBMVVkRHdRRUF3SUZvREFUQmdOVkhTVUVEREFLQmdnckJnRUYKQlFjREFqQU5CZ2txaGtpRzl3MEJBUVVGQUFPQ0FRRUFHMGZaWVlDVGJkajFYWWMrMVNub2FQUit2SThDOENhRAo4KzBVWWhkbnlVNGdnYTBCQWNEclk5ZTk0ZUVBdTZacXljRjZGakxxWFhkQWJvcHBXb2NyNlQ2R0QxeDMzQ2tsClZBcnpHL0t4UW9oR0QySmVxa2hJTWxEb214SE83a2EzOStPYThpMnZXTFZ5alU4QVp2V01BcnVIYTRFRU55RzcKbFcyQWFnYUZLRkNyOVRuWFRmcmR4R1ZFYnY3S1ZRNmJkaGc1cDVTanBXSDErTXEwM3VSM1pYUEJZZHlWODMxOQpvMGxWajFLRkkyRENML2xpV2lzSlJvb2YrMWNSMzVDdGQwd1lCY3BCNlRac2xNY09QbDc2ZHdLd0pnZUpvMlFnClpzZm1jMnZDMS9xT2xOdU5xLzBUenprVkd2OEVUVDNDZ2FVK1VYZTRYT1Z2a2NjZWJKbjJkZz09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K';
  57291. $script = <<<'EOT'
  57292. error_reporting(-1);
  57293. $info = openssl_x509_parse(base64_decode('%s'));
  57294. var_dump(PHP_VERSION, $info['issuer']['emailAddress'], $info['validFrom_time_t']);
  57295. EOT;
  57296. $script = '<'."?php\n".sprintf($script, $cert);
  57297. try {
  57298. $process = new PhpProcess($script);
  57299. $process->mustRun();
  57300. } catch (\Exception $e) {
  57301. return self::$useOpensslParse = false;
  57302. }
  57303. $output = preg_split('{\r?\n}', trim($process->getOutput()));
  57304. $errorOutput = trim($process->getErrorOutput());
  57305. if (
  57306. count($output) === 3
  57307. && $output[0] === sprintf('string(%d) "%s"', strlen(PHP_VERSION), PHP_VERSION)
  57308. && $output[1] === 'string(27) "stefan.esser@sektioneins.de"'
  57309. && $output[2] === 'int(-1)'
  57310. && preg_match('{openssl_x509_parse\(\): illegal (?:ASN1 data type for|length in) timestamp in - on line \d+}', $errorOutput)
  57311. ) {
  57312. return self::$useOpensslParse = true;
  57313. }
  57314. return self::$useOpensslParse = false;
  57315. }
  57316. public static function reset()
  57317. {
  57318. self::$caFileValidity = array();
  57319. self::$caPath = null;
  57320. self::$useOpensslParse = null;
  57321. }
  57322. private static function getEnvVariable($name)
  57323. {
  57324. if (isset($_SERVER[$name])) {
  57325. return (string) $_SERVER[$name];
  57326. }
  57327. if (PHP_SAPI === 'cli' && ($value = getenv($name)) !== false && $value !== null) {
  57328. return (string) $value;
  57329. }
  57330. return false;
  57331. }
  57332. private static function caFileUsable($certFile, LoggerInterface $logger = null)
  57333. {
  57334. return $certFile && @is_file($certFile) && @is_readable($certFile) && static::validateCaFile($certFile, $logger);
  57335. }
  57336. private static function caDirUsable($certDir)
  57337. {
  57338. return $certDir && @is_dir($certDir) && @is_readable($certDir) && glob($certDir . '/*');
  57339. }
  57340. }
  57341. MIT License
  57342. Copyright (c) 2017 Composer
  57343. Permission is hereby granted, free of charge, to any person obtaining a copy
  57344. of this software and associated documentation files (the "Software"), to deal
  57345. in the Software without restriction, including without limitation the rights
  57346. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  57347. copies of the Software, and to permit persons to whom the Software is
  57348. furnished to do so, subject to the following conditions:
  57349. The above copyright notice and this permission notice shall be included in all
  57350. copies or substantial portions of the Software.
  57351. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  57352. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  57353. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  57354. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  57355. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  57356. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  57357. SOFTWARE.
  57358. <?php
  57359. namespace Composer\XdebugHandler;
  57360. class PhpConfig
  57361. {
  57362. public function useOriginal()
  57363. {
  57364. $this->getDataAndReset();
  57365. return array();
  57366. }
  57367. public function useStandard()
  57368. {
  57369. if ($data = $this->getDataAndReset()) {
  57370. return array('-n', '-c', $data['tmpIni']);
  57371. }
  57372. return array();
  57373. }
  57374. public function usePersistent()
  57375. {
  57376. if ($data = $this->getDataAndReset()) {
  57377. Process::setEnv('PHPRC', $data['tmpIni']);
  57378. Process::setEnv('PHP_INI_SCAN_DIR', '');
  57379. }
  57380. return array();
  57381. }
  57382. private function getDataAndReset()
  57383. {
  57384. if ($data = XdebugHandler::getRestartSettings()) {
  57385. Process::setEnv('PHPRC', $data['phprc']);
  57386. Process::setEnv('PHP_INI_SCAN_DIR', $data['scanDir']);
  57387. }
  57388. return $data;
  57389. }
  57390. }
  57391. <?php
  57392. namespace Composer\XdebugHandler;
  57393. class Process
  57394. {
  57395. public static function addColorOption(array $args, $colorOption)
  57396. {
  57397. if (!$colorOption
  57398. || in_array($colorOption, $args)
  57399. || !preg_match('/^--([a-z]+$)|(^--[a-z]+=)/', $colorOption, $matches)) {
  57400. return $args;
  57401. }
  57402. if (isset($matches[2])) {
  57403. if (false !== ($index = array_search($matches[2].'auto', $args))) {
  57404. $args[$index] = $colorOption;
  57405. return $args;
  57406. } elseif (preg_grep('/^'.$matches[2].'/', $args)) {
  57407. return $args;
  57408. }
  57409. } elseif (in_array('--no-'.$matches[1], $args)) {
  57410. return $args;
  57411. }
  57412. if (false !== getenv('NO_COLOR')) {
  57413. return $args;
  57414. }
  57415. if (false !== ($index = array_search('--', $args))) {
  57416. array_splice($args, $index, 0, $colorOption);
  57417. } else {
  57418. $args[] = $colorOption;
  57419. }
  57420. return $args;
  57421. }
  57422. public static function escape($arg, $meta = true, $module = false)
  57423. {
  57424. if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
  57425. return "'".str_replace("'", "'\\''", $arg)."'";
  57426. }
  57427. $quote = strpbrk($arg, " \t") !== false || $arg === '';
  57428. $arg = preg_replace('/(\\\\*)"/', '$1$1\\"', $arg, -1, $dquotes);
  57429. if ($meta) {
  57430. $meta = $dquotes || preg_match('/%[^%]+%/', $arg);
  57431. if (!$meta) {
  57432. $quote = $quote || strpbrk($arg, '^&|<>()') !== false;
  57433. } elseif ($module && !$dquotes && $quote) {
  57434. $meta = false;
  57435. }
  57436. }
  57437. if ($quote) {
  57438. $arg = '"'.preg_replace('/(\\\\*)$/', '$1$1', $arg).'"';
  57439. }
  57440. if ($meta) {
  57441. $arg = preg_replace('/(["^&|<>()%])/', '^$1', $arg);
  57442. }
  57443. return $arg;
  57444. }
  57445. public static function supportsColor($output)
  57446. {
  57447. if ('Hyper' === getenv('TERM_PROGRAM')) {
  57448. return true;
  57449. }
  57450. if (defined('PHP_WINDOWS_VERSION_BUILD')) {
  57451. return (function_exists('sapi_windows_vt100_support')
  57452. && sapi_windows_vt100_support($output))
  57453. || false !== getenv('ANSICON')
  57454. || 'ON' === getenv('ConEmuANSI')
  57455. || 'xterm' === getenv('TERM');
  57456. }
  57457. if (function_exists('stream_isatty')) {
  57458. return stream_isatty($output);
  57459. }
  57460. if (function_exists('posix_isatty')) {
  57461. return posix_isatty($output);
  57462. }
  57463. $stat = fstat($output);
  57464. return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
  57465. }
  57466. public static function setEnv($name, $value = false)
  57467. {
  57468. $unset = false === $value;
  57469. if (!putenv($unset ? $name : $name.'='.$value)) {
  57470. return false;
  57471. }
  57472. if ($unset) {
  57473. unset($_SERVER[$name]);
  57474. } else {
  57475. $_SERVER[$name] = $value;
  57476. }
  57477. if (false !== stripos((string) ini_get('variables_order'), 'E')) {
  57478. if ($unset) {
  57479. unset($_ENV[$name]);
  57480. } else {
  57481. $_ENV[$name] = $value;
  57482. }
  57483. }
  57484. return true;
  57485. }
  57486. }
  57487. <?php
  57488. namespace Composer\XdebugHandler;
  57489. use Psr\Log\LoggerInterface;
  57490. use Psr\Log\LogLevel;
  57491. class Status
  57492. {
  57493. const ENV_RESTART = 'XDEBUG_HANDLER_RESTART';
  57494. const CHECK = 'Check';
  57495. const ERROR = 'Error';
  57496. const INFO = 'Info';
  57497. const NORESTART = 'NoRestart';
  57498. const RESTART = 'Restart';
  57499. const RESTARTING = 'Restarting';
  57500. const RESTARTED = 'Restarted';
  57501. private $debug;
  57502. private $envAllowXdebug;
  57503. private $loaded;
  57504. private $logger;
  57505. private $time;
  57506. public function __construct($envAllowXdebug, $debug)
  57507. {
  57508. $start = getenv(self::ENV_RESTART);
  57509. Process::setEnv(self::ENV_RESTART);
  57510. $this->time = $start ? round((microtime(true) - $start) * 1000) : 0;
  57511. $this->envAllowXdebug = $envAllowXdebug;
  57512. $this->debug = $debug && defined('STDERR');
  57513. }
  57514. public function setLogger(LoggerInterface $logger)
  57515. {
  57516. $this->logger = $logger;
  57517. }
  57518. public function report($op, $data)
  57519. {
  57520. if ($this->logger || $this->debug) {
  57521. call_user_func(array($this, 'report'.$op), $data);
  57522. }
  57523. }
  57524. private function output($text, $level = null)
  57525. {
  57526. if ($this->logger) {
  57527. $this->logger->log($level ?: LogLevel::DEBUG, $text);
  57528. }
  57529. if ($this->debug) {
  57530. fwrite(STDERR, sprintf('xdebug-handler[%d] %s', getmypid(), $text.PHP_EOL));
  57531. }
  57532. }
  57533. private function reportCheck($loaded)
  57534. {
  57535. $this->loaded = $loaded;
  57536. $this->output('Checking '.$this->envAllowXdebug);
  57537. }
  57538. private function reportError($error)
  57539. {
  57540. $this->output(sprintf('No restart (%s)', $error), LogLevel::WARNING);
  57541. }
  57542. private function reportInfo($info)
  57543. {
  57544. $this->output($info);
  57545. }
  57546. private function reportNoRestart()
  57547. {
  57548. $this->output($this->getLoadedMessage());
  57549. if ($this->loaded) {
  57550. $text = sprintf('No restart (%s)', $this->getEnvAllow());
  57551. if (!getenv($this->envAllowXdebug)) {
  57552. $text .= ' Allowed by application';
  57553. }
  57554. $this->output($text);
  57555. }
  57556. }
  57557. private function reportRestart()
  57558. {
  57559. $this->output($this->getLoadedMessage());
  57560. Process::setEnv(self::ENV_RESTART, (string) microtime(true));
  57561. }
  57562. private function reportRestarted()
  57563. {
  57564. $loaded = $this->getLoadedMessage();
  57565. $text = sprintf('Restarted (%d ms). %s', $this->time, $loaded);
  57566. $level = $this->loaded ? LogLevel::WARNING : null;
  57567. $this->output($text, $level);
  57568. }
  57569. private function reportRestarting($command)
  57570. {
  57571. $text = sprintf('Process restarting (%s)', $this->getEnvAllow());
  57572. $this->output($text);
  57573. $text = 'Running '.$command;
  57574. $this->output($text);
  57575. }
  57576. private function getEnvAllow()
  57577. {
  57578. return $this->envAllowXdebug.'='.getenv($this->envAllowXdebug);
  57579. }
  57580. private function getLoadedMessage()
  57581. {
  57582. $loaded = $this->loaded ? sprintf('loaded (%s)', $this->loaded) : 'not loaded';
  57583. return 'The Xdebug extension is '.$loaded;
  57584. }
  57585. }
  57586. <?php
  57587. namespace Composer\XdebugHandler;
  57588. use Psr\Log\LoggerInterface;
  57589. class XdebugHandler
  57590. {
  57591. const SUFFIX_ALLOW = '_ALLOW_XDEBUG';
  57592. const SUFFIX_INIS = '_ORIGINAL_INIS';
  57593. const RESTART_ID = 'internal';
  57594. const RESTART_SETTINGS = 'XDEBUG_HANDLER_SETTINGS';
  57595. const DEBUG = 'XDEBUG_HANDLER_DEBUG';
  57596. protected $tmpIni;
  57597. private static $inRestart;
  57598. private static $name;
  57599. private static $skipped;
  57600. private $cli;
  57601. private $colorOption;
  57602. private $debug;
  57603. private $envAllowXdebug;
  57604. private $envOriginalInis;
  57605. private $loaded;
  57606. private $persistent;
  57607. private $script;
  57608. private $statusWriter;
  57609. public function __construct($envPrefix, $colorOption = '')
  57610. {
  57611. if (!is_string($envPrefix) || empty($envPrefix) || !is_string($colorOption)) {
  57612. throw new \RuntimeException('Invalid constructor parameter');
  57613. }
  57614. self::$name = strtoupper($envPrefix);
  57615. $this->envAllowXdebug = self::$name.self::SUFFIX_ALLOW;
  57616. $this->envOriginalInis = self::$name.self::SUFFIX_INIS;
  57617. $this->colorOption = $colorOption;
  57618. if (extension_loaded('xdebug')) {
  57619. $ext = new \ReflectionExtension('xdebug');
  57620. $this->loaded = $ext->getVersion() ?: 'unknown';
  57621. }
  57622. if ($this->cli = PHP_SAPI === 'cli') {
  57623. $this->debug = getenv(self::DEBUG);
  57624. }
  57625. $this->statusWriter = new Status($this->envAllowXdebug, (bool) $this->debug);
  57626. }
  57627. public function setLogger(LoggerInterface $logger)
  57628. {
  57629. $this->statusWriter->setLogger($logger);
  57630. return $this;
  57631. }
  57632. public function setMainScript($script)
  57633. {
  57634. $this->script = $script;
  57635. return $this;
  57636. }
  57637. public function setPersistent()
  57638. {
  57639. $this->persistent = true;
  57640. return $this;
  57641. }
  57642. public function check()
  57643. {
  57644. $this->notify(Status::CHECK, $this->loaded);
  57645. $envArgs = explode('|', (string) getenv($this->envAllowXdebug));
  57646. if (empty($envArgs[0]) && $this->requiresRestart((bool) $this->loaded)) {
  57647. $this->notify(Status::RESTART);
  57648. if ($this->prepareRestart()) {
  57649. $command = $this->getCommand();
  57650. $this->restart($command);
  57651. }
  57652. return;
  57653. }
  57654. if (self::RESTART_ID === $envArgs[0] && count($envArgs) === 5) {
  57655. $this->notify(Status::RESTARTED);
  57656. Process::setEnv($this->envAllowXdebug);
  57657. self::$inRestart = true;
  57658. if (!$this->loaded) {
  57659. self::$skipped = $envArgs[1];
  57660. }
  57661. $this->tryEnableSignals();
  57662. $this->setEnvRestartSettings($envArgs);
  57663. return;
  57664. }
  57665. $this->notify(Status::NORESTART);
  57666. if ($settings = self::getRestartSettings()) {
  57667. $this->syncSettings($settings);
  57668. }
  57669. }
  57670. public static function getAllIniFiles()
  57671. {
  57672. if (!empty(self::$name)) {
  57673. $env = getenv(self::$name.self::SUFFIX_INIS);
  57674. if (false !== $env) {
  57675. return explode(PATH_SEPARATOR, $env);
  57676. }
  57677. }
  57678. $paths = array((string) php_ini_loaded_file());
  57679. if ($scanned = php_ini_scanned_files()) {
  57680. $paths = array_merge($paths, array_map('trim', explode(',', $scanned)));
  57681. }
  57682. return $paths;
  57683. }
  57684. public static function getRestartSettings()
  57685. {
  57686. $envArgs = explode('|', (string) getenv(self::RESTART_SETTINGS));
  57687. if (count($envArgs) !== 6
  57688. || (!self::$inRestart && php_ini_loaded_file() !== $envArgs[0])) {
  57689. return;
  57690. }
  57691. return array(
  57692. 'tmpIni' => $envArgs[0],
  57693. 'scannedInis' => (bool) $envArgs[1],
  57694. 'scanDir' => '*' === $envArgs[2] ? false : $envArgs[2],
  57695. 'phprc' => '*' === $envArgs[3] ? false : $envArgs[3],
  57696. 'inis' => explode(PATH_SEPARATOR, $envArgs[4]),
  57697. 'skipped' => $envArgs[5],
  57698. );
  57699. }
  57700. public static function getSkippedVersion()
  57701. {
  57702. return (string) self::$skipped;
  57703. }
  57704. protected function requiresRestart($isLoaded)
  57705. {
  57706. return $isLoaded;
  57707. }
  57708. protected function restart($command)
  57709. {
  57710. $this->doRestart($command);
  57711. }
  57712. private function doRestart($command)
  57713. {
  57714. $this->tryEnableSignals();
  57715. $this->notify(Status::RESTARTING, $command);
  57716. passthru($command, $exitCode);
  57717. $this->notify(Status::INFO, 'Restarted process exited '.$exitCode);
  57718. if ($this->debug === '2') {
  57719. $this->notify(Status::INFO, 'Temp ini saved: '.$this->tmpIni);
  57720. } else {
  57721. @unlink($this->tmpIni);
  57722. }
  57723. exit($exitCode);
  57724. }
  57725. private function prepareRestart()
  57726. {
  57727. $error = '';
  57728. $iniFiles = self::getAllIniFiles();
  57729. $scannedInis = count($iniFiles) > 1;
  57730. $tmpDir = sys_get_temp_dir();
  57731. if (!$this->cli) {
  57732. $error = 'Unsupported SAPI: '.PHP_SAPI;
  57733. } elseif (!defined('PHP_BINARY')) {
  57734. $error = 'PHP version is too old: '.PHP_VERSION;
  57735. } elseif (!$this->checkConfiguration($info)) {
  57736. $error = $info;
  57737. } elseif (!$this->checkScanDirConfig()) {
  57738. $error = 'PHP version does not report scanned inis: '.PHP_VERSION;
  57739. } elseif (!$this->checkMainScript()) {
  57740. $error = 'Unable to access main script: '.$this->script;
  57741. } elseif (!$this->writeTmpIni($iniFiles, $tmpDir, $error)) {
  57742. $error = $error ?: 'Unable to create temp ini file at: '.$tmpDir;
  57743. } elseif (!$this->setEnvironment($scannedInis, $iniFiles)) {
  57744. $error = 'Unable to set environment variables';
  57745. }
  57746. if ($error) {
  57747. $this->notify(Status::ERROR, $error);
  57748. }
  57749. return empty($error);
  57750. }
  57751. private function writeTmpIni(array $iniFiles, $tmpDir, &$error)
  57752. {
  57753. if (!$this->tmpIni = @tempnam($tmpDir, '')) {
  57754. return false;
  57755. }
  57756. if (empty($iniFiles[0])) {
  57757. array_shift($iniFiles);
  57758. }
  57759. $content = '';
  57760. $regex = '/^\s*(zend_extension\s*=.*xdebug.*)$/mi';
  57761. foreach ($iniFiles as $file) {
  57762. if (($data = @file_get_contents($file)) === false) {
  57763. $error = 'Unable to read ini: '.$file;
  57764. return false;
  57765. }
  57766. $content .= preg_replace($regex, ';$1', $data).PHP_EOL;
  57767. }
  57768. if ($config = parse_ini_string($content)) {
  57769. $loaded = ini_get_all(null, false);
  57770. $content .= $this->mergeLoadedConfig($loaded, $config);
  57771. }
  57772. $content .= 'opcache.enable_cli=0'.PHP_EOL;
  57773. return @file_put_contents($this->tmpIni, $content);
  57774. }
  57775. private function getCommand()
  57776. {
  57777. $php = array(PHP_BINARY);
  57778. $args = array_slice($_SERVER['argv'], 1);
  57779. if (!$this->persistent) {
  57780. array_push($php, '-n', '-c', $this->tmpIni);
  57781. }
  57782. if (defined('STDOUT') && Process::supportsColor(STDOUT)) {
  57783. $args = Process::addColorOption($args, $this->colorOption);
  57784. }
  57785. $args = array_merge($php, array($this->script), $args);
  57786. $cmd = Process::escape(array_shift($args), true, true);
  57787. foreach ($args as $arg) {
  57788. $cmd .= ' '.Process::escape($arg);
  57789. }
  57790. return $cmd;
  57791. }
  57792. private function setEnvironment($scannedInis, array $iniFiles)
  57793. {
  57794. $scanDir = getenv('PHP_INI_SCAN_DIR');
  57795. $phprc = getenv('PHPRC');
  57796. if (!putenv($this->envOriginalInis.'='.implode(PATH_SEPARATOR, $iniFiles))) {
  57797. return false;
  57798. }
  57799. if ($this->persistent) {
  57800. if (!putenv('PHP_INI_SCAN_DIR=') || !putenv('PHPRC='.$this->tmpIni)) {
  57801. return false;
  57802. }
  57803. }
  57804. $envArgs = array(
  57805. self::RESTART_ID,
  57806. $this->loaded,
  57807. (int) $scannedInis,
  57808. false === $scanDir ? '*' : $scanDir,
  57809. false === $phprc ? '*' : $phprc,
  57810. );
  57811. return putenv($this->envAllowXdebug.'='.implode('|', $envArgs));
  57812. }
  57813. private function notify($op, $data = null)
  57814. {
  57815. $this->statusWriter->report($op, $data);
  57816. }
  57817. private function mergeLoadedConfig(array $loadedConfig, array $iniConfig)
  57818. {
  57819. $content = '';
  57820. foreach ($loadedConfig as $name => $value) {
  57821. if (!is_string($value)
  57822. || strpos($name, 'xdebug') === 0
  57823. || $name === 'apc.mmap_file_mask') {
  57824. continue;
  57825. }
  57826. if (!isset($iniConfig[$name]) || $iniConfig[$name] !== $value) {
  57827. $content .= $name.'="'.addcslashes($value, '\\"').'"'.PHP_EOL;
  57828. }
  57829. }
  57830. return $content;
  57831. }
  57832. private function checkMainScript()
  57833. {
  57834. if (null !== $this->script) {
  57835. return file_exists($this->script) || '--' === $this->script;
  57836. }
  57837. if (file_exists($this->script = $_SERVER['argv'][0])) {
  57838. return true;
  57839. }
  57840. $options = PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_IGNORE_ARGS : false;
  57841. $trace = debug_backtrace($options);
  57842. if (($main = end($trace)) && isset($main['file'])) {
  57843. return file_exists($this->script = $main['file']);
  57844. }
  57845. return false;
  57846. }
  57847. private function setEnvRestartSettings($envArgs)
  57848. {
  57849. $settings = array(
  57850. php_ini_loaded_file(),
  57851. $envArgs[2],
  57852. $envArgs[3],
  57853. $envArgs[4],
  57854. getenv($this->envOriginalInis),
  57855. self::$skipped,
  57856. );
  57857. Process::setEnv(self::RESTART_SETTINGS, implode('|', $settings));
  57858. }
  57859. private function syncSettings(array $settings)
  57860. {
  57861. if (false === getenv($this->envOriginalInis)) {
  57862. Process::setEnv($this->envOriginalInis, implode(PATH_SEPARATOR, $settings['inis']));
  57863. }
  57864. self::$skipped = $settings['skipped'];
  57865. $this->notify(Status::INFO, 'Process called with existing restart settings');
  57866. }
  57867. private function checkScanDirConfig()
  57868. {
  57869. return !(getenv('PHP_INI_SCAN_DIR')
  57870. && !PHP_CONFIG_FILE_SCAN_DIR
  57871. && (PHP_VERSION_ID < 70113
  57872. || PHP_VERSION_ID === 70200));
  57873. }
  57874. private function checkConfiguration(&$info)
  57875. {
  57876. if (false !== strpos(ini_get('disable_functions'), 'passthru')) {
  57877. $info = 'passthru function is disabled';
  57878. return false;
  57879. }
  57880. if (extension_loaded('uopz') && !ini_get('uopz.disable')) {
  57881. if (function_exists('uopz_allow_exit')) {
  57882. @uopz_allow_exit(true);
  57883. } else {
  57884. $info = 'uopz extension is not compatible';
  57885. return false;
  57886. }
  57887. }
  57888. return true;
  57889. }
  57890. private function tryEnableSignals()
  57891. {
  57892. if (!function_exists('pcntl_async_signals')) {
  57893. return;
  57894. }
  57895. pcntl_async_signals(true);
  57896. $message = 'Async signals enabled';
  57897. if (!self::$inRestart) {
  57898. pcntl_signal(SIGINT, SIG_IGN);
  57899. $message .= ' (SIGINT = SIG_IGN)';
  57900. } elseif (is_int(pcntl_signal_get_handler(SIGINT))) {
  57901. pcntl_signal(SIGINT, SIG_DFL);
  57902. $message .= ' (SIGINT = SIG_DFL)';
  57903. }
  57904. $this->notify(Status::INFO, $message);
  57905. }
  57906. }
  57907. Copyright (c) 2012 PHP Framework Interoperability Group
  57908. Permission is hereby granted, free of charge, to any person obtaining a copy
  57909. of this software and associated documentation files (the "Software"), to deal
  57910. in the Software without restriction, including without limitation the rights
  57911. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  57912. copies of the Software, and to permit persons to whom the Software is
  57913. furnished to do so, subject to the following conditions:
  57914. The above copyright notice and this permission notice shall be included in
  57915. all copies or substantial portions of the Software.
  57916. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  57917. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  57918. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  57919. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  57920. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  57921. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  57922. THE SOFTWARE.
  57923. <?php
  57924. namespace Psr\Log;
  57925. abstract class AbstractLogger implements LoggerInterface
  57926. {
  57927. public function emergency($message, array $context = array())
  57928. {
  57929. $this->log(LogLevel::EMERGENCY, $message, $context);
  57930. }
  57931. public function alert($message, array $context = array())
  57932. {
  57933. $this->log(LogLevel::ALERT, $message, $context);
  57934. }
  57935. public function critical($message, array $context = array())
  57936. {
  57937. $this->log(LogLevel::CRITICAL, $message, $context);
  57938. }
  57939. public function error($message, array $context = array())
  57940. {
  57941. $this->log(LogLevel::ERROR, $message, $context);
  57942. }
  57943. public function warning($message, array $context = array())
  57944. {
  57945. $this->log(LogLevel::WARNING, $message, $context);
  57946. }
  57947. public function notice($message, array $context = array())
  57948. {
  57949. $this->log(LogLevel::NOTICE, $message, $context);
  57950. }
  57951. public function info($message, array $context = array())
  57952. {
  57953. $this->log(LogLevel::INFO, $message, $context);
  57954. }
  57955. public function debug($message, array $context = array())
  57956. {
  57957. $this->log(LogLevel::DEBUG, $message, $context);
  57958. }
  57959. }
  57960. <?php
  57961. namespace Psr\Log;
  57962. class InvalidArgumentException extends \InvalidArgumentException
  57963. {
  57964. }
  57965. <?php
  57966. namespace Psr\Log;
  57967. class LogLevel
  57968. {
  57969. const EMERGENCY = 'emergency';
  57970. const ALERT = 'alert';
  57971. const CRITICAL = 'critical';
  57972. const ERROR = 'error';
  57973. const WARNING = 'warning';
  57974. const NOTICE = 'notice';
  57975. const INFO = 'info';
  57976. const DEBUG = 'debug';
  57977. }
  57978. <?php
  57979. namespace Psr\Log;
  57980. interface LoggerAwareInterface
  57981. {
  57982. public function setLogger(LoggerInterface $logger);
  57983. }
  57984. <?php
  57985. namespace Psr\Log;
  57986. trait LoggerAwareTrait
  57987. {
  57988. protected $logger;
  57989. public function setLogger(LoggerInterface $logger)
  57990. {
  57991. $this->logger = $logger;
  57992. }
  57993. }
  57994. <?php
  57995. namespace Psr\Log;
  57996. interface LoggerInterface
  57997. {
  57998. public function emergency($message, array $context = array());
  57999. public function alert($message, array $context = array());
  58000. public function critical($message, array $context = array());
  58001. public function error($message, array $context = array());
  58002. public function warning($message, array $context = array());
  58003. public function notice($message, array $context = array());
  58004. public function info($message, array $context = array());
  58005. public function debug($message, array $context = array());
  58006. public function log($level, $message, array $context = array());
  58007. }
  58008. <?php
  58009. namespace Psr\Log;
  58010. trait LoggerTrait
  58011. {
  58012. public function emergency($message, array $context = array())
  58013. {
  58014. $this->log(LogLevel::EMERGENCY, $message, $context);
  58015. }
  58016. public function alert($message, array $context = array())
  58017. {
  58018. $this->log(LogLevel::ALERT, $message, $context);
  58019. }
  58020. public function critical($message, array $context = array())
  58021. {
  58022. $this->log(LogLevel::CRITICAL, $message, $context);
  58023. }
  58024. public function error($message, array $context = array())
  58025. {
  58026. $this->log(LogLevel::ERROR, $message, $context);
  58027. }
  58028. public function warning($message, array $context = array())
  58029. {
  58030. $this->log(LogLevel::WARNING, $message, $context);
  58031. }
  58032. public function notice($message, array $context = array())
  58033. {
  58034. $this->log(LogLevel::NOTICE, $message, $context);
  58035. }
  58036. public function info($message, array $context = array())
  58037. {
  58038. $this->log(LogLevel::INFO, $message, $context);
  58039. }
  58040. public function debug($message, array $context = array())
  58041. {
  58042. $this->log(LogLevel::DEBUG, $message, $context);
  58043. }
  58044. abstract public function log($level, $message, array $context = array());
  58045. }
  58046. <?php
  58047. namespace Psr\Log;
  58048. class NullLogger extends AbstractLogger
  58049. {
  58050. public function log($level, $message, array $context = array())
  58051. {
  58052. }
  58053. }
  58054. <?php
  58055. namespace Psr\Log\Test;
  58056. class DummyTest
  58057. {
  58058. public function __toString()
  58059. {
  58060. return 'DummyTest';
  58061. }
  58062. }
  58063. <?php
  58064. namespace Psr\Log\Test;
  58065. use Psr\Log\LoggerInterface;
  58066. use Psr\Log\LogLevel;
  58067. use PHPUnit\Framework\TestCase;
  58068. abstract class LoggerInterfaceTest extends TestCase
  58069. {
  58070. abstract public function getLogger();
  58071. abstract public function getLogs();
  58072. public function testImplements()
  58073. {
  58074. $this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger());
  58075. }
  58076. public function testLogsAtAllLevels($level, $message)
  58077. {
  58078. $logger = $this->getLogger();
  58079. $logger->{$level}($message, array('user' => 'Bob'));
  58080. $logger->log($level, $message, array('user' => 'Bob'));
  58081. $expected = array(
  58082. $level.' message of level '.$level.' with context: Bob',
  58083. $level.' message of level '.$level.' with context: Bob',
  58084. );
  58085. $this->assertEquals($expected, $this->getLogs());
  58086. }
  58087. public function provideLevelsAndMessages()
  58088. {
  58089. return array(
  58090. LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'),
  58091. LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'),
  58092. LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'),
  58093. LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'),
  58094. LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'),
  58095. LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'),
  58096. LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'),
  58097. LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'),
  58098. );
  58099. }
  58100. public function testThrowsOnInvalidLevel()
  58101. {
  58102. $logger = $this->getLogger();
  58103. $logger->log('invalid level', 'Foo');
  58104. }
  58105. public function testContextReplacement()
  58106. {
  58107. $logger = $this->getLogger();
  58108. $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar'));
  58109. $expected = array('info {Message {nothing} Bob Bar a}');
  58110. $this->assertEquals($expected, $this->getLogs());
  58111. }
  58112. public function testObjectCastToString()
  58113. {
  58114. if (method_exists($this, 'createPartialMock')) {
  58115. $dummy = $this->createPartialMock('Psr\Log\Test\DummyTest', array('__toString'));
  58116. } else {
  58117. $dummy = $this->getMock('Psr\Log\Test\DummyTest', array('__toString'));
  58118. }
  58119. $dummy->expects($this->once())
  58120. ->method('__toString')
  58121. ->will($this->returnValue('DUMMY'));
  58122. $this->getLogger()->warning($dummy);
  58123. $expected = array('warning DUMMY');
  58124. $this->assertEquals($expected, $this->getLogs());
  58125. }
  58126. public function testContextCanContainAnything()
  58127. {
  58128. $closed = fopen('php://memory', 'r');
  58129. fclose($closed);
  58130. $context = array(
  58131. 'bool' => true,
  58132. 'null' => null,
  58133. 'string' => 'Foo',
  58134. 'int' => 0,
  58135. 'float' => 0.5,
  58136. 'nested' => array('with object' => new DummyTest),
  58137. 'object' => new \DateTime,
  58138. 'resource' => fopen('php://memory', 'r'),
  58139. 'closed' => $closed,
  58140. );
  58141. $this->getLogger()->warning('Crazy context data', $context);
  58142. $expected = array('warning Crazy context data');
  58143. $this->assertEquals($expected, $this->getLogs());
  58144. }
  58145. public function testContextExceptionKeyCanBeExceptionOrOtherValues()
  58146. {
  58147. $logger = $this->getLogger();
  58148. $logger->warning('Random message', array('exception' => 'oops'));
  58149. $logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail')));
  58150. $expected = array(
  58151. 'warning Random message',
  58152. 'critical Uncaught Exception!'
  58153. );
  58154. $this->assertEquals($expected, $this->getLogs());
  58155. }
  58156. }
  58157. <?php
  58158. namespace Psr\Log\Test;
  58159. use Psr\Log\AbstractLogger;
  58160. class TestLogger extends AbstractLogger
  58161. {
  58162. public $records = [];
  58163. public $recordsByLevel = [];
  58164. public function log($level, $message, array $context = [])
  58165. {
  58166. $record = [
  58167. 'level' => $level,
  58168. 'message' => $message,
  58169. 'context' => $context,
  58170. ];
  58171. $this->recordsByLevel[$record['level']][] = $record;
  58172. $this->records[] = $record;
  58173. }
  58174. public function hasRecords($level)
  58175. {
  58176. return isset($this->recordsByLevel[$level]);
  58177. }
  58178. public function hasRecord($record, $level)
  58179. {
  58180. if (is_string($record)) {
  58181. $record = ['message' => $record];
  58182. }
  58183. return $this->hasRecordThatPasses(function ($rec) use ($record) {
  58184. if ($rec['message'] !== $record['message']) {
  58185. return false;
  58186. }
  58187. if (isset($record['context']) && $rec['context'] !== $record['context']) {
  58188. return false;
  58189. }
  58190. return true;
  58191. }, $level);
  58192. }
  58193. public function hasRecordThatContains($message, $level)
  58194. {
  58195. return $this->hasRecordThatPasses(function ($rec) use ($message) {
  58196. return strpos($rec['message'], $message) !== false;
  58197. }, $level);
  58198. }
  58199. public function hasRecordThatMatches($regex, $level)
  58200. {
  58201. return $this->hasRecordThatPasses(function ($rec) use ($regex) {
  58202. return preg_match($regex, $rec['message']) > 0;
  58203. }, $level);
  58204. }
  58205. public function hasRecordThatPasses(callable $predicate, $level)
  58206. {
  58207. if (!isset($this->recordsByLevel[$level])) {
  58208. return false;
  58209. }
  58210. foreach ($this->recordsByLevel[$level] as $i => $rec) {
  58211. if (call_user_func($predicate, $rec, $i)) {
  58212. return true;
  58213. }
  58214. }
  58215. return false;
  58216. }
  58217. public function __call($method, $args)
  58218. {
  58219. if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) {
  58220. $genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3];
  58221. $level = strtolower($matches[2]);
  58222. if (method_exists($this, $genericMethod)) {
  58223. $args[] = $level;
  58224. return call_user_func_array([$this, $genericMethod], $args);
  58225. }
  58226. }
  58227. throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()');
  58228. }
  58229. public function reset()
  58230. {
  58231. $this->records = [];
  58232. $this->recordsByLevel = [];
  58233. }
  58234. }
  58235. Copyright (c) 2012-2016 Jan Sorgalla
  58236. Permission is hereby granted, free of charge, to any person
  58237. obtaining a copy of this software and associated documentation
  58238. files (the "Software"), to deal in the Software without
  58239. restriction, including without limitation the rights to use,
  58240. copy, modify, merge, publish, distribute, sublicense, and/or sell
  58241. copies of the Software, and to permit persons to whom the
  58242. Software is furnished to do so, subject to the following
  58243. conditions:
  58244. The above copyright notice and this permission notice shall be
  58245. included in all copies or substantial portions of the Software.
  58246. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  58247. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  58248. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  58249. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  58250. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  58251. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  58252. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  58253. OTHER DEALINGS IN THE SOFTWARE.
  58254. <?php
  58255. namespace React\Promise;
  58256. interface CancellablePromiseInterface extends PromiseInterface
  58257. {
  58258. public function cancel();
  58259. }
  58260. <?php
  58261. namespace React\Promise;
  58262. class Deferred implements PromiseInterface, ResolverInterface, PromisorInterface, CancellablePromiseInterface
  58263. {
  58264. private $completed;
  58265. private $promise;
  58266. private $resolver;
  58267. private $handlers = array();
  58268. private $progressHandlers = array();
  58269. private $canceller;
  58270. private $requiredCancelRequests = 0;
  58271. private $cancelRequests = 0;
  58272. public function __construct($canceller = null)
  58273. {
  58274. if ($canceller !== null && !is_callable($canceller)) {
  58275. throw new \InvalidArgumentException(
  58276. sprintf(
  58277. 'The canceller argument must be null or of type callable, %s given.',
  58278. gettype($canceller)
  58279. )
  58280. );
  58281. }
  58282. $this->canceller = $canceller;
  58283. }
  58284. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  58285. {
  58286. if (null !== $this->completed) {
  58287. return $this->completed->then($fulfilledHandler, $errorHandler, $progressHandler);
  58288. }
  58289. $canceller = null;
  58290. if ($this->canceller !== null) {
  58291. $this->requiredCancelRequests++;
  58292. $that = $this;
  58293. $current =& $this->cancelRequests;
  58294. $required =& $this->requiredCancelRequests;
  58295. $canceller = function () use ($that, &$current, &$required) {
  58296. if (++$current < $required) {
  58297. return;
  58298. }
  58299. $that->cancel();
  58300. };
  58301. }
  58302. $deferred = new static($canceller);
  58303. if (is_callable($progressHandler)) {
  58304. $progHandler = function ($update) use ($deferred, $progressHandler) {
  58305. try {
  58306. $deferred->progress(call_user_func($progressHandler, $update));
  58307. } catch (\Exception $e) {
  58308. $deferred->progress($e);
  58309. }
  58310. };
  58311. } else {
  58312. if (null !== $progressHandler) {
  58313. trigger_error('Invalid $progressHandler argument passed to then(), must be null or callable.', E_USER_NOTICE);
  58314. }
  58315. $progHandler = array($deferred, 'progress');
  58316. }
  58317. $this->handlers[] = function ($promise) use ($fulfilledHandler, $errorHandler, $deferred, $progHandler) {
  58318. $promise
  58319. ->then($fulfilledHandler, $errorHandler)
  58320. ->then(
  58321. array($deferred, 'resolve'),
  58322. array($deferred, 'reject'),
  58323. $progHandler
  58324. );
  58325. };
  58326. $this->progressHandlers[] = $progHandler;
  58327. return $deferred->promise();
  58328. }
  58329. public function resolve($result = null)
  58330. {
  58331. if (null !== $this->completed) {
  58332. return resolve($result);
  58333. }
  58334. $this->completed = resolve($result);
  58335. $this->processQueue($this->handlers, $this->completed);
  58336. $this->progressHandlers = $this->handlers = array();
  58337. return $this->completed;
  58338. }
  58339. public function reject($reason = null)
  58340. {
  58341. return $this->resolve(reject($reason));
  58342. }
  58343. public function progress($update = null)
  58344. {
  58345. if (null !== $this->completed) {
  58346. return;
  58347. }
  58348. $this->processQueue($this->progressHandlers, $update);
  58349. }
  58350. public function promise()
  58351. {
  58352. if (null === $this->promise) {
  58353. $this->promise = new DeferredPromise($this);
  58354. }
  58355. return $this->promise;
  58356. }
  58357. public function resolver()
  58358. {
  58359. if (null === $this->resolver) {
  58360. $this->resolver = new DeferredResolver($this);
  58361. }
  58362. return $this->resolver;
  58363. }
  58364. public function cancel()
  58365. {
  58366. if (null === $this->canceller || null !== $this->completed) {
  58367. return;
  58368. }
  58369. $canceller = $this->canceller;
  58370. $this->canceller = null;
  58371. try {
  58372. $that = $this;
  58373. call_user_func(
  58374. $canceller,
  58375. function ($value = null) use ($that) {
  58376. $that->resolve($value);
  58377. },
  58378. function ($reason = null) use ($that) {
  58379. $that->reject($reason);
  58380. },
  58381. function ($update = null) use ($that) {
  58382. $that->progress($update);
  58383. }
  58384. );
  58385. } catch (\Exception $e) {
  58386. $this->reject($e);
  58387. }
  58388. }
  58389. protected function processQueue($queue, $value)
  58390. {
  58391. foreach ($queue as $handler) {
  58392. call_user_func($handler, $value);
  58393. }
  58394. }
  58395. }
  58396. <?php
  58397. namespace React\Promise;
  58398. class DeferredPromise implements PromiseInterface, CancellablePromiseInterface
  58399. {
  58400. private $deferred;
  58401. public function __construct(Deferred $deferred)
  58402. {
  58403. $this->deferred = $deferred;
  58404. }
  58405. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  58406. {
  58407. return $this->deferred->then($fulfilledHandler, $errorHandler, $progressHandler);
  58408. }
  58409. public function cancel()
  58410. {
  58411. $this->deferred->cancel();
  58412. }
  58413. }
  58414. <?php
  58415. namespace React\Promise;
  58416. class DeferredResolver implements ResolverInterface
  58417. {
  58418. private $deferred;
  58419. public function __construct(Deferred $deferred)
  58420. {
  58421. $this->deferred = $deferred;
  58422. }
  58423. public function resolve($result = null)
  58424. {
  58425. return $this->deferred->resolve($result);
  58426. }
  58427. public function reject($reason = null)
  58428. {
  58429. return $this->deferred->reject($reason);
  58430. }
  58431. public function progress($update = null)
  58432. {
  58433. return $this->deferred->progress($update);
  58434. }
  58435. }
  58436. <?php
  58437. namespace React\Promise;
  58438. class FulfilledPromise implements PromiseInterface, CancellablePromiseInterface
  58439. {
  58440. private $result;
  58441. public function __construct($result = null)
  58442. {
  58443. $this->result = $result;
  58444. }
  58445. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  58446. {
  58447. try {
  58448. $result = $this->result;
  58449. if (is_callable($fulfilledHandler)) {
  58450. $result = call_user_func($fulfilledHandler, $result);
  58451. } elseif (null !== $fulfilledHandler) {
  58452. trigger_error('Invalid $fulfilledHandler argument passed to then(), must be null or callable.', E_USER_NOTICE);
  58453. }
  58454. return resolve($result);
  58455. } catch (\Exception $exception) {
  58456. return new RejectedPromise($exception);
  58457. }
  58458. }
  58459. public function cancel()
  58460. {
  58461. }
  58462. }
  58463. <?php
  58464. namespace React\Promise;
  58465. class LazyPromise implements PromiseInterface, CancellablePromiseInterface
  58466. {
  58467. private $factory;
  58468. private $promise;
  58469. public function __construct($factory)
  58470. {
  58471. $this->factory = $factory;
  58472. }
  58473. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  58474. {
  58475. return $this->promise()->then($fulfilledHandler, $errorHandler, $progressHandler);
  58476. }
  58477. public function cancel()
  58478. {
  58479. $promise = $this->promise();
  58480. if ($promise instanceof CancellablePromiseInterface) {
  58481. $promise->cancel();
  58482. }
  58483. }
  58484. private function promise()
  58485. {
  58486. if (null === $this->promise) {
  58487. try {
  58488. $this->promise = resolve(call_user_func($this->factory));
  58489. } catch (\Exception $exception) {
  58490. $this->promise = new RejectedPromise($exception);
  58491. }
  58492. }
  58493. return $this->promise;
  58494. }
  58495. }
  58496. <?php
  58497. namespace React\Promise;
  58498. class Promise implements PromiseInterface, CancellablePromiseInterface
  58499. {
  58500. private $deferred;
  58501. public function __construct($resolver, $canceller = null)
  58502. {
  58503. if (!is_callable($resolver)) {
  58504. throw new \InvalidArgumentException(
  58505. sprintf(
  58506. 'The resolver argument must be of type callable, %s given.',
  58507. gettype($resolver)
  58508. )
  58509. );
  58510. }
  58511. $this->deferred = new Deferred($canceller);
  58512. $this->call($resolver);
  58513. }
  58514. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  58515. {
  58516. return $this->deferred->then($fulfilledHandler, $errorHandler, $progressHandler);
  58517. }
  58518. public function cancel()
  58519. {
  58520. $this->deferred->cancel();
  58521. }
  58522. private function call($callback)
  58523. {
  58524. $deferred = $this->deferred;
  58525. try {
  58526. call_user_func(
  58527. $callback,
  58528. function ($result = null) use ($deferred) {
  58529. $deferred->resolve($result);
  58530. },
  58531. function ($reason = null) use ($deferred) {
  58532. $deferred->reject($reason);
  58533. },
  58534. function ($update = null) use ($deferred) {
  58535. $deferred->progress($update);
  58536. }
  58537. );
  58538. } catch (\Exception $e) {
  58539. $this->deferred->reject($e);
  58540. }
  58541. }
  58542. }
  58543. <?php
  58544. namespace React\Promise;
  58545. interface PromiseInterface
  58546. {
  58547. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null);
  58548. }
  58549. <?php
  58550. namespace React\Promise;
  58551. interface PromisorInterface
  58552. {
  58553. public function promise();
  58554. }
  58555. <?php
  58556. namespace React\Promise;
  58557. class RejectedPromise implements PromiseInterface, CancellablePromiseInterface
  58558. {
  58559. private $reason;
  58560. public function __construct($reason = null)
  58561. {
  58562. $this->reason = $reason;
  58563. }
  58564. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  58565. {
  58566. try {
  58567. if (!is_callable($errorHandler)) {
  58568. if (null !== $errorHandler) {
  58569. trigger_error('Invalid $errorHandler argument passed to then(), must be null or callable.', E_USER_NOTICE);
  58570. }
  58571. return new RejectedPromise($this->reason);
  58572. }
  58573. return resolve(call_user_func($errorHandler, $this->reason));
  58574. } catch (\Exception $exception) {
  58575. return new RejectedPromise($exception);
  58576. }
  58577. }
  58578. public function cancel()
  58579. {
  58580. }
  58581. }
  58582. <?php
  58583. namespace React\Promise;
  58584. interface ResolverInterface
  58585. {
  58586. public function resolve($result = null);
  58587. public function reject($reason = null);
  58588. public function progress($update = null);
  58589. }
  58590. <?php
  58591. namespace React\Promise;
  58592. class Util
  58593. {
  58594. public static function promiseFor($promiseOrValue)
  58595. {
  58596. return resolve($promiseOrValue);
  58597. }
  58598. public static function rejectedPromiseFor($promiseOrValue)
  58599. {
  58600. return reject($promiseOrValue);
  58601. }
  58602. }
  58603. <?php
  58604. namespace React\Promise;
  58605. class When
  58606. {
  58607. public static function resolve($promiseOrValue = null)
  58608. {
  58609. return resolve($promiseOrValue);
  58610. }
  58611. public static function reject($promiseOrValue = null)
  58612. {
  58613. return reject($promiseOrValue);
  58614. }
  58615. public static function lazy($factory)
  58616. {
  58617. return new LazyPromise($factory);
  58618. }
  58619. public static function all($promisesOrValues, $fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  58620. {
  58621. return all($promisesOrValues)->then($fulfilledHandler, $errorHandler, $progressHandler);
  58622. }
  58623. public static function any($promisesOrValues, $fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  58624. {
  58625. return any($promisesOrValues)->then($fulfilledHandler, $errorHandler, $progressHandler);
  58626. }
  58627. public static function some($promisesOrValues, $howMany, $fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  58628. {
  58629. return some($promisesOrValues, $howMany)->then($fulfilledHandler, $errorHandler, $progressHandler);
  58630. }
  58631. public static function map($promisesOrValues, $mapFunc)
  58632. {
  58633. return map($promisesOrValues, $mapFunc);
  58634. }
  58635. public static function reduce($promisesOrValues, $reduceFunc , $initialValue = null)
  58636. {
  58637. return reduce($promisesOrValues, $reduceFunc, $initialValue);
  58638. }
  58639. }
  58640. <?php
  58641. namespace React\Promise;
  58642. function resolve($promiseOrValue = null)
  58643. {
  58644. if ($promiseOrValue instanceof PromiseInterface) {
  58645. return $promiseOrValue;
  58646. }
  58647. return new FulfilledPromise($promiseOrValue);
  58648. }
  58649. function reject($promiseOrValue = null)
  58650. {
  58651. if ($promiseOrValue instanceof PromiseInterface) {
  58652. return $promiseOrValue->then(function ($value) {
  58653. return new RejectedPromise($value);
  58654. });
  58655. }
  58656. return new RejectedPromise($promiseOrValue);
  58657. }
  58658. function all($promisesOrValues)
  58659. {
  58660. return map($promisesOrValues, function ($val) {
  58661. return $val;
  58662. });
  58663. }
  58664. function any($promisesOrValues)
  58665. {
  58666. return some($promisesOrValues, 1)->then(function($val) {
  58667. return array_shift($val);
  58668. });
  58669. }
  58670. function some($promisesOrValues, $howMany)
  58671. {
  58672. return resolve($promisesOrValues)->then(function ($array) use ($howMany) {
  58673. if (!is_array($array)) {
  58674. $array = array();
  58675. }
  58676. $len = count($array);
  58677. $toResolve = max(0, min($howMany, $len));
  58678. $values = array();
  58679. $deferred = new Deferred();
  58680. if (!$toResolve) {
  58681. $deferred->resolve($values);
  58682. } else {
  58683. $toReject = ($len - $toResolve) + 1;
  58684. $reasons = array();
  58685. $progress = array($deferred, 'progress');
  58686. $fulfillOne = function ($val, $i) use (&$values, &$toResolve, $deferred) {
  58687. $values[$i] = $val;
  58688. if (0 === --$toResolve) {
  58689. $deferred->resolve($values);
  58690. return true;
  58691. }
  58692. };
  58693. $rejectOne = function ($reason, $i) use (&$reasons, &$toReject, $deferred) {
  58694. $reasons[$i] = $reason;
  58695. if (0 === --$toReject) {
  58696. $deferred->reject($reasons);
  58697. return true;
  58698. }
  58699. };
  58700. foreach ($array as $i => $promiseOrValue) {
  58701. $fulfiller = function ($val) use ($i, &$fulfillOne, &$rejectOne) {
  58702. $reset = $fulfillOne($val, $i);
  58703. if (true === $reset) {
  58704. $fulfillOne = $rejectOne = function () {};
  58705. }
  58706. };
  58707. $rejecter = function ($val) use ($i, &$fulfillOne, &$rejectOne) {
  58708. $reset = $rejectOne($val, $i);
  58709. if (true === $reset) {
  58710. $fulfillOne = $rejectOne = function () {};
  58711. }
  58712. };
  58713. resolve($promiseOrValue)->then($fulfiller, $rejecter, $progress);
  58714. }
  58715. }
  58716. return $deferred->promise();
  58717. });
  58718. }
  58719. function map($promisesOrValues, $mapFunc)
  58720. {
  58721. return resolve($promisesOrValues)->then(function ($array) use ($mapFunc) {
  58722. if (!is_array($array)) {
  58723. $array = array();
  58724. }
  58725. $toResolve = count($array);
  58726. $results = array();
  58727. $deferred = new Deferred();
  58728. if (!$toResolve) {
  58729. $deferred->resolve($results);
  58730. } else {
  58731. $resolve = function ($item, $i) use ($mapFunc, &$results, &$toResolve, $deferred) {
  58732. resolve($item)
  58733. ->then($mapFunc)
  58734. ->then(
  58735. function ($mapped) use (&$results, $i, &$toResolve, $deferred) {
  58736. $results[$i] = $mapped;
  58737. if (0 === --$toResolve) {
  58738. $deferred->resolve($results);
  58739. }
  58740. },
  58741. array($deferred, 'reject')
  58742. );
  58743. };
  58744. foreach ($array as $i => $item) {
  58745. $resolve($item, $i);
  58746. }
  58747. }
  58748. return $deferred->promise();
  58749. });
  58750. }
  58751. function reduce($promisesOrValues, $reduceFunc , $initialValue = null)
  58752. {
  58753. return resolve($promisesOrValues)->then(function ($array) use ($reduceFunc, $initialValue) {
  58754. if (!is_array($array)) {
  58755. $array = array();
  58756. }
  58757. $total = count($array);
  58758. $i = 0;
  58759. $wrappedReduceFunc = function ($current, $val) use ($reduceFunc, $total, &$i) {
  58760. return resolve($current)->then(function ($c) use ($reduceFunc, $total, &$i, $val) {
  58761. return resolve($val)->then(function ($value) use ($reduceFunc, $total, &$i, $c) {
  58762. return call_user_func($reduceFunc, $c, $value, $i++, $total);
  58763. });
  58764. });
  58765. };
  58766. return array_reduce($array, $wrappedReduceFunc, $initialValue);
  58767. });
  58768. }
  58769. <?php
  58770. if (!function_exists('React\Promise\resolve')) {
  58771. require __DIR__.'/functions.php';
  58772. }
  58773. <?php
  58774. require_once __DIR__ . '/composer/autoload_real.php';
  58775. return ComposerAutoloaderInitComposerPhar1603208047::getLoader();
  58776. <?php
  58777. $vendorDir = dirname(dirname(__FILE__));
  58778. $baseDir = dirname($vendorDir);
  58779. return array(
  58780. 'React\\Promise' => array($vendorDir . '/react/promise/src'),
  58781. );
  58782. <?php
  58783. $vendorDir = dirname(dirname(__FILE__));
  58784. $baseDir = dirname($vendorDir);
  58785. return array(
  58786. 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
  58787. 'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
  58788. 'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'),
  58789. 'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'),
  58790. 'Symfony\\Component\\Filesystem\\' => array($vendorDir . '/symfony/filesystem'),
  58791. 'Symfony\\Component\\Debug\\' => array($vendorDir . '/symfony/debug'),
  58792. 'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'),
  58793. 'Seld\\PharUtils\\' => array($vendorDir . '/seld/phar-utils/src'),
  58794. 'Seld\\JsonLint\\' => array($vendorDir . '/seld/jsonlint/src/Seld/JsonLint'),
  58795. 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
  58796. 'JsonSchema\\' => array($vendorDir . '/justinrainbow/json-schema/src/JsonSchema'),
  58797. 'Composer\\XdebugHandler\\' => array($vendorDir . '/composer/xdebug-handler/src'),
  58798. 'Composer\\Spdx\\' => array($vendorDir . '/composer/spdx-licenses/src'),
  58799. 'Composer\\Semver\\' => array($vendorDir . '/composer/semver/src'),
  58800. 'Composer\\CaBundle\\' => array($vendorDir . '/composer/ca-bundle/src'),
  58801. 'Composer\\' => array($baseDir . '/src/Composer'),
  58802. );
  58803. <?php
  58804. $vendorDir = dirname(dirname(__FILE__));
  58805. $baseDir = dirname($vendorDir);
  58806. return array(
  58807. 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
  58808. );
  58809. <?php
  58810. $vendorDir = dirname(dirname(__FILE__));
  58811. $baseDir = dirname($vendorDir);
  58812. return array(
  58813. '320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
  58814. '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
  58815. '7844cce90d4037f1a077c08319eef109' => $vendorDir . '/react/promise/src/React/Promise/functions_include.php',
  58816. );
  58817. <?php
  58818. class ComposerAutoloaderInitComposerPhar1603208047
  58819. {
  58820. private static $loader;
  58821. public static function loadClassLoader($class)
  58822. {
  58823. if ('Composer\Autoload\ClassLoader' === $class) {
  58824. require __DIR__ . '/ClassLoader.php';
  58825. }
  58826. }
  58827. public static function getLoader()
  58828. {
  58829. if (null !== self::$loader) {
  58830. return self::$loader;
  58831. }
  58832. spl_autoload_register(array('ComposerAutoloaderInitComposerPhar1603208047', 'loadClassLoader'), true, true);
  58833. self::$loader = $loader = new \Composer\Autoload\ClassLoader();
  58834. spl_autoload_unregister(array('ComposerAutoloaderInitComposerPhar1603208047', 'loadClassLoader'));
  58835. $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
  58836. if ($useStaticLoader) {
  58837. require __DIR__ . '/autoload_static.php';
  58838. call_user_func(\Composer\Autoload\ComposerStaticInitComposerPhar1603208047::getInitializer($loader));
  58839. } else {
  58840. $map = require __DIR__ . '/autoload_namespaces.php';
  58841. foreach ($map as $namespace => $path) {
  58842. $loader->set($namespace, $path);
  58843. }
  58844. $map = require __DIR__ . '/autoload_psr4.php';
  58845. foreach ($map as $namespace => $path) {
  58846. $loader->setPsr4($namespace, $path);
  58847. }
  58848. $classMap = require __DIR__ . '/autoload_classmap.php';
  58849. if ($classMap) {
  58850. $loader->addClassMap($classMap);
  58851. }
  58852. }
  58853. $loader->register(true);
  58854. if ($useStaticLoader) {
  58855. $includeFiles = Composer\Autoload\ComposerStaticInitComposerPhar1603208047::$files;
  58856. } else {
  58857. $includeFiles = require __DIR__ . '/autoload_files.php';
  58858. }
  58859. foreach ($includeFiles as $fileIdentifier => $file) {
  58860. composerRequireComposerPhar1603208047($fileIdentifier, $file);
  58861. }
  58862. return $loader;
  58863. }
  58864. }
  58865. function composerRequireComposerPhar1603208047($fileIdentifier, $file)
  58866. {
  58867. if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  58868. require $file;
  58869. $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
  58870. }
  58871. }
  58872. <?php
  58873. namespace Composer\Autoload;
  58874. class ComposerStaticInitComposerPhar1603208047
  58875. {
  58876. public static $files = array (
  58877. '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
  58878. '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
  58879. '7844cce90d4037f1a077c08319eef109' => __DIR__ . '/..' . '/react/promise/src/React/Promise/functions_include.php',
  58880. );
  58881. public static $prefixLengthsPsr4 = array (
  58882. 'S' =>
  58883. array (
  58884. 'Symfony\\Polyfill\\Mbstring\\' => 26,
  58885. 'Symfony\\Polyfill\\Ctype\\' => 23,
  58886. 'Symfony\\Component\\Process\\' => 26,
  58887. 'Symfony\\Component\\Finder\\' => 25,
  58888. 'Symfony\\Component\\Filesystem\\' => 29,
  58889. 'Symfony\\Component\\Debug\\' => 24,
  58890. 'Symfony\\Component\\Console\\' => 26,
  58891. 'Seld\\PharUtils\\' => 15,
  58892. 'Seld\\JsonLint\\' => 14,
  58893. ),
  58894. 'P' =>
  58895. array (
  58896. 'Psr\\Log\\' => 8,
  58897. ),
  58898. 'J' =>
  58899. array (
  58900. 'JsonSchema\\' => 11,
  58901. ),
  58902. 'C' =>
  58903. array (
  58904. 'Composer\\XdebugHandler\\' => 23,
  58905. 'Composer\\Spdx\\' => 14,
  58906. 'Composer\\Semver\\' => 16,
  58907. 'Composer\\CaBundle\\' => 18,
  58908. 'Composer\\' => 9,
  58909. ),
  58910. );
  58911. public static $prefixDirsPsr4 = array (
  58912. 'Symfony\\Polyfill\\Mbstring\\' =>
  58913. array (
  58914. 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
  58915. ),
  58916. 'Symfony\\Polyfill\\Ctype\\' =>
  58917. array (
  58918. 0 => __DIR__ . '/..' . '/symfony/polyfill-ctype',
  58919. ),
  58920. 'Symfony\\Component\\Process\\' =>
  58921. array (
  58922. 0 => __DIR__ . '/..' . '/symfony/process',
  58923. ),
  58924. 'Symfony\\Component\\Finder\\' =>
  58925. array (
  58926. 0 => __DIR__ . '/..' . '/symfony/finder',
  58927. ),
  58928. 'Symfony\\Component\\Filesystem\\' =>
  58929. array (
  58930. 0 => __DIR__ . '/..' . '/symfony/filesystem',
  58931. ),
  58932. 'Symfony\\Component\\Debug\\' =>
  58933. array (
  58934. 0 => __DIR__ . '/..' . '/symfony/debug',
  58935. ),
  58936. 'Symfony\\Component\\Console\\' =>
  58937. array (
  58938. 0 => __DIR__ . '/..' . '/symfony/console',
  58939. ),
  58940. 'Seld\\PharUtils\\' =>
  58941. array (
  58942. 0 => __DIR__ . '/..' . '/seld/phar-utils/src',
  58943. ),
  58944. 'Seld\\JsonLint\\' =>
  58945. array (
  58946. 0 => __DIR__ . '/..' . '/seld/jsonlint/src/Seld/JsonLint',
  58947. ),
  58948. 'Psr\\Log\\' =>
  58949. array (
  58950. 0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
  58951. ),
  58952. 'JsonSchema\\' =>
  58953. array (
  58954. 0 => __DIR__ . '/..' . '/justinrainbow/json-schema/src/JsonSchema',
  58955. ),
  58956. 'Composer\\XdebugHandler\\' =>
  58957. array (
  58958. 0 => __DIR__ . '/..' . '/composer/xdebug-handler/src',
  58959. ),
  58960. 'Composer\\Spdx\\' =>
  58961. array (
  58962. 0 => __DIR__ . '/..' . '/composer/spdx-licenses/src',
  58963. ),
  58964. 'Composer\\Semver\\' =>
  58965. array (
  58966. 0 => __DIR__ . '/..' . '/composer/semver/src',
  58967. ),
  58968. 'Composer\\CaBundle\\' =>
  58969. array (
  58970. 0 => __DIR__ . '/..' . '/composer/ca-bundle/src',
  58971. ),
  58972. 'Composer\\' =>
  58973. array (
  58974. 0 => __DIR__ . '/../..' . '/src/Composer',
  58975. ),
  58976. );
  58977. public static $prefixesPsr0 = array (
  58978. 'R' =>
  58979. array (
  58980. 'React\\Promise' =>
  58981. array (
  58982. 0 => __DIR__ . '/..' . '/react/promise/src',
  58983. ),
  58984. ),
  58985. );
  58986. public static $classMap = array (
  58987. 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
  58988. );
  58989. public static function getInitializer(ClassLoader $loader)
  58990. {
  58991. return \Closure::bind(function () use ($loader) {
  58992. $loader->prefixLengthsPsr4 = ComposerStaticInitComposerPhar1603208047::$prefixLengthsPsr4;
  58993. $loader->prefixDirsPsr4 = ComposerStaticInitComposerPhar1603208047::$prefixDirsPsr4;
  58994. $loader->prefixesPsr0 = ComposerStaticInitComposerPhar1603208047::$prefixesPsr0;
  58995. $loader->classMap = ComposerStaticInitComposerPhar1603208047::$classMap;
  58996. }, null, ClassLoader::class);
  58997. }
  58998. }
  58999. <?php return array (
  59000. 'root' =>
  59001. array (
  59002. 'pretty_version' => 'dev-master',
  59003. 'version' => 'dev-master',
  59004. 'aliases' =>
  59005. array (
  59006. 0 => '2.0.x-dev',
  59007. ),
  59008. 'reference' => '14ec957e96a24aefab22ba9eb1e0c6589d9a221c',
  59009. 'name' => 'composer/composer',
  59010. ),
  59011. 'versions' =>
  59012. array (
  59013. 'composer/ca-bundle' =>
  59014. array (
  59015. 'pretty_version' => '1.2.8',
  59016. 'version' => '1.2.8.0',
  59017. 'aliases' =>
  59018. array (
  59019. ),
  59020. 'reference' => '8a7ecad675253e4654ea05505233285377405215',
  59021. ),
  59022. 'composer/composer' =>
  59023. array (
  59024. 'pretty_version' => 'dev-master',
  59025. 'version' => 'dev-master',
  59026. 'aliases' =>
  59027. array (
  59028. 0 => '2.0.x-dev',
  59029. ),
  59030. 'reference' => '14ec957e96a24aefab22ba9eb1e0c6589d9a221c',
  59031. ),
  59032. 'composer/semver' =>
  59033. array (
  59034. 'pretty_version' => '3.2.2',
  59035. 'version' => '3.2.2.0',
  59036. 'aliases' =>
  59037. array (
  59038. ),
  59039. 'reference' => '4089fddb67bcf6bf860d91b979e95be303835002',
  59040. ),
  59041. 'composer/spdx-licenses' =>
  59042. array (
  59043. 'pretty_version' => '1.5.4',
  59044. 'version' => '1.5.4.0',
  59045. 'aliases' =>
  59046. array (
  59047. ),
  59048. 'reference' => '6946f785871e2314c60b4524851f3702ea4f2223',
  59049. ),
  59050. 'composer/xdebug-handler' =>
  59051. array (
  59052. 'pretty_version' => '1.4.3',
  59053. 'version' => '1.4.3.0',
  59054. 'aliases' =>
  59055. array (
  59056. ),
  59057. 'reference' => 'ebd27a9866ae8254e873866f795491f02418c5a5',
  59058. ),
  59059. 'justinrainbow/json-schema' =>
  59060. array (
  59061. 'pretty_version' => '5.2.10',
  59062. 'version' => '5.2.10.0',
  59063. 'aliases' =>
  59064. array (
  59065. ),
  59066. 'reference' => '2ba9c8c862ecd5510ed16c6340aa9f6eadb4f31b',
  59067. ),
  59068. 'psr/log' =>
  59069. array (
  59070. 'pretty_version' => '1.1.3',
  59071. 'version' => '1.1.3.0',
  59072. 'aliases' =>
  59073. array (
  59074. ),
  59075. 'reference' => '0f73288fd15629204f9d42b7055f72dacbe811fc',
  59076. ),
  59077. 'react/promise' =>
  59078. array (
  59079. 'pretty_version' => 'v1.2.1',
  59080. 'version' => '1.2.1.0',
  59081. 'aliases' =>
  59082. array (
  59083. ),
  59084. 'reference' => 'eefff597e67ff66b719f8171480add3c91474a1e',
  59085. ),
  59086. 'seld/jsonlint' =>
  59087. array (
  59088. 'pretty_version' => '1.8.2',
  59089. 'version' => '1.8.2.0',
  59090. 'aliases' =>
  59091. array (
  59092. ),
  59093. 'reference' => '590cfec960b77fd55e39b7d9246659e95dd6d337',
  59094. ),
  59095. 'seld/phar-utils' =>
  59096. array (
  59097. 'pretty_version' => '1.1.1',
  59098. 'version' => '1.1.1.0',
  59099. 'aliases' =>
  59100. array (
  59101. ),
  59102. 'reference' => '8674b1d84ffb47cc59a101f5d5a3b61e87d23796',
  59103. ),
  59104. 'symfony/console' =>
  59105. array (
  59106. 'pretty_version' => 'v2.8.52',
  59107. 'version' => '2.8.52.0',
  59108. 'aliases' =>
  59109. array (
  59110. ),
  59111. 'reference' => 'cbcf4b5e233af15cd2bbd50dee1ccc9b7927dc12',
  59112. ),
  59113. 'symfony/debug' =>
  59114. array (
  59115. 'pretty_version' => 'v2.8.52',
  59116. 'version' => '2.8.52.0',
  59117. 'aliases' =>
  59118. array (
  59119. ),
  59120. 'reference' => '74251c8d50dd3be7c4ce0c7b862497cdc641a5d0',
  59121. ),
  59122. 'symfony/filesystem' =>
  59123. array (
  59124. 'pretty_version' => 'v2.8.52',
  59125. 'version' => '2.8.52.0',
  59126. 'aliases' =>
  59127. array (
  59128. ),
  59129. 'reference' => '7ae46872dad09dffb7fe1e93a0937097339d0080',
  59130. ),
  59131. 'symfony/finder' =>
  59132. array (
  59133. 'pretty_version' => 'v2.8.52',
  59134. 'version' => '2.8.52.0',
  59135. 'aliases' =>
  59136. array (
  59137. ),
  59138. 'reference' => '1444eac52273e345d9b95129bf914639305a9ba4',
  59139. ),
  59140. 'symfony/polyfill-ctype' =>
  59141. array (
  59142. 'pretty_version' => 'v1.18.1',
  59143. 'version' => '1.18.1.0',
  59144. 'aliases' =>
  59145. array (
  59146. ),
  59147. 'reference' => '1c302646f6efc070cd46856e600e5e0684d6b454',
  59148. ),
  59149. 'symfony/polyfill-mbstring' =>
  59150. array (
  59151. 'pretty_version' => 'v1.18.1',
  59152. 'version' => '1.18.1.0',
  59153. 'aliases' =>
  59154. array (
  59155. ),
  59156. 'reference' => 'a6977d63bf9a0ad4c65cd352709e230876f9904a',
  59157. ),
  59158. 'symfony/process' =>
  59159. array (
  59160. 'pretty_version' => 'v2.8.52',
  59161. 'version' => '2.8.52.0',
  59162. 'aliases' =>
  59163. array (
  59164. ),
  59165. 'reference' => 'c3591a09c78639822b0b290d44edb69bf9f05dc8',
  59166. ),
  59167. ),
  59168. );
  59169. <?php
  59170. namespace Composer;
  59171. use Composer\Semver\VersionParser;
  59172. class InstalledVersions
  59173. {
  59174. private static $installed = array (
  59175. 'root' =>
  59176. array (
  59177. 'pretty_version' => 'dev-master',
  59178. 'version' => 'dev-master',
  59179. 'aliases' =>
  59180. array (
  59181. 0 => '2.0.x-dev',
  59182. ),
  59183. 'reference' => '14ec957e96a24aefab22ba9eb1e0c6589d9a221c',
  59184. 'name' => 'composer/composer',
  59185. ),
  59186. 'versions' =>
  59187. array (
  59188. 'composer/ca-bundle' =>
  59189. array (
  59190. 'pretty_version' => '1.2.8',
  59191. 'version' => '1.2.8.0',
  59192. 'aliases' =>
  59193. array (
  59194. ),
  59195. 'reference' => '8a7ecad675253e4654ea05505233285377405215',
  59196. ),
  59197. 'composer/composer' =>
  59198. array (
  59199. 'pretty_version' => 'dev-master',
  59200. 'version' => 'dev-master',
  59201. 'aliases' =>
  59202. array (
  59203. 0 => '2.0.x-dev',
  59204. ),
  59205. 'reference' => '14ec957e96a24aefab22ba9eb1e0c6589d9a221c',
  59206. ),
  59207. 'composer/semver' =>
  59208. array (
  59209. 'pretty_version' => '3.2.2',
  59210. 'version' => '3.2.2.0',
  59211. 'aliases' =>
  59212. array (
  59213. ),
  59214. 'reference' => '4089fddb67bcf6bf860d91b979e95be303835002',
  59215. ),
  59216. 'composer/spdx-licenses' =>
  59217. array (
  59218. 'pretty_version' => '1.5.4',
  59219. 'version' => '1.5.4.0',
  59220. 'aliases' =>
  59221. array (
  59222. ),
  59223. 'reference' => '6946f785871e2314c60b4524851f3702ea4f2223',
  59224. ),
  59225. 'composer/xdebug-handler' =>
  59226. array (
  59227. 'pretty_version' => '1.4.3',
  59228. 'version' => '1.4.3.0',
  59229. 'aliases' =>
  59230. array (
  59231. ),
  59232. 'reference' => 'ebd27a9866ae8254e873866f795491f02418c5a5',
  59233. ),
  59234. 'justinrainbow/json-schema' =>
  59235. array (
  59236. 'pretty_version' => '5.2.10',
  59237. 'version' => '5.2.10.0',
  59238. 'aliases' =>
  59239. array (
  59240. ),
  59241. 'reference' => '2ba9c8c862ecd5510ed16c6340aa9f6eadb4f31b',
  59242. ),
  59243. 'psr/log' =>
  59244. array (
  59245. 'pretty_version' => '1.1.3',
  59246. 'version' => '1.1.3.0',
  59247. 'aliases' =>
  59248. array (
  59249. ),
  59250. 'reference' => '0f73288fd15629204f9d42b7055f72dacbe811fc',
  59251. ),
  59252. 'react/promise' =>
  59253. array (
  59254. 'pretty_version' => 'v1.2.1',
  59255. 'version' => '1.2.1.0',
  59256. 'aliases' =>
  59257. array (
  59258. ),
  59259. 'reference' => 'eefff597e67ff66b719f8171480add3c91474a1e',
  59260. ),
  59261. 'seld/jsonlint' =>
  59262. array (
  59263. 'pretty_version' => '1.8.2',
  59264. 'version' => '1.8.2.0',
  59265. 'aliases' =>
  59266. array (
  59267. ),
  59268. 'reference' => '590cfec960b77fd55e39b7d9246659e95dd6d337',
  59269. ),
  59270. 'seld/phar-utils' =>
  59271. array (
  59272. 'pretty_version' => '1.1.1',
  59273. 'version' => '1.1.1.0',
  59274. 'aliases' =>
  59275. array (
  59276. ),
  59277. 'reference' => '8674b1d84ffb47cc59a101f5d5a3b61e87d23796',
  59278. ),
  59279. 'symfony/console' =>
  59280. array (
  59281. 'pretty_version' => 'v2.8.52',
  59282. 'version' => '2.8.52.0',
  59283. 'aliases' =>
  59284. array (
  59285. ),
  59286. 'reference' => 'cbcf4b5e233af15cd2bbd50dee1ccc9b7927dc12',
  59287. ),
  59288. 'symfony/debug' =>
  59289. array (
  59290. 'pretty_version' => 'v2.8.52',
  59291. 'version' => '2.8.52.0',
  59292. 'aliases' =>
  59293. array (
  59294. ),
  59295. 'reference' => '74251c8d50dd3be7c4ce0c7b862497cdc641a5d0',
  59296. ),
  59297. 'symfony/filesystem' =>
  59298. array (
  59299. 'pretty_version' => 'v2.8.52',
  59300. 'version' => '2.8.52.0',
  59301. 'aliases' =>
  59302. array (
  59303. ),
  59304. 'reference' => '7ae46872dad09dffb7fe1e93a0937097339d0080',
  59305. ),
  59306. 'symfony/finder' =>
  59307. array (
  59308. 'pretty_version' => 'v2.8.52',
  59309. 'version' => '2.8.52.0',
  59310. 'aliases' =>
  59311. array (
  59312. ),
  59313. 'reference' => '1444eac52273e345d9b95129bf914639305a9ba4',
  59314. ),
  59315. 'symfony/polyfill-ctype' =>
  59316. array (
  59317. 'pretty_version' => 'v1.18.1',
  59318. 'version' => '1.18.1.0',
  59319. 'aliases' =>
  59320. array (
  59321. ),
  59322. 'reference' => '1c302646f6efc070cd46856e600e5e0684d6b454',
  59323. ),
  59324. 'symfony/polyfill-mbstring' =>
  59325. array (
  59326. 'pretty_version' => 'v1.18.1',
  59327. 'version' => '1.18.1.0',
  59328. 'aliases' =>
  59329. array (
  59330. ),
  59331. 'reference' => 'a6977d63bf9a0ad4c65cd352709e230876f9904a',
  59332. ),
  59333. 'symfony/process' =>
  59334. array (
  59335. 'pretty_version' => 'v2.8.52',
  59336. 'version' => '2.8.52.0',
  59337. 'aliases' =>
  59338. array (
  59339. ),
  59340. 'reference' => 'c3591a09c78639822b0b290d44edb69bf9f05dc8',
  59341. ),
  59342. ),
  59343. );
  59344. public static function getInstalledPackages()
  59345. {
  59346. return array_keys(self::$installed['versions']);
  59347. }
  59348. public static function isInstalled($packageName)
  59349. {
  59350. return isset(self::$installed['versions'][$packageName]);
  59351. }
  59352. public static function satisfies(VersionParser $parser, $packageName, $constraint)
  59353. {
  59354. $constraint = $parser->parseConstraints($constraint);
  59355. $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
  59356. return $provided->matches($constraint);
  59357. }
  59358. public static function getVersionRanges($packageName)
  59359. {
  59360. if (!isset(self::$installed['versions'][$packageName])) {
  59361. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  59362. }
  59363. $ranges = array();
  59364. if (isset(self::$installed['versions'][$packageName]['pretty_version'])) {
  59365. $ranges[] = self::$installed['versions'][$packageName]['pretty_version'];
  59366. }
  59367. if (array_key_exists('aliases', self::$installed['versions'][$packageName])) {
  59368. $ranges = array_merge($ranges, self::$installed['versions'][$packageName]['aliases']);
  59369. }
  59370. if (array_key_exists('replaced', self::$installed['versions'][$packageName])) {
  59371. $ranges = array_merge($ranges, self::$installed['versions'][$packageName]['replaced']);
  59372. }
  59373. if (array_key_exists('provided', self::$installed['versions'][$packageName])) {
  59374. $ranges = array_merge($ranges, self::$installed['versions'][$packageName]['provided']);
  59375. }
  59376. return implode(' || ', $ranges);
  59377. }
  59378. public static function getVersion($packageName)
  59379. {
  59380. if (!isset(self::$installed['versions'][$packageName])) {
  59381. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  59382. }
  59383. if (!isset(self::$installed['versions'][$packageName]['version'])) {
  59384. return null;
  59385. }
  59386. return self::$installed['versions'][$packageName]['version'];
  59387. }
  59388. public static function getPrettyVersion($packageName)
  59389. {
  59390. if (!isset(self::$installed['versions'][$packageName])) {
  59391. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  59392. }
  59393. if (!isset(self::$installed['versions'][$packageName]['pretty_version'])) {
  59394. return null;
  59395. }
  59396. return self::$installed['versions'][$packageName]['pretty_version'];
  59397. }
  59398. public static function getReference($packageName)
  59399. {
  59400. if (!isset(self::$installed['versions'][$packageName])) {
  59401. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  59402. }
  59403. if (!isset(self::$installed['versions'][$packageName]['reference'])) {
  59404. return null;
  59405. }
  59406. return self::$installed['versions'][$packageName]['reference'];
  59407. }
  59408. public static function getRootPackage()
  59409. {
  59410. return self::$installed['root'];
  59411. }
  59412. public static function getRawData()
  59413. {
  59414. return self::$installed;
  59415. }
  59416. public static function reload($data)
  59417. {
  59418. self::$installed = $data;
  59419. }
  59420. }
  59421. <?php
  59422. namespace Composer\Autoload;
  59423. class ClassLoader
  59424. {
  59425. private $prefixLengthsPsr4 = array();
  59426. private $prefixDirsPsr4 = array();
  59427. private $fallbackDirsPsr4 = array();
  59428. private $prefixesPsr0 = array();
  59429. private $fallbackDirsPsr0 = array();
  59430. private $useIncludePath = false;
  59431. private $classMap = array();
  59432. private $classMapAuthoritative = false;
  59433. private $missingClasses = array();
  59434. private $apcuPrefix;
  59435. public function getPrefixes()
  59436. {
  59437. if (!empty($this->prefixesPsr0)) {
  59438. return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
  59439. }
  59440. return array();
  59441. }
  59442. public function getPrefixesPsr4()
  59443. {
  59444. return $this->prefixDirsPsr4;
  59445. }
  59446. public function getFallbackDirs()
  59447. {
  59448. return $this->fallbackDirsPsr0;
  59449. }
  59450. public function getFallbackDirsPsr4()
  59451. {
  59452. return $this->fallbackDirsPsr4;
  59453. }
  59454. public function getClassMap()
  59455. {
  59456. return $this->classMap;
  59457. }
  59458. public function addClassMap(array $classMap)
  59459. {
  59460. if ($this->classMap) {
  59461. $this->classMap = array_merge($this->classMap, $classMap);
  59462. } else {
  59463. $this->classMap = $classMap;
  59464. }
  59465. }
  59466. public function add($prefix, $paths, $prepend = false)
  59467. {
  59468. if (!$prefix) {
  59469. if ($prepend) {
  59470. $this->fallbackDirsPsr0 = array_merge(
  59471. (array) $paths,
  59472. $this->fallbackDirsPsr0
  59473. );
  59474. } else {
  59475. $this->fallbackDirsPsr0 = array_merge(
  59476. $this->fallbackDirsPsr0,
  59477. (array) $paths
  59478. );
  59479. }
  59480. return;
  59481. }
  59482. $first = $prefix[0];
  59483. if (!isset($this->prefixesPsr0[$first][$prefix])) {
  59484. $this->prefixesPsr0[$first][$prefix] = (array) $paths;
  59485. return;
  59486. }
  59487. if ($prepend) {
  59488. $this->prefixesPsr0[$first][$prefix] = array_merge(
  59489. (array) $paths,
  59490. $this->prefixesPsr0[$first][$prefix]
  59491. );
  59492. } else {
  59493. $this->prefixesPsr0[$first][$prefix] = array_merge(
  59494. $this->prefixesPsr0[$first][$prefix],
  59495. (array) $paths
  59496. );
  59497. }
  59498. }
  59499. public function addPsr4($prefix, $paths, $prepend = false)
  59500. {
  59501. if (!$prefix) {
  59502. if ($prepend) {
  59503. $this->fallbackDirsPsr4 = array_merge(
  59504. (array) $paths,
  59505. $this->fallbackDirsPsr4
  59506. );
  59507. } else {
  59508. $this->fallbackDirsPsr4 = array_merge(
  59509. $this->fallbackDirsPsr4,
  59510. (array) $paths
  59511. );
  59512. }
  59513. } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
  59514. $length = strlen($prefix);
  59515. if ('\\' !== $prefix[$length - 1]) {
  59516. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  59517. }
  59518. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  59519. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  59520. } elseif ($prepend) {
  59521. $this->prefixDirsPsr4[$prefix] = array_merge(
  59522. (array) $paths,
  59523. $this->prefixDirsPsr4[$prefix]
  59524. );
  59525. } else {
  59526. $this->prefixDirsPsr4[$prefix] = array_merge(
  59527. $this->prefixDirsPsr4[$prefix],
  59528. (array) $paths
  59529. );
  59530. }
  59531. }
  59532. public function set($prefix, $paths)
  59533. {
  59534. if (!$prefix) {
  59535. $this->fallbackDirsPsr0 = (array) $paths;
  59536. } else {
  59537. $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
  59538. }
  59539. }
  59540. public function setPsr4($prefix, $paths)
  59541. {
  59542. if (!$prefix) {
  59543. $this->fallbackDirsPsr4 = (array) $paths;
  59544. } else {
  59545. $length = strlen($prefix);
  59546. if ('\\' !== $prefix[$length - 1]) {
  59547. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  59548. }
  59549. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  59550. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  59551. }
  59552. }
  59553. public function setUseIncludePath($useIncludePath)
  59554. {
  59555. $this->useIncludePath = $useIncludePath;
  59556. }
  59557. public function getUseIncludePath()
  59558. {
  59559. return $this->useIncludePath;
  59560. }
  59561. public function setClassMapAuthoritative($classMapAuthoritative)
  59562. {
  59563. $this->classMapAuthoritative = $classMapAuthoritative;
  59564. }
  59565. public function isClassMapAuthoritative()
  59566. {
  59567. return $this->classMapAuthoritative;
  59568. }
  59569. public function setApcuPrefix($apcuPrefix)
  59570. {
  59571. $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
  59572. }
  59573. public function getApcuPrefix()
  59574. {
  59575. return $this->apcuPrefix;
  59576. }
  59577. public function register($prepend = false)
  59578. {
  59579. spl_autoload_register(array($this, 'loadClass'), true, $prepend);
  59580. }
  59581. public function unregister()
  59582. {
  59583. spl_autoload_unregister(array($this, 'loadClass'));
  59584. }
  59585. public function loadClass($class)
  59586. {
  59587. if ($file = $this->findFile($class)) {
  59588. includeFile($file);
  59589. return true;
  59590. }
  59591. }
  59592. public function findFile($class)
  59593. {
  59594. if (isset($this->classMap[$class])) {
  59595. return $this->classMap[$class];
  59596. }
  59597. if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
  59598. return false;
  59599. }
  59600. if (null !== $this->apcuPrefix) {
  59601. $file = apcu_fetch($this->apcuPrefix.$class, $hit);
  59602. if ($hit) {
  59603. return $file;
  59604. }
  59605. }
  59606. $file = $this->findFileWithExtension($class, '.php');
  59607. if (false === $file && defined('HHVM_VERSION')) {
  59608. $file = $this->findFileWithExtension($class, '.hh');
  59609. }
  59610. if (null !== $this->apcuPrefix) {
  59611. apcu_add($this->apcuPrefix.$class, $file);
  59612. }
  59613. if (false === $file) {
  59614. $this->missingClasses[$class] = true;
  59615. }
  59616. return $file;
  59617. }
  59618. private function findFileWithExtension($class, $ext)
  59619. {
  59620. $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
  59621. $first = $class[0];
  59622. if (isset($this->prefixLengthsPsr4[$first])) {
  59623. $subPath = $class;
  59624. while (false !== $lastPos = strrpos($subPath, '\\')) {
  59625. $subPath = substr($subPath, 0, $lastPos);
  59626. $search = $subPath . '\\';
  59627. if (isset($this->prefixDirsPsr4[$search])) {
  59628. $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
  59629. foreach ($this->prefixDirsPsr4[$search] as $dir) {
  59630. if (file_exists($file = $dir . $pathEnd)) {
  59631. return $file;
  59632. }
  59633. }
  59634. }
  59635. }
  59636. }
  59637. foreach ($this->fallbackDirsPsr4 as $dir) {
  59638. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
  59639. return $file;
  59640. }
  59641. }
  59642. if (false !== $pos = strrpos($class, '\\')) {
  59643. $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
  59644. . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
  59645. } else {
  59646. $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
  59647. }
  59648. if (isset($this->prefixesPsr0[$first])) {
  59649. foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
  59650. if (0 === strpos($class, $prefix)) {
  59651. foreach ($dirs as $dir) {
  59652. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  59653. return $file;
  59654. }
  59655. }
  59656. }
  59657. }
  59658. }
  59659. foreach ($this->fallbackDirsPsr0 as $dir) {
  59660. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  59661. return $file;
  59662. }
  59663. }
  59664. if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
  59665. return $file;
  59666. }
  59667. return false;
  59668. }
  59669. }
  59670. function includeFile($file)
  59671. {
  59672. include $file;
  59673. }
  59674. ##
  59675. ## Bundle of CA Root Certificates
  59676. ##
  59677. ## Certificate data from Mozilla as of: Wed Jul 22 03:12:14 2020 GMT
  59678. ##
  59679. ## This is a bundle of X.509 certificates of public Certificate Authorities
  59680. ## (CA). These were automatically extracted from Mozilla's root certificates
  59681. ## file (certdata.txt). This file can be found in the mozilla source tree:
  59682. ## https://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt
  59683. ##
  59684. ## It contains the certificates in PEM format and therefore
  59685. ## can be directly used with curl / libcurl / php_curl, or with
  59686. ## an Apache+mod_ssl webserver for SSL client authentication.
  59687. ## Just configure this file as the SSLCACertificateFile.
  59688. ##
  59689. ## Conversion done with mk-ca-bundle.pl version 1.28.
  59690. ## SHA256: cc6408bd4be7fbfb8699bdb40ccb7f6de5780d681d87785ea362646e4dad5e8e
  59691. ##
  59692. GlobalSign Root CA
  59693. ==================
  59694. -----BEGIN CERTIFICATE-----
  59695. MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkGA1UEBhMCQkUx
  59696. GTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jvb3QgQ0ExGzAZBgNVBAMTEkds
  59697. b2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAwMDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNV
  59698. BAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYD
  59699. VQQDExJHbG9iYWxTaWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDa
  59700. DuaZjc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavpxy0Sy6sc
  59701. THAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp1Wrjsok6Vjk4bwY8iGlb
  59702. Kk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdGsnUOhugZitVtbNV4FpWi6cgKOOvyJBNP
  59703. c1STE4U6G7weNLWLBYy5d4ux2x8gkasJU26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrX
  59704. gzT/LCrBbBlDSgeF59N89iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV
  59705. HRMBAf8EBTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0BAQUF
  59706. AAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOzyj1hTdNGCbM+w6Dj
  59707. Y1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE38NflNUVyRRBnMRddWQVDf9VMOyG
  59708. j/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymPAbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhH
  59709. hm4qxFYxldBniYUr+WymXUadDKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveC
  59710. X4XSQRjbgbMEHMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==
  59711. -----END CERTIFICATE-----
  59712. GlobalSign Root CA - R2
  59713. =======================
  59714. -----BEGIN CERTIFICATE-----
  59715. MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4GA1UECxMXR2xv
  59716. YmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh
  59717. bFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT
  59718. aWduIFJvb3QgQ0EgLSBSMjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln
  59719. bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6
  59720. ErPLv4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8eoLrvozp
  59721. s6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklqtTleiDTsvHgMCJiEbKjN
  59722. S7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzdC9XZzPnqJworc5HGnRusyMvo4KD0L5CL
  59723. TfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pazq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6C
  59724. ygPCm48CAwEAAaOBnDCBmTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4E
  59725. FgQUm+IHV2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5nbG9i
  59726. YWxzaWduLm5ldC9yb290LXIyLmNybDAfBgNVHSMEGDAWgBSb4gdXZxwewGoG3lm0mi3f3BmGLjAN
  59727. BgkqhkiG9w0BAQUFAAOCAQEAmYFThxxol4aR7OBKuEQLq4GsJ0/WwbgcQ3izDJr86iw8bmEbTUsp
  59728. 9Z8FHSbBuOmDAGJFtqkIk7mpM0sYmsL4h4hO291xNBrBVNpGP+DTKqttVCL1OmLNIG+6KYnX3ZHu
  59729. 01yiPqFbQfXf5WRDLenVOavSot+3i9DAgBkcRcAtjOj4LaR0VknFBbVPFd5uRHg5h6h+u/N5GJG7
  59730. 9G+dwfCMNYxdAfvDbbnvRG15RjF+Cv6pgsH/76tuIMRQyV+dTZsXjAzlAcmgQWpzU/qlULRuJQ/7
  59731. TBj0/VLZjmmx6BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg==
  59732. -----END CERTIFICATE-----
  59733. Entrust.net Premium 2048 Secure Server CA
  59734. =========================================
  59735. -----BEGIN CERTIFICATE-----
  59736. MIIEKjCCAxKgAwIBAgIEOGPe+DANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChMLRW50cnVzdC5u
  59737. ZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBpbmNvcnAuIGJ5IHJlZi4gKGxp
  59738. bWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNV
  59739. BAMTKkVudHJ1c3QubmV0IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ICgyMDQ4KTAeFw05OTEyMjQx
  59740. NzUwNTFaFw0yOTA3MjQxNDE1MTJaMIG0MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDFAMD4GA1UECxQ3
  59741. d3d3LmVudHJ1c3QubmV0L0NQU18yMDQ4IGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTEl
  59742. MCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEGA1UEAxMqRW50cnVzdC5u
  59743. ZXQgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgKDIwNDgpMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  59744. MIIBCgKCAQEArU1LqRKGsuqjIAcVFmQqK0vRvwtKTY7tgHalZ7d4QMBzQshowNtTK91euHaYNZOL
  59745. Gp18EzoOH1u3Hs/lJBQesYGpjX24zGtLA/ECDNyrpUAkAH90lKGdCCmziAv1h3edVc3kw37XamSr
  59746. hRSGlVuXMlBvPci6Zgzj/L24ScF2iUkZ/cCovYmjZy/Gn7xxGWC4LeksyZB2ZnuU4q941mVTXTzW
  59747. nLLPKQP5L6RQstRIzgUyVYr9smRMDuSYB3Xbf9+5CFVghTAp+XtIpGmG4zU/HoZdenoVve8AjhUi
  59748. VBcAkCaTvA5JaJG/+EfTnZVCwQ5N328mz8MYIWJmQ3DW1cAH4QIDAQABo0IwQDAOBgNVHQ8BAf8E
  59749. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUVeSB0RGAvtiJuQijMfmhJAkWuXAwDQYJ
  59750. KoZIhvcNAQEFBQADggEBADubj1abMOdTmXx6eadNl9cZlZD7Bh/KM3xGY4+WZiT6QBshJ8rmcnPy
  59751. T/4xmf3IDExoU8aAghOY+rat2l098c5u9hURlIIM7j+VrxGrD9cv3h8Dj1csHsm7mhpElesYT6Yf
  59752. zX1XEC+bBAlahLVu2B064dae0Wx5XnkcFMXj0EyTO2U87d89vqbllRrDtRnDvV5bu/8j72gZyxKT
  59753. J1wDLW8w0B62GqzeWvfRqqgnpv55gcR5mTNXuhKwqeBCbJPKVt7+bYQLCIt+jerXmCHG8+c8eS9e
  59754. nNFMFY3h7CI3zJpDC5fcgJCNs2ebb0gIFVbPv/ErfF6adulZkMV8gzURZVE=
  59755. -----END CERTIFICATE-----
  59756. Baltimore CyberTrust Root
  59757. =========================
  59758. -----BEGIN CERTIFICATE-----
  59759. MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJRTESMBAGA1UE
  59760. ChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYDVQQDExlCYWx0aW1vcmUgQ3li
  59761. ZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoXDTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMC
  59762. SUUxEjAQBgNVBAoTCUJhbHRpbW9yZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFs
  59763. dGltb3JlIEN5YmVyVHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKME
  59764. uyKrmD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjrIZ3AQSsB
  59765. UnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeKmpYcqWe4PwzV9/lSEy/C
  59766. G9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSuXmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9
  59767. XbIGevOF6uvUA65ehD5f/xXtabz5OTZydc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjpr
  59768. l3RjM71oGDHweI12v/yejl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoI
  59769. VDaGezq1BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEB
  59770. BQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT929hkTI7gQCvlYpNRh
  59771. cL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3WgxjkzSswF07r51XgdIGn9w/xZchMB5
  59772. hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsa
  59773. Y71k5h+3zvDyny67G7fyUIhzksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9H
  59774. RCwBXbsdtTLSR9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp
  59775. -----END CERTIFICATE-----
  59776. Entrust Root Certification Authority
  59777. ====================================
  59778. -----BEGIN CERTIFICATE-----
  59779. MIIEkTCCA3mgAwIBAgIERWtQVDANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMCVVMxFjAUBgNV
  59780. BAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0Lm5ldC9DUFMgaXMgaW5jb3Jw
  59781. b3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMWKGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsG
  59782. A1UEAxMkRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTEyNzIwMjM0
  59783. MloXDTI2MTEyNzIwNTM0MlowgbAxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMu
  59784. MTkwNwYDVQQLEzB3d3cuZW50cnVzdC5uZXQvQ1BTIGlzIGluY29ycG9yYXRlZCBieSByZWZlcmVu
  59785. Y2UxHzAdBgNVBAsTFihjKSAyMDA2IEVudHJ1c3QsIEluYy4xLTArBgNVBAMTJEVudHJ1c3QgUm9v
  59786. dCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  59787. ALaVtkNC+sZtKm9I35RMOVcF7sN5EUFoNu3s/poBj6E4KPz3EEZmLk0eGrEaTsbRwJWIsMn/MYsz
  59788. A9u3g3s+IIRe7bJWKKf44LlAcTfFy0cOlypowCKVYhXbR9n10Cv/gkvJrT7eTNuQgFA/CYqEAOww
  59789. Cj0Yzfv9KlmaI5UXLEWeH25DeW0MXJj+SKfFI0dcXv1u5x609mhF0YaDW6KKjbHjKYD+JXGIrb68
  59790. j6xSlkuqUY3kEzEZ6E5Nn9uss2rVvDlUccp6en+Q3X0dgNmBu1kmwhH+5pPi94DkZfs0Nw4pgHBN
  59791. rziGLp5/V6+eF67rHMsoIV+2HNjnogQi+dPa2MsCAwEAAaOBsDCBrTAOBgNVHQ8BAf8EBAMCAQYw
  59792. DwYDVR0TAQH/BAUwAwEB/zArBgNVHRAEJDAigA8yMDA2MTEyNzIwMjM0MlqBDzIwMjYxMTI3MjA1
  59793. MzQyWjAfBgNVHSMEGDAWgBRokORnpKZTgMeGZqTx90tD+4S9bTAdBgNVHQ4EFgQUaJDkZ6SmU4DH
  59794. hmak8fdLQ/uEvW0wHQYJKoZIhvZ9B0EABBAwDhsIVjcuMTo0LjADAgSQMA0GCSqGSIb3DQEBBQUA
  59795. A4IBAQCT1DCw1wMgKtD5Y+iRDAUgqV8ZyntyTtSx29CW+1RaGSwMCPeyvIWonX9tO1KzKtvn1ISM
  59796. Y/YPyyYBkVBs9F8U4pN0wBOeMDpQ47RgxRzwIkSNcUesyBrJ6ZuaAGAT/3B+XxFNSRuzFVJ7yVTa
  59797. v52Vr2ua2J7p8eRDjeIRRDq/r72DQnNSi6q7pynP9WQcCk3RvKqsnyrQ/39/2n3qse0wJcGE2jTS
  59798. W3iDVuycNsMm4hH2Z0kdkquM++v/eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0
  59799. tHuu2guQOHXvgR1m0vdXcDazv/wor3ElhVsT/h5/WrQ8
  59800. -----END CERTIFICATE-----
  59801. GeoTrust Global CA
  59802. ==================
  59803. -----BEGIN CERTIFICATE-----
  59804. MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVTMRYwFAYDVQQK
  59805. Ew1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9iYWwgQ0EwHhcNMDIwNTIxMDQw
  59806. MDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5j
  59807. LjEbMBkGA1UEAxMSR2VvVHJ1c3QgR2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
  59808. CgKCAQEA2swYYzD99BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjo
  59809. BbdqfnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDviS2Aelet
  59810. 8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU1XupGc1V3sjs0l44U+Vc
  59811. T4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+bw8HHa8sHo9gOeL6NlMTOdReJivbPagU
  59812. vTLrGAMoUgRx5aszPeE4uwc2hGKceeoWMPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTAD
  59813. AQH/MB0GA1UdDgQWBBTAephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVk
  59814. DBF9qn1luMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKInZ57Q
  59815. zxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfStQWVYrmm3ok9Nns4
  59816. d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcFPseKUgzbFbS9bZvlxrFUaKnjaZC2
  59817. mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Unhw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6p
  59818. XE0zX5IJL4hmXXeXxx12E6nV5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvm
  59819. Mw==
  59820. -----END CERTIFICATE-----
  59821. GeoTrust Universal CA
  59822. =====================
  59823. -----BEGIN CERTIFICATE-----
  59824. MIIFaDCCA1CgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJVUzEWMBQGA1UEChMN
  59825. R2VvVHJ1c3QgSW5jLjEeMBwGA1UEAxMVR2VvVHJ1c3QgVW5pdmVyc2FsIENBMB4XDTA0MDMwNDA1
  59826. MDAwMFoXDTI5MDMwNDA1MDAwMFowRTELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IElu
  59827. Yy4xHjAcBgNVBAMTFUdlb1RydXN0IFVuaXZlcnNhbCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIP
  59828. ADCCAgoCggIBAKYVVaCjxuAfjJ0hUNfBvitbtaSeodlyWL0AG0y/YckUHUWCq8YdgNY96xCcOq9t
  59829. JPi8cQGeBvV8Xx7BDlXKg5pZMK4ZyzBIle0iN430SppyZj6tlcDgFgDgEB8rMQ7XlFTTQjOgNB0e
  59830. RXbdT8oYN+yFFXoZCPzVx5zw8qkuEKmS5j1YPakWaDwvdSEYfyh3peFhF7em6fgemdtzbvQKoiFs
  59831. 7tqqhZJmr/Z6a4LauiIINQ/PQvE1+mrufislzDoR5G2vc7J2Ha3QsnhnGqQ5HFELZ1aD/ThdDc7d
  59832. 8Lsrlh/eezJS/R27tQahsiFepdaVaH/wmZ7cRQg+59IJDTWU3YBOU5fXtQlEIGQWFwMCTFMNaN7V
  59833. qnJNk22CDtucvc+081xdVHppCZbW2xHBjXWotM85yM48vCR85mLK4b19p71XZQvk/iXttmkQ3Cga
  59834. Rr0BHdCXteGYO8A3ZNY9lO4L4fUorgtWv3GLIylBjobFS1J72HGrH4oVpjuDWtdYAVHGTEHZf9hB
  59835. Z3KiKN9gg6meyHv8U3NyWfWTehd2Ds735VzZC1U0oqpbtWpU5xPKV+yXbfReBi9Fi1jUIxaS5BZu
  59836. KGNZMN9QAZxjiRqf2xeUgnA3wySemkfWWspOqGmJch+RbNt+nhutxx9z3SxPGWX9f5NAEC7S8O08
  59837. ni4oPmkmM8V7AgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFNq7LqqwDLiIJlF0
  59838. XG0D08DYj3rWMB8GA1UdIwQYMBaAFNq7LqqwDLiIJlF0XG0D08DYj3rWMA4GA1UdDwEB/wQEAwIB
  59839. hjANBgkqhkiG9w0BAQUFAAOCAgEAMXjmx7XfuJRAyXHEqDXsRh3ChfMoWIawC/yOsjmPRFWrZIRc
  59840. aanQmjg8+uUfNeVE44B5lGiku8SfPeE0zTBGi1QrlaXv9z+ZhP015s8xxtxqv6fXIwjhmF7DWgh2
  59841. qaavdy+3YL1ERmrvl/9zlcGO6JP7/TG37FcREUWbMPEaiDnBTzynANXH/KttgCJwpQzgXQQpAvvL
  59842. oJHRfNbDflDVnVi+QTjruXU8FdmbyUqDWcDaU/0zuzYYm4UPFd3uLax2k7nZAY1IEKj79TiG8dsK
  59843. xr2EoyNB3tZ3b4XUhRxQ4K5RirqNPnbiucon8l+f725ZDQbYKxek0nxru18UGkiPGkzns0ccjkxF
  59844. KyDuSN/n3QmOGKjaQI2SJhFTYXNd673nxE0pN2HrrDktZy4W1vUAg4WhzH92xH3kt0tm7wNFYGm2
  59845. DFKWkoRepqO1pD4r2czYG0eq8kTaT/kD6PAUyz/zg97QwVTjt+gKN02LIFkDMBmhLMi9ER/frslK
  59846. xfMnZmaGrGiR/9nmUxwPi1xpZQomyB40w11Re9epnAahNt3ViZS82eQtDF4JbAiXfKM9fJP/P6EU
  59847. p8+1Xevb2xzEdt+Iub1FBZUbrvxGakyvSOPOrg/SfuvmbJxPgWp6ZKy7PtXny3YuxadIwVyQD8vI
  59848. P/rmMuGNG2+k5o7Y+SlIis5z/iw=
  59849. -----END CERTIFICATE-----
  59850. GeoTrust Universal CA 2
  59851. =======================
  59852. -----BEGIN CERTIFICATE-----
  59853. MIIFbDCCA1SgAwIBAgIBATANBgkqhkiG9w0BAQUFADBHMQswCQYDVQQGEwJVUzEWMBQGA1UEChMN
  59854. R2VvVHJ1c3QgSW5jLjEgMB4GA1UEAxMXR2VvVHJ1c3QgVW5pdmVyc2FsIENBIDIwHhcNMDQwMzA0
  59855. MDUwMDAwWhcNMjkwMzA0MDUwMDAwWjBHMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3Qg
  59856. SW5jLjEgMB4GA1UEAxMXR2VvVHJ1c3QgVW5pdmVyc2FsIENBIDIwggIiMA0GCSqGSIb3DQEBAQUA
  59857. A4ICDwAwggIKAoICAQCzVFLByT7y2dyxUxpZKeexw0Uo5dfR7cXFS6GqdHtXr0om/Nj1XqduGdt0
  59858. DE81WzILAePb63p3NeqqWuDW6KFXlPCQo3RWlEQwAx5cTiuFJnSCegx2oG9NzkEtoBUGFF+3Qs17
  59859. j1hhNNwqCPkuwwGmIkQcTAeC5lvO0Ep8BNMZcyfwqph/Lq9O64ceJHdqXbboW0W63MOhBW9Wjo8Q
  59860. JqVJwy7XQYci4E+GymC16qFjwAGXEHm9ADwSbSsVsaxLse4YuU6W3Nx2/zu+z18DwPw76L5GG//a
  59861. QMJS9/7jOvdqdzXQ2o3rXhhqMcceujwbKNZrVMaqW9eiLBsZzKIC9ptZvTdrhrVtgrrY6slWvKk2
  59862. WP0+GfPtDCapkzj4T8FdIgbQl+rhrcZV4IErKIM6+vR7IVEAvlI4zs1meaj0gVbi0IMJR1FbUGrP
  59863. 20gaXT73y/Zl92zxlfgCOzJWgjl6W70viRu/obTo/3+NjN8D8WBOWBFM66M/ECuDmgFz2ZRthAAn
  59864. ZqzwcEAJQpKtT5MNYQlRJNiS1QuUYbKHsu3/mjX/hVTK7URDrBs8FmtISgocQIgfksILAAX/8sgC
  59865. SqSqqcyZlpwvWOB94b67B9xfBHJcMTTD7F8t4D1kkCLm0ey4Lt1ZrtmhN79UNdxzMk+MBB4zsslG
  59866. 8dhcyFVQyWi9qLo2CQIDAQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR281Xh+qQ2
  59867. +/CfXGJx7Tz0RzgQKzAfBgNVHSMEGDAWgBR281Xh+qQ2+/CfXGJx7Tz0RzgQKzAOBgNVHQ8BAf8E
  59868. BAMCAYYwDQYJKoZIhvcNAQEFBQADggIBAGbBxiPz2eAubl/oz66wsCVNK/g7WJtAJDday6sWSf+z
  59869. dXkzoS9tcBc0kf5nfo/sm+VegqlVHy/c1FEHEv6sFj4sNcZj/NwQ6w2jqtB8zNHQL1EuxBRa3ugZ
  59870. 4T7GzKQp5y6EqgYweHZUcyiYWTjgAA1i00J9IZ+uPTqM1fp3DRgrFg5fNuH8KrUwJM/gYwx7WBr+
  59871. mbpCErGR9Hxo4sjoryzqyX6uuyo9DRXcNJW2GHSoag/HtPQTxORb7QrSpJdMKu0vbBKJPfEncKpq
  59872. A1Ihn0CoZ1Dy81of398j9tx4TuaYT1U6U+Pv8vSfx3zYWK8pIpe44L2RLrB27FcRz+8pRPPphXpg
  59873. Y+RdM4kX2TGq2tbzGDVyz4crL2MjhF2EjD9XoIj8mZEoJmmZ1I+XRL6O1UixpCgp8RW04eWe3fiP
  59874. pm8m1wk8OhwRDqZsN/etRIcsKMfYdIKz0G9KV7s1KSegi+ghp4dkNl3M2Basx7InQJJVOCiNUW7d
  59875. FGdTbHFcJoRNdVq2fmBWqU2t+5sel/MN2dKXVHfaPRK34B7vCAas+YWH6aLcr34YEoP9VhdBLtUp
  59876. gn2Z9DH2canPLAEnpQW5qrJITirvn5NSUZU8UnOOVkwXQMAJKOSLakhT2+zNVVXxxvjpoixMptEm
  59877. X36vWkzaH6byHCx+rgIW0lbQL1dTR+iS
  59878. -----END CERTIFICATE-----
  59879. Comodo AAA Services root
  59880. ========================
  59881. -----BEGIN CERTIFICATE-----
  59882. MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEbMBkGA1UECAwS
  59883. R3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRowGAYDVQQKDBFDb21vZG8gQ0Eg
  59884. TGltaXRlZDEhMB8GA1UEAwwYQUFBIENlcnRpZmljYXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAwMDAw
  59885. MFoXDTI4MTIzMTIzNTk1OVowezELMAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFuY2hl
  59886. c3RlcjEQMA4GA1UEBwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxITAfBgNV
  59887. BAMMGEFBQSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
  59888. ggEBAL5AnfRu4ep2hxxNRUSOvkbIgwadwSr+GB+O5AL686tdUIoWMQuaBtDFcCLNSS1UY8y2bmhG
  59889. C1Pqy0wkwLxyTurxFa70VJoSCsN6sjNg4tqJVfMiWPPe3M/vg4aijJRPn2jymJBGhCfHdr/jzDUs
  59890. i14HZGWCwEiwqJH5YZ92IFCokcdmtet4YgNW8IoaE+oxox6gmf049vYnMlhvB/VruPsUK6+3qszW
  59891. Y19zjNoFmag4qMsXeDZRrOme9Hg6jc8P2ULimAyrL58OAd7vn5lJ8S3frHRNG5i1R8XlKdH5kBjH
  59892. Ypy+g8cmez6KJcfA3Z3mNWgQIJ2P2N7Sw4ScDV7oL8kCAwEAAaOBwDCBvTAdBgNVHQ4EFgQUoBEK
  59893. Iz6W8Qfs4q8p74Klf9AwpLQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wewYDVR0f
  59894. BHQwcjA4oDagNIYyaHR0cDovL2NybC5jb21vZG9jYS5jb20vQUFBQ2VydGlmaWNhdGVTZXJ2aWNl
  59895. cy5jcmwwNqA0oDKGMGh0dHA6Ly9jcmwuY29tb2RvLm5ldC9BQUFDZXJ0aWZpY2F0ZVNlcnZpY2Vz
  59896. LmNybDANBgkqhkiG9w0BAQUFAAOCAQEACFb8AvCb6P+k+tZ7xkSAzk/ExfYAWMymtrwUSWgEdujm
  59897. 7l3sAg9g1o1QGE8mTgHj5rCl7r+8dFRBv/38ErjHT1r0iWAFf2C3BUrz9vHCv8S5dIa2LX1rzNLz
  59898. Rt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2G9w84FoVxp7Z
  59899. 8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsil2D4kF501KKaU73yqWjgom7C
  59900. 12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg==
  59901. -----END CERTIFICATE-----
  59902. QuoVadis Root CA
  59903. ================
  59904. -----BEGIN CERTIFICATE-----
  59905. MIIF0DCCBLigAwIBAgIEOrZQizANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJCTTEZMBcGA1UE
  59906. ChMQUXVvVmFkaXMgTGltaXRlZDElMCMGA1UECxMcUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0
  59907. eTEuMCwGA1UEAxMlUXVvVmFkaXMgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wMTAz
  59908. MTkxODMzMzNaFw0yMTAzMTcxODMzMzNaMH8xCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRp
  59909. cyBMaW1pdGVkMSUwIwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MS4wLAYDVQQD
  59910. EyVRdW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEF
  59911. AAOCAQ8AMIIBCgKCAQEAv2G1lVO6V/z68mcLOhrfEYBklbTRvM16z/Ypli4kVEAkOPcahdxYTMuk
  59912. J0KX0J+DisPkBgNbAKVRHnAEdOLB1Dqr1607BxgFjv2DrOpm2RgbaIr1VxqYuvXtdj182d6UajtL
  59913. F8HVj71lODqV0D1VNk7feVcxKh7YWWVJWCCYfqtffp/p1k3sg3Spx2zY7ilKhSoGFPlU5tPaZQeL
  59914. YzcS19Dsw3sgQUSj7cugF+FxZc4dZjH3dgEZyH0DWLaVSR2mEiboxgx24ONmy+pdpibu5cxfvWen
  59915. AScOospUxbF6lR1xHkopigPcakXBpBlebzbNw6Kwt/5cOOJSvPhEQ+aQuwIDAQABo4ICUjCCAk4w
  59916. PQYIKwYBBQUHAQEEMTAvMC0GCCsGAQUFBzABhiFodHRwczovL29jc3AucXVvdmFkaXNvZmZzaG9y
  59917. ZS5jb20wDwYDVR0TAQH/BAUwAwEB/zCCARoGA1UdIASCAREwggENMIIBCQYJKwYBBAG+WAABMIH7
  59918. MIHUBggrBgEFBQcCAjCBxxqBxFJlbGlhbmNlIG9uIHRoZSBRdW9WYWRpcyBSb290IENlcnRpZmlj
  59919. YXRlIGJ5IGFueSBwYXJ0eSBhc3N1bWVzIGFjY2VwdGFuY2Ugb2YgdGhlIHRoZW4gYXBwbGljYWJs
  59920. ZSBzdGFuZGFyZCB0ZXJtcyBhbmQgY29uZGl0aW9ucyBvZiB1c2UsIGNlcnRpZmljYXRpb24gcHJh
  59921. Y3RpY2VzLCBhbmQgdGhlIFF1b1ZhZGlzIENlcnRpZmljYXRlIFBvbGljeS4wIgYIKwYBBQUHAgEW
  59922. Fmh0dHA6Ly93d3cucXVvdmFkaXMuYm0wHQYDVR0OBBYEFItLbe3TKbkGGew5Oanwl4Rqy+/fMIGu
  59923. BgNVHSMEgaYwgaOAFItLbe3TKbkGGew5Oanwl4Rqy+/foYGEpIGBMH8xCzAJBgNVBAYTAkJNMRkw
  59924. FwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMSUwIwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0
  59925. aG9yaXR5MS4wLAYDVQQDEyVRdW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggQ6
  59926. tlCLMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOCAQEAitQUtf70mpKnGdSkfnIYj9lo
  59927. fFIk3WdvOXrEql494liwTXCYhGHoG+NpGA7O+0dQoE7/8CQfvbLO9Sf87C9TqnN7Az10buYWnuul
  59928. LsS/VidQK2K6vkscPFVcQR0kvoIgR13VRH56FmjffU1RcHhXHTMe/QKZnAzNCgVPx7uOpHX6Sm2x
  59929. gI4JVrmcGmD+XcHXetwReNDWXcG31a0ymQM6isxUJTkxgXsTIlG6Rmyhu576BGxJJnSP0nPrzDCi
  59930. 5upZIof4l/UO/erMkqQWxFIY6iHOsfHmhIHluqmGKPJDWl0Snawe2ajlCmqnf6CHKc/yiU3U7MXi
  59931. 5nrQNiOKSnQ2+Q==
  59932. -----END CERTIFICATE-----
  59933. QuoVadis Root CA 2
  59934. ==================
  59935. -----BEGIN CERTIFICATE-----
  59936. MIIFtzCCA5+gAwIBAgICBQkwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT
  59937. EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMjAeFw0wNjExMjQx
  59938. ODI3MDBaFw0zMTExMjQxODIzMzNaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM
  59939. aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  59940. DwAwggIKAoICAQCaGMpLlA0ALa8DKYrwD4HIrkwZhR0In6spRIXzL4GtMh6QRr+jhiYaHv5+HBg6
  59941. XJxgFyo6dIMzMH1hVBHL7avg5tKifvVrbxi3Cgst/ek+7wrGsxDp3MJGF/hd/aTa/55JWpzmM+Yk
  59942. lvc/ulsrHHo1wtZn/qtmUIttKGAr79dgw8eTvI02kfN/+NsRE8Scd3bBrrcCaoF6qUWD4gXmuVbB
  59943. lDePSHFjIuwXZQeVikvfj8ZaCuWw419eaxGrDPmF60Tp+ARz8un+XJiM9XOva7R+zdRcAitMOeGy
  59944. lZUtQofX1bOQQ7dsE/He3fbE+Ik/0XX1ksOR1YqI0JDs3G3eicJlcZaLDQP9nL9bFqyS2+r+eXyt
  59945. 66/3FsvbzSUr5R/7mp/iUcw6UwxI5g69ybR2BlLmEROFcmMDBOAENisgGQLodKcftslWZvB1Jdxn
  59946. wQ5hYIizPtGo/KPaHbDRsSNU30R2be1B2MGyIrZTHN81Hdyhdyox5C315eXbyOD/5YDXC2Og/zOh
  59947. D7osFRXql7PSorW+8oyWHhqPHWykYTe5hnMz15eWniN9gqRMgeKh0bpnX5UHoycR7hYQe7xFSkyy
  59948. BNKr79X9DFHOUGoIMfmR2gyPZFwDwzqLID9ujWc9Otb+fVuIyV77zGHcizN300QyNQliBJIWENie
  59949. J0f7OyHj+OsdWwIDAQABo4GwMIGtMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1Ud
  59950. DgQWBBQahGK8SEwzJQTU7tD2A8QZRtGUazBuBgNVHSMEZzBlgBQahGK8SEwzJQTU7tD2A8QZRtGU
  59951. a6FJpEcwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMT
  59952. ElF1b1ZhZGlzIFJvb3QgQ0EgMoICBQkwDQYJKoZIhvcNAQEFBQADggIBAD4KFk2fBluornFdLwUv
  59953. Z+YTRYPENvbzwCYMDbVHZF34tHLJRqUDGCdViXh9duqWNIAXINzng/iN/Ae42l9NLmeyhP3ZRPx3
  59954. UIHmfLTJDQtyU/h2BwdBR5YM++CCJpNVjP4iH2BlfF/nJrP3MpCYUNQ3cVX2kiF495V5+vgtJodm
  59955. VjB3pjd4M1IQWK4/YY7yarHvGH5KWWPKjaJW1acvvFYfzznB4vsKqBUsfU16Y8Zsl0Q80m/DShcK
  59956. +JDSV6IZUaUtl0HaB0+pUNqQjZRG4T7wlP0QADj1O+hA4bRuVhogzG9Yje0uRY/W6ZM/57Es3zrW
  59957. IozchLsib9D45MY56QSIPMO661V6bYCZJPVsAfv4l7CUW+v90m/xd2gNNWQjrLhVoQPRTUIZ3Ph1
  59958. WVaj+ahJefivDrkRoHy3au000LYmYjgahwz46P0u05B/B5EqHdZ+XIWDmbA4CD/pXvk1B+TJYm5X
  59959. f6dQlfe6yJvmjqIBxdZmv3lh8zwc4bmCXF2gw+nYSL0ZohEUGW6yhhtoPkg3Goi3XZZenMfvJ2II
  59960. 4pEZXNLxId26F0KCl3GBUzGpn/Z9Yr9y4aOTHcyKJloJONDO1w2AFrR4pTqHTI2KpdVGl/IsELm8
  59961. VCLAAVBpQ570su9t+Oza8eOx79+Rj1QqCyXBJhnEUhAFZdWCEOrCMc0u
  59962. -----END CERTIFICATE-----
  59963. QuoVadis Root CA 3
  59964. ==================
  59965. -----BEGIN CERTIFICATE-----
  59966. MIIGnTCCBIWgAwIBAgICBcYwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT
  59967. EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMzAeFw0wNjExMjQx
  59968. OTExMjNaFw0zMTExMjQxOTA2NDRaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM
  59969. aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  59970. DwAwggIKAoICAQDMV0IWVJzmmNPTTe7+7cefQzlKZbPoFog02w1ZkXTPkrgEQK0CSzGrvI2RaNgg
  59971. DhoB4hp7Thdd4oq3P5kazethq8Jlph+3t723j/z9cI8LoGe+AaJZz3HmDyl2/7FWeUUrH556VOij
  59972. KTVopAFPD6QuN+8bv+OPEKhyq1hX51SGyMnzW9os2l2ObjyjPtr7guXd8lyyBTNvijbO0BNO/79K
  59973. DDRMpsMhvVAEVeuxu537RR5kFd5VAYwCdrXLoT9CabwvvWhDFlaJKjdhkf2mrk7AyxRllDdLkgbv
  59974. BNDInIjbC3uBr7E9KsRlOni27tyAsdLTmZw67mtaa7ONt9XOnMK+pUsvFrGeaDsGb659n/je7Mwp
  59975. p5ijJUMv7/FfJuGITfhebtfZFG4ZM2mnO4SJk8RTVROhUXhA+LjJou57ulJCg54U7QVSWllWp5f8
  59976. nT8KKdjcT5EOE7zelaTfi5m+rJsziO+1ga8bxiJTyPbH7pcUsMV8eFLI8M5ud2CEpukqdiDtWAEX
  59977. MJPpGovgc2PZapKUSU60rUqFxKMiMPwJ7Wgic6aIDFUhWMXhOp8q3crhkODZc6tsgLjoC2SToJyM
  59978. Gf+z0gzskSaHirOi4XCPLArlzW1oUevaPwV/izLmE1xr/l9A4iLItLRkT9a6fUg+qGkM17uGcclz
  59979. uD87nSVL2v9A6wIDAQABo4IBlTCCAZEwDwYDVR0TAQH/BAUwAwEB/zCB4QYDVR0gBIHZMIHWMIHT
  59980. BgkrBgEEAb5YAAMwgcUwgZMGCCsGAQUFBwICMIGGGoGDQW55IHVzZSBvZiB0aGlzIENlcnRpZmlj
  59981. YXRlIGNvbnN0aXR1dGVzIGFjY2VwdGFuY2Ugb2YgdGhlIFF1b1ZhZGlzIFJvb3QgQ0EgMyBDZXJ0
  59982. aWZpY2F0ZSBQb2xpY3kgLyBDZXJ0aWZpY2F0aW9uIFByYWN0aWNlIFN0YXRlbWVudC4wLQYIKwYB
  59983. BQUHAgEWIWh0dHA6Ly93d3cucXVvdmFkaXNnbG9iYWwuY29tL2NwczALBgNVHQ8EBAMCAQYwHQYD
  59984. VR0OBBYEFPLAE+CCQz777i9nMpY1XNu4ywLQMG4GA1UdIwRnMGWAFPLAE+CCQz777i9nMpY1XNu4
  59985. ywLQoUmkRzBFMQswCQYDVQQGEwJCTTEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRlZDEbMBkGA1UE
  59986. AxMSUXVvVmFkaXMgUm9vdCBDQSAzggIFxjANBgkqhkiG9w0BAQUFAAOCAgEAT62gLEz6wPJv92ZV
  59987. qyM07ucp2sNbtrCD2dDQ4iH782CnO11gUyeim/YIIirnv6By5ZwkajGxkHon24QRiSemd1o417+s
  59988. hvzuXYO8BsbRd2sPbSQvS3pspweWyuOEn62Iix2rFo1bZhfZFvSLgNLd+LJ2w/w4E6oM3kJpK27z
  59989. POuAJ9v1pkQNn1pVWQvVDVJIxa6f8i+AxeoyUDUSly7B4f/xI4hROJ/yZlZ25w9Rl6VSDE1JUZU2
  59990. Pb+iSwwQHYaZTKrzchGT5Or2m9qoXadNt54CrnMAyNojA+j56hl0YgCUyyIgvpSnWbWCar6ZeXqp
  59991. 8kokUvd0/bpO5qgdAm6xDYBEwa7TIzdfu4V8K5Iu6H6li92Z4b8nby1dqnuH/grdS/yO9SbkbnBC
  59992. bjPsMZ57k8HkyWkaPcBrTiJt7qtYTcbQQcEr6k8Sh17rRdhs9ZgC06DYVYoGmRmioHfRMJ6szHXu
  59993. g/WwYjnPbFfiTNKRCw51KBuav/0aQ/HKd/s7j2G4aSgWQgRecCocIdiP4b0jWy10QJLZYxkNc91p
  59994. vGJHvOB0K7Lrfb5BG7XARsWhIstfTsEokt4YutUqKLsRixeTmJlglFwjz1onl14LBQaTNx47aTbr
  59995. qZ5hHY8y2o4M1nQ+ewkk2gF3R8Q7zTSMmfXK4SVhM7JZG+Ju1zdXtg2pEto=
  59996. -----END CERTIFICATE-----
  59997. Security Communication Root CA
  59998. ==============================
  59999. -----BEGIN CERTIFICATE-----
  60000. MIIDWjCCAkKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMP
  60001. U0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEw
  60002. HhcNMDMwOTMwMDQyMDQ5WhcNMjMwOTMwMDQyMDQ5WjBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMP
  60003. U0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEw
  60004. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCzs/5/022x7xZ8V6UMbXaKL0u/ZPtM7orw
  60005. 8yl89f/uKuDp6bpbZCKamm8sOiZpUQWZJtzVHGpxxpp9Hp3dfGzGjGdnSj74cbAZJ6kJDKaVv0uM
  60006. DPpVmDvY6CKhS3E4eayXkmmziX7qIWgGmBSWh9JhNrxtJ1aeV+7AwFb9Ms+k2Y7CI9eNqPPYJayX
  60007. 5HA49LY6tJ07lyZDo6G8SVlyTCMwhwFY9k6+HGhWZq/NQV3Is00qVUarH9oe4kA92819uZKAnDfd
  60008. DJZkndwi92SL32HeFZRSFaB9UslLqCHJxrHty8OVYNEP8Ktw+N/LTX7s1vqr2b1/VPKl6Xn62dZ2
  60009. JChzAgMBAAGjPzA9MB0GA1UdDgQWBBSgc0mZaNyFW2XjmygvV5+9M7wHSDALBgNVHQ8EBAMCAQYw
  60010. DwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAaECpqLvkT115swW1F7NgE+vGkl3g
  60011. 0dNq/vu+m22/xwVtWSDEHPC32oRYAmP6SBbvT6UL90qY8j+eG61Ha2POCEfrUj94nK9NrvjVT8+a
  60012. mCoQQTlSxN3Zmw7vkwGusi7KaEIkQmywszo+zenaSMQVy+n5Bw+SUEmK3TGXX8npN6o7WWWXlDLJ
  60013. s58+OmJYxUmtYg5xpTKqL8aJdkNAExNnPaJUJRDL8Try2frbSVa7pv6nQTXD4IhhyYjH3zYQIphZ
  60014. 6rBK+1YWc26sTfcioU+tHXotRSflMMFe8toTyyVCUZVHA4xsIcx0Qu1T/zOLjw9XARYvz6buyXAi
  60015. FL39vmwLAw==
  60016. -----END CERTIFICATE-----
  60017. Sonera Class 2 Root CA
  60018. ======================
  60019. -----BEGIN CERTIFICATE-----
  60020. MIIDIDCCAgigAwIBAgIBHTANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQGEwJGSTEPMA0GA1UEChMG
  60021. U29uZXJhMRkwFwYDVQQDExBTb25lcmEgQ2xhc3MyIENBMB4XDTAxMDQwNjA3Mjk0MFoXDTIxMDQw
  60022. NjA3Mjk0MFowOTELMAkGA1UEBhMCRkkxDzANBgNVBAoTBlNvbmVyYTEZMBcGA1UEAxMQU29uZXJh
  60023. IENsYXNzMiBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJAXSjWdyvANlsdE+hY3
  60024. /Ei9vX+ALTU74W+oZ6m/AxxNjG8yR9VBaKQTBME1DJqEQ/xcHf+Js+gXGM2RX/uJ4+q/Tl18GybT
  60025. dXnt5oTjV+WtKcT0OijnpXuENmmz/V52vaMtmdOQTiMofRhj8VQ7Jp12W5dCsv+u8E7s3TmVToMG
  60026. f+dJQMjFAbJUWmYdPfz56TwKnoG4cPABi+QjVHzIrviQHgCWctRUz2EjvOr7nQKV0ba5cTppCD8P
  60027. tOFCx4j1P5iop7oc4HFx71hXgVB6XGt0Rg6DA5jDjqhu8nYybieDwnPz3BjotJPqdURrBGAgcVeH
  60028. nfO+oJAjPYok4doh28MCAwEAAaMzMDEwDwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQISqCqWITT
  60029. XjwwCwYDVR0PBAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQBazof5FnIVV0sd2ZvnoiYw7JNn39Yt
  60030. 0jSv9zilzqsWuasvfDXLrNAPtEwr/IDva4yRXzZ299uzGxnq9LIR/WFxRL8oszodv7ND6J+/3DEI
  60031. cbCdjdY0RzKQxmUk96BKfARzjzlvF4xytb1LyHr4e4PDKE6cCepnP7JnBBvDFNr450kkkdAdavph
  60032. Oe9r5yF1BgfYErQhIHBCcYHaPJo2vqZbDWpsmh+Re/n570K6Tk6ezAyNlNzZRZxe7EJQY670XcSx
  60033. EtzKO6gunRRaBXW37Ndj4ro1tgQIkejanZz2ZrUYrAqmVCY0M9IbwdR/GjqOC6oybtv8TyWf2TLH
  60034. llpwrN9M
  60035. -----END CERTIFICATE-----
  60036. XRamp Global CA Root
  60037. ====================
  60038. -----BEGIN CERTIFICATE-----
  60039. MIIEMDCCAxigAwIBAgIQUJRs7Bjq1ZxN1ZfvdY+grTANBgkqhkiG9w0BAQUFADCBgjELMAkGA1UE
  60040. BhMCVVMxHjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2Vj
  60041. dXJpdHkgU2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBB
  60042. dXRob3JpdHkwHhcNMDQxMTAxMTcxNDA0WhcNMzUwMTAxMDUzNzE5WjCBgjELMAkGA1UEBhMCVVMx
  60043. HjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2VjdXJpdHkg
  60044. U2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBBdXRob3Jp
  60045. dHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCYJB69FbS638eMpSe2OAtp87ZOqCwu
  60046. IR1cRN8hXX4jdP5efrRKt6atH67gBhbim1vZZ3RrXYCPKZ2GG9mcDZhtdhAoWORlsH9KmHmf4MMx
  60047. foArtYzAQDsRhtDLooY2YKTVMIJt2W7QDxIEM5dfT2Fa8OT5kavnHTu86M/0ay00fOJIYRyO82FE
  60048. zG+gSqmUsE3a56k0enI4qEHMPJQRfevIpoy3hsvKMzvZPTeL+3o+hiznc9cKV6xkmxnr9A8ECIqs
  60049. AxcZZPRaJSKNNCyy9mgdEm3Tih4U2sSPpuIjhdV6Db1q4Ons7Be7QhtnqiXtRYMh/MHJfNViPvry
  60050. xS3T/dRlAgMBAAGjgZ8wgZwwEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud
  60051. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFMZPoj0GY4QJnM5i5ASsjVy16bYbMDYGA1UdHwQvMC0wK6Ap
  60052. oCeGJWh0dHA6Ly9jcmwueHJhbXBzZWN1cml0eS5jb20vWEdDQS5jcmwwEAYJKwYBBAGCNxUBBAMC
  60053. AQEwDQYJKoZIhvcNAQEFBQADggEBAJEVOQMBG2f7Shz5CmBbodpNl2L5JFMn14JkTpAuw0kbK5rc
  60054. /Kh4ZzXxHfARvbdI4xD2Dd8/0sm2qlWkSLoC295ZLhVbO50WfUfXN+pfTXYSNrsf16GBBEYgoyxt
  60055. qZ4Bfj8pzgCT3/3JknOJiWSe5yvkHJEs0rnOfc5vMZnT5r7SHpDwCRR5XCOrTdLaIR9NmXmd4c8n
  60056. nxCbHIgNsIpkQTG4DmyQJKSbXHGPurt+HBvbaoAPIbzp26a3QPSyi6mx5O+aGtA9aZnuqCij4Tyz
  60057. 8LIRnM98QObd50N9otg6tamN8jSZxNQQ4Qb9CYQQO+7ETPTsJ3xCwnR8gooJybQDJbw=
  60058. -----END CERTIFICATE-----
  60059. Go Daddy Class 2 CA
  60060. ===================
  60061. -----BEGIN CERTIFICATE-----
  60062. MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMY
  60063. VGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRp
  60064. ZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkG
  60065. A1UEBhMCVVMxITAfBgNVBAoTGFRoZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28g
  60066. RGFkZHkgQ2xhc3MgMiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQAD
  60067. ggENADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCAPVYYYwhv
  60068. 2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6wwdhFJ2+qN1j3hybX2C32
  60069. qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXiEqITLdiOr18SPaAIBQi2XKVlOARFmR6j
  60070. YGB0xUGlcmIbYsUfb18aQr4CUWWoriMYavx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmY
  60071. vLEHZ6IVDd2gWMZEewo+YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0O
  60072. BBYEFNLEsNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h/t2o
  60073. atTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMu
  60074. MTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwG
  60075. A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wim
  60076. PQoZ+YeAEW5p5JYXMP80kWNyOO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKt
  60077. I3lpjbi2Tc7PTMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ
  60078. HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mERdEr/VxqHD3VI
  60079. Ls9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5CufReYNnyicsbkqWletNw+vHX/b
  60080. vZ8=
  60081. -----END CERTIFICATE-----
  60082. Starfield Class 2 CA
  60083. ====================
  60084. -----BEGIN CERTIFICATE-----
  60085. MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzElMCMGA1UEChMc
  60086. U3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZpZWxkIENsYXNzIDIg
  60087. Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQwNjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBo
  60088. MQswCQYDVQQGEwJVUzElMCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAG
  60089. A1UECxMpU3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqG
  60090. SIb3DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf8MOh2tTY
  60091. bitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN+lq2cwQlZut3f+dZxkqZ
  60092. JRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVm
  60093. epsZGD3/cVE8MC5fvj13c7JdBmzDI1aaK4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSN
  60094. F4Azbl5KXZnJHoe0nRrA1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HF
  60095. MIHCMB0GA1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fRzt0f
  60096. hvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNo
  60097. bm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBDbGFzcyAyIENlcnRpZmljYXRpb24g
  60098. QXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGs
  60099. afPzWdqbAYcaT1epoXkJKtv3L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLM
  60100. PUxA2IGvd56Deruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl
  60101. xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynpVSJYACPq4xJD
  60102. KVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEYWQPJIrSPnNVeKtelttQKbfi3
  60103. QBFGmh95DmK/D5fs4C8fF5Q=
  60104. -----END CERTIFICATE-----
  60105. Taiwan GRCA
  60106. ===========
  60107. -----BEGIN CERTIFICATE-----
  60108. MIIFcjCCA1qgAwIBAgIQH51ZWtcvwgZEpYAIaeNe9jANBgkqhkiG9w0BAQUFADA/MQswCQYDVQQG
  60109. EwJUVzEwMC4GA1UECgwnR292ZXJubWVudCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4X
  60110. DTAyMTIwNTEzMjMzM1oXDTMyMTIwNTEzMjMzM1owPzELMAkGA1UEBhMCVFcxMDAuBgNVBAoMJ0dv
  60111. dmVybm1lbnQgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCAiIwDQYJKoZIhvcNAQEBBQAD
  60112. ggIPADCCAgoCggIBAJoluOzMonWoe/fOW1mKydGGEghU7Jzy50b2iPN86aXfTEc2pBsBHH8eV4qN
  60113. w8XRIePaJD9IK/ufLqGU5ywck9G/GwGHU5nOp/UKIXZ3/6m3xnOUT0b3EEk3+qhZSV1qgQdW8or5
  60114. BtD3cCJNtLdBuTK4sfCxw5w/cP1T3YGq2GN49thTbqGsaoQkclSGxtKyyhwOeYHWtXBiCAEuTk8O
  60115. 1RGvqa/lmr/czIdtJuTJV6L7lvnM4T9TjGxMfptTCAtsF/tnyMKtsc2AtJfcdgEWFelq16TheEfO
  60116. htX7MfP6Mb40qij7cEwdScevLJ1tZqa2jWR+tSBqnTuBto9AAGdLiYa4zGX+FVPpBMHWXx1E1wov
  60117. J5pGfaENda1UhhXcSTvxls4Pm6Dso3pdvtUqdULle96ltqqvKKyskKw4t9VoNSZ63Pc78/1Fm9G7
  60118. Q3hub/FCVGqY8A2tl+lSXunVanLeavcbYBT0peS2cWeqH+riTcFCQP5nRhc4L0c/cZyu5SHKYS1t
  60119. B6iEfC3uUSXxY5Ce/eFXiGvviiNtsea9P63RPZYLhY3Naye7twWb7LuRqQoHEgKXTiCQ8P8NHuJB
  60120. O9NAOueNXdpm5AKwB1KYXA6OM5zCppX7VRluTI6uSw+9wThNXo+EHWbNxWCWtFJaBYmOlXqYwZE8
  60121. lSOyDvR5tMl8wUohAgMBAAGjajBoMB0GA1UdDgQWBBTMzO/MKWCkO7GStjz6MmKPrCUVOzAMBgNV
  60122. HRMEBTADAQH/MDkGBGcqBwAEMTAvMC0CAQAwCQYFKw4DAhoFADAHBgVnKgMAAAQUA5vwIhP/lSg2
  60123. 09yewDL7MTqKUWUwDQYJKoZIhvcNAQEFBQADggIBAECASvomyc5eMN1PhnR2WPWus4MzeKR6dBcZ
  60124. TulStbngCnRiqmjKeKBMmo4sIy7VahIkv9Ro04rQ2JyftB8M3jh+Vzj8jeJPXgyfqzvS/3WXy6Tj
  60125. Zwj/5cAWtUgBfen5Cv8b5Wppv3ghqMKnI6mGq3ZW6A4M9hPdKmaKZEk9GhiHkASfQlK3T8v+R0F2
  60126. Ne//AHY2RTKbxkaFXeIksB7jSJaYV0eUVXoPQbFEJPPB/hprv4j9wabak2BegUqZIJxIZhm1AHlU
  60127. D7gsL0u8qV1bYH+Mh6XgUmMqvtg7hUAV/h62ZT/FS9p+tXo1KaMuephgIqP0fSdOLeq0dDzpD6Qz
  60128. DxARvBMB1uUO07+1EqLhRSPAzAhuYbeJq4PjJB7mXQfnHyA+z2fI56wwbSdLaG5LKlwCCDTb+Hbk
  60129. Z6MmnD+iMsJKxYEYMRBWqoTvLQr/uB930r+lWKBi5NdLkXWNiYCYfm3LU05er/ayl4WXudpVBrkk
  60130. 7tfGOB5jGxI7leFYrPLfhNVfmS8NVVvmONsuP3LpSIXLuykTjx44VbnzssQwmSNOXfJIoRIM3BKQ
  60131. CZBUkQM8R+XVyWXgt0t97EfTsws+rZ7QdAAO671RrcDeLMDDav7v3Aun+kbfYNucpllQdSNpc5Oy
  60132. +fwC00fmcc4QAu4njIT/rEUNE1yDMuAlpYYsfPQS
  60133. -----END CERTIFICATE-----
  60134. DigiCert Assured ID Root CA
  60135. ===========================
  60136. -----BEGIN CERTIFICATE-----
  60137. MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBlMQswCQYDVQQG
  60138. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw
  60139. IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0EwHhcNMDYxMTEwMDAwMDAwWhcNMzEx
  60140. MTEwMDAwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL
  60141. ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0Ew
  60142. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtDhXO5EOAXLGH87dg+XESpa7cJpSIqvTO
  60143. 9SA5KFhgDPiA2qkVlTJhPLWxKISKityfCgyDF3qPkKyK53lTXDGEKvYPmDI2dsze3Tyoou9q+yHy
  60144. UmHfnyDXH+Kx2f4YZNISW1/5WBg1vEfNoTb5a3/UsDg+wRvDjDPZ2C8Y/igPs6eD1sNuRMBhNZYW
  60145. /lmci3Zt1/GiSw0r/wty2p5g0I6QNcZ4VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpy
  60146. oeb6pNnVFzF1roV9Iq4/AUaG9ih5yLHa5FcXxH4cDrC0kqZWs72yl+2qp/C3xag/lRbQ/6GW6whf
  60147. GHdPAgMBAAGjYzBhMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRF
  60148. 66Kv9JLLgjEtUYunpyGd823IDzAfBgNVHSMEGDAWgBRF66Kv9JLLgjEtUYunpyGd823IDzANBgkq
  60149. hkiG9w0BAQUFAAOCAQEAog683+Lt8ONyc3pklL/3cmbYMuRCdWKuh+vy1dneVrOfzM4UKLkNl2Bc
  60150. EkxY5NM9g0lFWJc1aRqoR+pWxnmrEthngYTffwk8lOa4JiwgvT2zKIn3X/8i4peEH+ll74fg38Fn
  60151. SbNd67IJKusm7Xi+fT8r87cmNW1fiQG2SVufAQWbqz0lwcy2f8Lxb4bG+mRo64EtlOtCt/qMHt1i
  60152. 8b5QZ7dsvfPxH2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe
  60153. +o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g==
  60154. -----END CERTIFICATE-----
  60155. DigiCert Global Root CA
  60156. =======================
  60157. -----BEGIN CERTIFICATE-----
  60158. MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQG
  60159. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw
  60160. HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBDQTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAw
  60161. MDAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3
  60162. dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkq
  60163. hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsBCSDMAZOn
  60164. TjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97nh6Vfe63SKMI2tavegw5
  60165. BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt43C/dxC//AH2hdmoRBBYMql1GNXRor5H
  60166. 4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7PT19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y
  60167. 7vrTC0LUq7dBMtoM1O/4gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQAB
  60168. o2MwYTAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbRTLtm
  60169. 8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUwDQYJKoZIhvcNAQEF
  60170. BQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/EsrhMAtudXH/vTBH1jLuG2cenTnmCmr
  60171. EbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIt
  60172. tep3Sp+dWOIrWcBAI+0tKIJFPnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886
  60173. UAb3LujEV0lsYSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk
  60174. CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=
  60175. -----END CERTIFICATE-----
  60176. DigiCert High Assurance EV Root CA
  60177. ==================================
  60178. -----BEGIN CERTIFICATE-----
  60179. MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBsMQswCQYDVQQG
  60180. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSsw
  60181. KQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5jZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAw
  60182. MFoXDTMxMTExMDAwMDAwMFowbDELMAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZ
  60183. MBcGA1UECxMQd3d3LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFu
  60184. Y2UgRVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm+9S75S0t
  60185. Mqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTWPNt0OKRKzE0lgvdKpVMS
  60186. OO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEMxChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3
  60187. MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFBIk5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQ
  60188. NAQTXKFx01p8VdteZOE3hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUe
  60189. h10aUAsgEsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMB
  60190. Af8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaAFLE+w2kD+L9HAdSY
  60191. JhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3NecnzyIZgYIVyHbIUf4KmeqvxgydkAQ
  60192. V8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6zeM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFp
  60193. myPInngiK3BD41VHMWEZ71jFhS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkK
  60194. mNEVX58Svnw2Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe
  60195. vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep+OkuE6N36B9K
  60196. -----END CERTIFICATE-----
  60197. DST Root CA X3
  60198. ==============
  60199. -----BEGIN CERTIFICATE-----
  60200. MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/MSQwIgYDVQQK
  60201. ExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMTDkRTVCBSb290IENBIFgzMB4X
  60202. DTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVowPzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1
  60203. cmUgVHJ1c3QgQ28uMRcwFQYDVQQDEw5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQAD
  60204. ggEPADCCAQoCggEBAN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmT
  60205. rE4Orz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEqOLl5CjH9
  60206. UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9bxiqKqy69cK3FCxolkHRy
  60207. xXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40d
  60208. utolucbY38EVAjqr2m7xPi71XAicPNaDaeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0T
  60209. AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQ
  60210. MA0GCSqGSIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69ikug
  60211. dB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXrAvHRAosZy5Q6XkjE
  60212. GB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZzR8srzJmwN0jP41ZL9c8PDHIyh8bw
  60213. RLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubS
  60214. fZGL+T0yjWW06XyxV3bqxbYoOb8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ
  60215. -----END CERTIFICATE-----
  60216. SwissSign Gold CA - G2
  60217. ======================
  60218. -----BEGIN CERTIFICATE-----
  60219. MIIFujCCA6KgAwIBAgIJALtAHEP1Xk+wMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNVBAYTAkNIMRUw
  60220. EwYDVQQKEwxTd2lzc1NpZ24gQUcxHzAdBgNVBAMTFlN3aXNzU2lnbiBHb2xkIENBIC0gRzIwHhcN
  60221. MDYxMDI1MDgzMDM1WhcNMzYxMDI1MDgzMDM1WjBFMQswCQYDVQQGEwJDSDEVMBMGA1UEChMMU3dp
  60222. c3NTaWduIEFHMR8wHQYDVQQDExZTd2lzc1NpZ24gR29sZCBDQSAtIEcyMIICIjANBgkqhkiG9w0B
  60223. AQEFAAOCAg8AMIICCgKCAgEAr+TufoskDhJuqVAtFkQ7kpJcyrhdhJJCEyq8ZVeCQD5XJM1QiyUq
  60224. t2/876LQwB8CJEoTlo8jE+YoWACjR8cGp4QjK7u9lit/VcyLwVcfDmJlD909Vopz2q5+bbqBHH5C
  60225. jCA12UNNhPqE21Is8w4ndwtrvxEvcnifLtg+5hg3Wipy+dpikJKVyh+c6bM8K8vzARO/Ws/BtQpg
  60226. vd21mWRTuKCWs2/iJneRjOBiEAKfNA+k1ZIzUd6+jbqEemA8atufK+ze3gE/bk3lUIbLtK/tREDF
  60227. ylqM2tIrfKjuvqblCqoOpd8FUrdVxyJdMmqXl2MT28nbeTZ7hTpKxVKJ+STnnXepgv9VHKVxaSvR
  60228. AiTysybUa9oEVeXBCsdtMDeQKuSeFDNeFhdVxVu1yzSJkvGdJo+hB9TGsnhQ2wwMC3wLjEHXuend
  60229. jIj3o02yMszYF9rNt85mndT9Xv+9lz4pded+p2JYryU0pUHHPbwNUMoDAw8IWh+Vc3hiv69yFGkO
  60230. peUDDniOJihC8AcLYiAQZzlG+qkDzAQ4embvIIO1jEpWjpEA/I5cgt6IoMPiaG59je883WX0XaxR
  60231. 7ySArqpWl2/5rX3aYT+YdzylkbYcjCbaZaIJbcHiVOO5ykxMgI93e2CaHt+28kgeDrpOVG2Y4OGi
  60232. GqJ3UM/EY5LsRxmd6+ZrzsECAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUw
  60233. AwEB/zAdBgNVHQ4EFgQUWyV7lqRlUX64OfPAeGZe6Drn8O4wHwYDVR0jBBgwFoAUWyV7lqRlUX64
  60234. OfPAeGZe6Drn8O4wRgYDVR0gBD8wPTA7BglghXQBWQECAQEwLjAsBggrBgEFBQcCARYgaHR0cDov
  60235. L3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBACe645R88a7A3hfm
  60236. 5djV9VSwg/S7zV4Fe0+fdWavPOhWfvxyeDgD2StiGwC5+OlgzczOUYrHUDFu4Up+GC9pWbY9ZIEr
  60237. 44OE5iKHjn3g7gKZYbge9LgriBIWhMIxkziWMaa5O1M/wySTVltpkuzFwbs4AOPsF6m43Md8AYOf
  60238. Mke6UiI0HTJ6CVanfCU2qT1L2sCCbwq7EsiHSycR+R4tx5M/nttfJmtS2S6K8RTGRI0Vqbe/vd6m
  60239. Gu6uLftIdxf+u+yvGPUqUfA5hJeVbG4bwyvEdGB5JbAKJ9/fXtI5z0V9QkvfsywexcZdylU6oJxp
  60240. mo/a77KwPJ+HbBIrZXAVUjEaJM9vMSNQH4xPjyPDdEFjHFWoFN0+4FFQz/EbMFYOkrCChdiDyyJk
  60241. vC24JdVUorgG6q2SpCSgwYa1ShNqR88uC1aVVMvOmttqtKay20EIhid392qgQmwLOM7XdVAyksLf
  60242. KzAiSNDVQTglXaTpXZ/GlHXQRf0wl0OPkKsKx4ZzYEppLd6leNcG2mqeSz53OiATIgHQv2ieY2Br
  60243. NU0LbbqhPcCT4H8js1WtciVORvnSFu+wZMEBnunKoGqYDs/YYPIvSbjkQuE4NRb0yG5P94FW6Lqj
  60244. viOvrv1vA+ACOzB2+httQc8Bsem4yWb02ybzOqR08kkkW8mw0FfB+j564ZfJ
  60245. -----END CERTIFICATE-----
  60246. SwissSign Silver CA - G2
  60247. ========================
  60248. -----BEGIN CERTIFICATE-----
  60249. MIIFvTCCA6WgAwIBAgIITxvUL1S7L0swDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCQ0gxFTAT
  60250. BgNVBAoTDFN3aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMB4X
  60251. DTA2MTAyNTA4MzI0NloXDTM2MTAyNTA4MzI0NlowRzELMAkGA1UEBhMCQ0gxFTATBgNVBAoTDFN3
  60252. aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMIICIjANBgkqhkiG
  60253. 9w0BAQEFAAOCAg8AMIICCgKCAgEAxPGHf9N4Mfc4yfjDmUO8x/e8N+dOcbpLj6VzHVxumK4DV644
  60254. N0MvFz0fyM5oEMF4rhkDKxD6LHmD9ui5aLlV8gREpzn5/ASLHvGiTSf5YXu6t+WiE7brYT7QbNHm
  60255. +/pe7R20nqA1W6GSy/BJkv6FCgU+5tkL4k+73JU3/JHpMjUi0R86TieFnbAVlDLaYQ1HTWBCrpJH
  60256. 6INaUFjpiou5XaHc3ZlKHzZnu0jkg7Y360g6rw9njxcH6ATK72oxh9TAtvmUcXtnZLi2kUpCe2Uu
  60257. MGoM9ZDulebyzYLs2aFK7PayS+VFheZteJMELpyCbTapxDFkH4aDCyr0NQp4yVXPQbBH6TCfmb5h
  60258. qAaEuSh6XzjZG6k4sIN/c8HDO0gqgg8hm7jMqDXDhBuDsz6+pJVpATqJAHgE2cn0mRmrVn5bi4Y5
  60259. FZGkECwJMoBgs5PAKrYYC51+jUnyEEp/+dVGLxmSo5mnJqy7jDzmDrxHB9xzUfFwZC8I+bRHHTBs
  60260. ROopN4WSaGa8gzj+ezku01DwH/teYLappvonQfGbGHLy9YR0SslnxFSuSGTfjNFusB3hB48IHpmc
  60261. celM2KX3RxIfdNFRnobzwqIjQAtz20um53MGjMGg6cFZrEb65i/4z3GcRm25xBWNOHkDRUjvxF3X
  60262. CO6HOSKGsg0PWEP3calILv3q1h8CAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/
  60263. BAUwAwEB/zAdBgNVHQ4EFgQUF6DNweRBtjpbO8tFnb0cwpj6hlgwHwYDVR0jBBgwFoAUF6DNweRB
  60264. tjpbO8tFnb0cwpj6hlgwRgYDVR0gBD8wPTA7BglghXQBWQEDAQEwLjAsBggrBgEFBQcCARYgaHR0
  60265. cDovL3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBAHPGgeAn0i0P
  60266. 4JUw4ppBf1AsX19iYamGamkYDHRJ1l2E6kFSGG9YrVBWIGrGvShpWJHckRE1qTodvBqlYJ7YH39F
  60267. kWnZfrt4csEGDyrOj4VwYaygzQu4OSlWhDJOhrs9xCrZ1x9y7v5RoSJBsXECYxqCsGKrXlcSH9/L
  60268. 3XWgwF15kIwb4FDm3jH+mHtwX6WQ2K34ArZv02DdQEsixT2tOnqfGhpHkXkzuoLcMmkDlm4fS/Bx
  60269. /uNncqCxv1yL5PqZIseEuRuNI5c/7SXgz2W79WEE790eslpBIlqhn10s6FvJbakMDHiqYMZWjwFa
  60270. DGi8aRl5xB9+lwW/xekkUV7U1UtT7dkjWjYDZaPBA61BMPNGG4WQr2W11bHkFlt4dR2Xem1ZqSqP
  60271. e97Dh4kQmUlzeMg9vVE1dCrV8X5pGyq7O70luJpaPXJhkGaH7gzWTdQRdAtq/gsD/KNVV4n+Ssuu
  60272. WxcFyPKNIzFTONItaj+CuY0IavdeQXRuwxF+B6wpYJE/OMpXEA29MC/HpeZBoNquBYeaoKRlbEwJ
  60273. DIm6uNO5wJOKMPqN5ZprFQFOZ6raYlY+hAhm0sQ2fac+EPyI4NSA5QC9qvNOBqN6avlicuMJT+ub
  60274. DgEj8Z+7fNzcbBGXJbLytGMU0gYqZ4yD9c7qB9iaah7s5Aq7KkzrCWA5zspi2C5u
  60275. -----END CERTIFICATE-----
  60276. GeoTrust Primary Certification Authority
  60277. ========================================
  60278. -----BEGIN CERTIFICATE-----
  60279. MIIDfDCCAmSgAwIBAgIQGKy1av1pthU6Y2yv2vrEoTANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQG
  60280. EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjExMC8GA1UEAxMoR2VvVHJ1c3QgUHJpbWFyeSBD
  60281. ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjExMjcwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMFgx
  60282. CzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTEwLwYDVQQDEyhHZW9UcnVzdCBQ
  60283. cmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
  60284. CgKCAQEAvrgVe//UfH1nrYNke8hCUy3f9oQIIGHWAVlqnEQRr+92/ZV+zmEwu3qDXwK9AWbK7hWN
  60285. b6EwnL2hhZ6UOvNWiAAxz9juapYC2e0DjPt1befquFUWBRaa9OBesYjAZIVcFU2Ix7e64HXprQU9
  60286. nceJSOC7KMgD4TCTZF5SwFlwIjVXiIrxlQqD17wxcwE07e9GceBrAqg1cmuXm2bgyxx5X9gaBGge
  60287. RwLmnWDiNpcB3841kt++Z8dtd1k7j53WkBWUvEI0EME5+bEnPn7WinXFsq+W06Lem+SYvn3h6YGt
  60288. tm/81w7a4DSwDRp35+MImO9Y+pyEtzavwt+s0vQQBnBxNQIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  60289. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQULNVQQZcVi/CPNmFbSvtr2ZnJM5IwDQYJKoZI
  60290. hvcNAQEFBQADggEBAFpwfyzdtzRP9YZRqSa+S7iq8XEN3GHHoOo0Hnp3DwQ16CePbJC/kRYkRj5K
  60291. Ts4rFtULUh38H2eiAkUxT87z+gOneZ1TatnaYzr4gNfTmeGl4b7UVXGYNTq+k+qurUKykG/g/CFN
  60292. NWMziUnWm07Kx+dOCQD32sfvmWKZd7aVIl6KoKv0uHiYyjgZmclynnjNS6yvGaBzEi38wkG6gZHa
  60293. Floxt/m0cYASSJlyc1pZU8FjUjPtp8nSOQJw+uCxQmYpqptR7TBUIhRf2asdweSU8Pj1K/fqynhG
  60294. 1riR/aYNKxoUAT6A8EKglQdebc3MS6RFjasS6LPeWuWgfOgPIh1a6Vk=
  60295. -----END CERTIFICATE-----
  60296. thawte Primary Root CA
  60297. ======================
  60298. -----BEGIN CERTIFICATE-----
  60299. MIIEIDCCAwigAwIBAgIQNE7VVyDV7exJ9C/ON9srbTANBgkqhkiG9w0BAQUFADCBqTELMAkGA1UE
  60300. BhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2
  60301. aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIwMDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhv
  60302. cml6ZWQgdXNlIG9ubHkxHzAdBgNVBAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwHhcNMDYxMTE3
  60303. MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCBqTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwg
  60304. SW5jLjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMv
  60305. KGMpIDIwMDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxHzAdBgNVBAMT
  60306. FnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCs
  60307. oPD7gFnUnMekz52hWXMJEEUMDSxuaPFsW0hoSVk3/AszGcJ3f8wQLZU0HObrTQmnHNK4yZc2AreJ
  60308. 1CRfBsDMRJSUjQJib+ta3RGNKJpchJAQeg29dGYvajig4tVUROsdB58Hum/u6f1OCyn1PoSgAfGc
  60309. q/gcfomk6KHYcWUNo1F77rzSImANuVud37r8UVsLr5iy6S7pBOhih94ryNdOwUxkHt3Ph1i6Sk/K
  60310. aAcdHJ1KxtUvkcx8cXIcxcBn6zL9yZJclNqFwJu/U30rCfSMnZEfl2pSy94JNqR32HuHUETVPm4p
  60311. afs5SSYeCaWAe0At6+gnhcn+Yf1+5nyXHdWdAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYD
  60312. VR0PAQH/BAQDAgEGMB0GA1UdDgQWBBR7W0XPr87Lev0xkhpqtvNG61dIUDANBgkqhkiG9w0BAQUF
  60313. AAOCAQEAeRHAS7ORtvzw6WfUDW5FvlXok9LOAz/t2iWwHVfLHjp2oEzsUHboZHIMpKnxuIvW1oeE
  60314. uzLlQRHAd9mzYJ3rG9XRbkREqaYB7FViHXe4XI5ISXycO1cRrK1zN44veFyQaEfZYGDm/Ac9IiAX
  60315. xPcW6cTYcvnIc3zfFi8VqT79aie2oetaupgf1eNNZAqdE8hhuvU5HIe6uL17In/2/qxAeeWsEG89
  60316. jxt5dovEN7MhGITlNgDrYyCZuen+MwS7QcjBAvlEYyCegc5C09Y/LHbTY5xZ3Y+m4Q6gLkH3LpVH
  60317. z7z9M/P2C2F+fpErgUfCJzDupxBdN49cOSvkBPB7jVaMaA==
  60318. -----END CERTIFICATE-----
  60319. VeriSign Class 3 Public Primary Certification Authority - G5
  60320. ============================================================
  60321. -----BEGIN CERTIFICATE-----
  60322. MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCByjELMAkGA1UE
  60323. BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO
  60324. ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk
  60325. IHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRp
  60326. ZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCB
  60327. yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2ln
  60328. biBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBh
  60329. dXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmlt
  60330. YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
  60331. ggEKAoIBAQCvJAgIKXo1nmAMqudLO07cfLw8RRy7K+D+KQL5VwijZIUVJ/XxrcgxiV0i6CqqpkKz
  60332. j/i5Vbext0uz/o9+B1fs70PbZmIVYc9gDaTY3vjgw2IIPVQT60nKWVSFJuUrjxuf6/WhkcIzSdhD
  60333. Y2pSS9KP6HBRTdGJaXvHcPaz3BJ023tdS1bTlr8Vd6Gw9KIl8q8ckmcY5fQGBO+QueQA5N06tRn/
  60334. Arr0PO7gi+s3i+z016zy9vA9r911kTMZHRxAy3QkGSGT2RT+rCpSx4/VBEnkjWNHiDxpg8v+R70r
  60335. fk/Fla4OndTRQ8Bnc+MUCH7lP59zuDMKz10/NIeWiu5T6CUVAgMBAAGjgbIwga8wDwYDVR0TAQH/
  60336. BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2Uv
  60337. Z2lmMCEwHzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVy
  60338. aXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFH/TZafC3ey78DAJ80M5+gKvMzEzMA0GCSqG
  60339. SIb3DQEBBQUAA4IBAQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzEp6B4Eq1iDkVwZMXnl2YtmAl+
  60340. X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKE
  60341. KQsTb47bDN0lAtukixlE0kF6BWlKWE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiC
  60342. Km0oHw0LxOXnGiYZ4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vE
  60343. ZV8NhnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq
  60344. -----END CERTIFICATE-----
  60345. SecureTrust CA
  60346. ==============
  60347. -----BEGIN CERTIFICATE-----
  60348. MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBIMQswCQYDVQQG
  60349. EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xFzAVBgNVBAMTDlNlY3VyZVRy
  60350. dXN0IENBMB4XDTA2MTEwNzE5MzExOFoXDTI5MTIzMTE5NDA1NVowSDELMAkGA1UEBhMCVVMxIDAe
  60351. BgNVBAoTF1NlY3VyZVRydXN0IENvcnBvcmF0aW9uMRcwFQYDVQQDEw5TZWN1cmVUcnVzdCBDQTCC
  60352. ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKukgeWVzfX2FI7CT8rU4niVWJxB4Q2ZQCQX
  60353. OZEzZum+4YOvYlyJ0fwkW2Gz4BERQRwdbvC4u/jep4G6pkjGnx29vo6pQT64lO0pGtSO0gMdA+9t
  60354. DWccV9cGrcrI9f4Or2YlSASWC12juhbDCE/RRvgUXPLIXgGZbf2IzIaowW8xQmxSPmjL8xk037uH
  60355. GFaAJsTQ3MBv396gwpEWoGQRS0S8Hvbn+mPeZqx2pHGj7DaUaHp3pLHnDi+BeuK1cobvomuL8A/b
  60356. 01k/unK8RCSc43Oz969XL0Imnal0ugBS8kvNU3xHCzaFDmapCJcWNFfBZveA4+1wVMeT4C4oFVmH
  60357. ursCAwEAAaOBnTCBmjATBgkrBgEEAYI3FAIEBh4EAEMAQTALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/
  60358. BAUwAwEB/zAdBgNVHQ4EFgQUQjK2FvoE/f5dS3rD/fdMQB1aQ68wNAYDVR0fBC0wKzApoCegJYYj
  60359. aHR0cDovL2NybC5zZWN1cmV0cnVzdC5jb20vU1RDQS5jcmwwEAYJKwYBBAGCNxUBBAMCAQAwDQYJ
  60360. KoZIhvcNAQEFBQADggEBADDtT0rhWDpSclu1pqNlGKa7UTt36Z3q059c4EVlew3KW+JwULKUBRSu
  60361. SceNQQcSc5R+DCMh/bwQf2AQWnL1mA6s7Ll/3XpvXdMc9P+IBWlCqQVxyLesJugutIxq/3HcuLHf
  60362. mbx8IVQr5Fiiu1cprp6poxkmD5kuCLDv/WnPmRoJjeOnnyvJNjR7JLN4TJUXpAYmHrZkUjZfYGfZ
  60363. nMUFdAvnZyPSCPyI6a6Lf+Ew9Dd+/cYy2i2eRDAwbO4H3tI0/NL/QPZL9GZGBlSm8jIKYyYwa5vR
  60364. 3ItHuuG51WLQoqD0ZwV4KWMabwTW+MZMo5qxN7SN5ShLHZ4swrhovO0C7jE=
  60365. -----END CERTIFICATE-----
  60366. Secure Global CA
  60367. ================
  60368. -----BEGIN CERTIFICATE-----
  60369. MIIDvDCCAqSgAwIBAgIQB1YipOjUiolN9BPI8PjqpTANBgkqhkiG9w0BAQUFADBKMQswCQYDVQQG
  60370. EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBH
  60371. bG9iYWwgQ0EwHhcNMDYxMTA3MTk0MjI4WhcNMjkxMjMxMTk1MjA2WjBKMQswCQYDVQQGEwJVUzEg
  60372. MB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBHbG9iYWwg
  60373. Q0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvNS7YrGxVaQZx5RNoJLNP2MwhR/jx
  60374. YDiJiQPpvepeRlMJ3Fz1Wuj3RSoC6zFh1ykzTM7HfAo3fg+6MpjhHZevj8fcyTiW89sa/FHtaMbQ
  60375. bqR8JNGuQsiWUGMu4P51/pinX0kuleM5M2SOHqRfkNJnPLLZ/kG5VacJjnIFHovdRIWCQtBJwB1g
  60376. 8NEXLJXr9qXBkqPFwqcIYA1gBBCWeZ4WNOaptvolRTnIHmX5k/Wq8VLcmZg9pYYaDDUz+kulBAYV
  60377. HDGA76oYa8J719rO+TMg1fW9ajMtgQT7sFzUnKPiXB3jqUJ1XnvUd+85VLrJChgbEplJL4hL/VBi
  60378. 0XPnj3pDAgMBAAGjgZ0wgZowEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud
  60379. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFK9EBMJBfkiD2045AuzshHrmzsmkMDQGA1UdHwQtMCswKaAn
  60380. oCWGI2h0dHA6Ly9jcmwuc2VjdXJldHJ1c3QuY29tL1NHQ0EuY3JsMBAGCSsGAQQBgjcVAQQDAgEA
  60381. MA0GCSqGSIb3DQEBBQUAA4IBAQBjGghAfaReUw132HquHw0LURYD7xh8yOOvaliTFGCRsoTciE6+
  60382. OYo68+aCiV0BN7OrJKQVDpI1WkpEXk5X+nXOH0jOZvQ8QCaSmGwb7iRGDBezUqXbpZGRzzfTb+cn
  60383. CDpOGR86p1hcF895P4vkp9MmI50mD1hp/Ed+stCNi5O/KU9DaXR2Z0vPB4zmAve14bRDtUstFJ/5
  60384. 3CYNv6ZHdAbYiNE6KTCEztI5gGIbqMdXSbxqVVFnFUq+NQfk1XWYN3kwFNspnWzFacxHVaIw98xc
  60385. f8LDmBxrThaA63p4ZUWiABqvDA1VZDRIuJK58bRQKfJPIx/abKwfROHdI3hRW8cW
  60386. -----END CERTIFICATE-----
  60387. COMODO Certification Authority
  60388. ==============================
  60389. -----BEGIN CERTIFICATE-----
  60390. MIIEHTCCAwWgAwIBAgIQToEtioJl4AsC7j41AkblPTANBgkqhkiG9w0BAQUFADCBgTELMAkGA1UE
  60391. BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG
  60392. A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxJzAlBgNVBAMTHkNPTU9ETyBDZXJ0aWZpY2F0aW9uIEF1
  60393. dGhvcml0eTAeFw0wNjEyMDEwMDAwMDBaFw0yOTEyMzEyMzU5NTlaMIGBMQswCQYDVQQGEwJHQjEb
  60394. MBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQKExFD
  60395. T01PRE8gQ0EgTGltaXRlZDEnMCUGA1UEAxMeQ09NT0RPIENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  60396. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0ECLi3LjkRv3UcEbVASY06m/weaKXTuH
  60397. +7uIzg3jLz8GlvCiKVCZrts7oVewdFFxze1CkU1B/qnI2GqGd0S7WWaXUF601CxwRM/aN5VCaTww
  60398. xHGzUvAhTaHYujl8HJ6jJJ3ygxaYqhZ8Q5sVW7euNJH+1GImGEaaP+vB+fGQV+useg2L23IwambV
  60399. 4EajcNxo2f8ESIl33rXp+2dtQem8Ob0y2WIC8bGoPW43nOIv4tOiJovGuFVDiOEjPqXSJDlqR6sA
  60400. 1KGzqSX+DT+nHbrTUcELpNqsOO9VUCQFZUaTNE8tja3G1CEZ0o7KBWFxB3NH5YoZEr0ETc5OnKVI
  60401. rLsm9wIDAQABo4GOMIGLMB0GA1UdDgQWBBQLWOWLxkwVN6RAqTCpIb5HNlpW/zAOBgNVHQ8BAf8E
  60402. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zBJBgNVHR8EQjBAMD6gPKA6hjhodHRwOi8vY3JsLmNvbW9k
  60403. b2NhLmNvbS9DT01PRE9DZXJ0aWZpY2F0aW9uQXV0aG9yaXR5LmNybDANBgkqhkiG9w0BAQUFAAOC
  60404. AQEAPpiem/Yb6dc5t3iuHXIYSdOH5EOC6z/JqvWote9VfCFSZfnVDeFs9D6Mk3ORLgLETgdxb8CP
  60405. OGEIqB6BCsAvIC9Bi5HcSEW88cbeunZrM8gALTFGTO3nnc+IlP8zwFboJIYmuNg4ON8qa90SzMc/
  60406. RxdMosIGlgnW2/4/PEZB31jiVg88O8EckzXZOFKs7sjsLjBOlDW0JB9LeGna8gI4zJVSk/BwJVmc
  60407. IGfE7vmLV2H0knZ9P4SNVbfo5azV8fUZVqZa+5Acr5Pr5RzUZ5ddBA6+C4OmF4O5MBKgxTMVBbkN
  60408. +8cFduPYSo38NBejxiEovjBFMR7HeL5YYTisO+IBZQ==
  60409. -----END CERTIFICATE-----
  60410. Network Solutions Certificate Authority
  60411. =======================================
  60412. -----BEGIN CERTIFICATE-----
  60413. MIID5jCCAs6gAwIBAgIQV8szb8JcFuZHFhfjkDFo4DANBgkqhkiG9w0BAQUFADBiMQswCQYDVQQG
  60414. EwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMuMTAwLgYDVQQDEydOZXR3b3Jr
  60415. IFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMDYxMjAxMDAwMDAwWhcNMjkxMjMx
  60416. MjM1OTU5WjBiMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMu
  60417. MTAwLgYDVQQDEydOZXR3b3JrIFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggEiMA0G
  60418. CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDkvH6SMG3G2I4rC7xGzuAnlt7e+foS0zwzc7MEL7xx
  60419. jOWftiJgPl9dzgn/ggwbmlFQGiaJ3dVhXRncEg8tCqJDXRfQNJIg6nPPOCwGJgl6cvf6UDL4wpPT
  60420. aaIjzkGxzOTVHzbRijr4jGPiFFlp7Q3Tf2vouAPlT2rlmGNpSAW+Lv8ztumXWWn4Zxmuk2GWRBXT
  60421. crA/vGp97Eh/jcOrqnErU2lBUzS1sLnFBgrEsEX1QV1uiUV7PTsmjHTC5dLRfbIR1PtYMiKagMnc
  60422. /Qzpf14Dl847ABSHJ3A4qY5usyd2mFHgBeMhqxrVhSI8KbWaFsWAqPS7azCPL0YCorEMIuDTAgMB
  60423. AAGjgZcwgZQwHQYDVR0OBBYEFCEwyfsA106Y2oeqKtCnLrFAMadMMA4GA1UdDwEB/wQEAwIBBjAP
  60424. BgNVHRMBAf8EBTADAQH/MFIGA1UdHwRLMEkwR6BFoEOGQWh0dHA6Ly9jcmwubmV0c29sc3NsLmNv
  60425. bS9OZXR3b3JrU29sdXRpb25zQ2VydGlmaWNhdGVBdXRob3JpdHkuY3JsMA0GCSqGSIb3DQEBBQUA
  60426. A4IBAQC7rkvnt1frf6ott3NHhWrB5KUd5Oc86fRZZXe1eltajSU24HqXLjjAV2CDmAaDn7l2em5Q
  60427. 4LqILPxFzBiwmZVRDuwduIj/h1AcgsLj4DKAv6ALR8jDMe+ZZzKATxcheQxpXN5eNK4CtSbqUN9/
  60428. GGUsyfJj4akH/nxxH2szJGoeBfcFaMBqEssuXmHLrijTfsK0ZpEmXzwuJF/LWA/rKOyvEZbz3Htv
  60429. wKeI8lN3s2Berq4o2jUsbzRF0ybh3uxbTydrFny9RAQYgrOJeRcQcT16ohZO9QHNpGxlaKFJdlxD
  60430. ydi8NmdspZS11My5vWo1ViHe2MPr+8ukYEywVaCge1ey
  60431. -----END CERTIFICATE-----
  60432. COMODO ECC Certification Authority
  60433. ==================================
  60434. -----BEGIN CERTIFICATE-----
  60435. MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTELMAkGA1UEBhMC
  60436. R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE
  60437. ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBB
  60438. dXRob3JpdHkwHhcNMDgwMzA2MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0Ix
  60439. GzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR
  60440. Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRo
  60441. b3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSRFtSrYpn1PlILBs5BAH+X
  60442. 4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0JcfRK9ChQtP6IHG4/bC8vCVlbpVsLM5ni
  60443. wz2J+Wos77LTBumjQjBAMB0GA1UdDgQWBBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8E
  60444. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VG
  60445. FAkK+qDmfQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdvGDeA
  60446. U/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY=
  60447. -----END CERTIFICATE-----
  60448. OISTE WISeKey Global Root GA CA
  60449. ===============================
  60450. -----BEGIN CERTIFICATE-----
  60451. MIID8TCCAtmgAwIBAgIQQT1yx/RrH4FDffHSKFTfmjANBgkqhkiG9w0BAQUFADCBijELMAkGA1UE
  60452. BhMCQ0gxEDAOBgNVBAoTB1dJU2VLZXkxGzAZBgNVBAsTEkNvcHlyaWdodCAoYykgMjAwNTEiMCAG
  60453. A1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNlZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBH
  60454. bG9iYWwgUm9vdCBHQSBDQTAeFw0wNTEyMTExNjAzNDRaFw0zNzEyMTExNjA5NTFaMIGKMQswCQYD
  60455. VQQGEwJDSDEQMA4GA1UEChMHV0lTZUtleTEbMBkGA1UECxMSQ29weXJpZ2h0IChjKSAyMDA1MSIw
  60456. IAYDVQQLExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5
  60457. IEdsb2JhbCBSb290IEdBIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAy0+zAJs9
  60458. Nt350UlqaxBJH+zYK7LG+DKBKUOVTJoZIyEVRd7jyBxRVVuuk+g3/ytr6dTqvirdqFEr12bDYVxg
  60459. Asj1znJ7O7jyTmUIms2kahnBAbtzptf2w93NvKSLtZlhuAGio9RN1AU9ka34tAhxZK9w8RxrfvbD
  60460. d50kc3vkDIzh2TbhmYsFmQvtRTEJysIA2/dyoJaqlYfQjse2YXMNdmaM3Bu0Y6Kff5MTMPGhJ9vZ
  60461. /yxViJGg4E8HsChWjBgbl0SOid3gF27nKu+POQoxhILYQBRJLnpB5Kf+42TMwVlxSywhp1t94B3R
  60462. LoGbw9ho972WG6xwsRYUC9tguSYBBQIDAQABo1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUw
  60463. AwEB/zAdBgNVHQ4EFgQUswN+rja8sHnR3JQmthG+IbJphpQwEAYJKwYBBAGCNxUBBAMCAQAwDQYJ
  60464. KoZIhvcNAQEFBQADggEBAEuh/wuHbrP5wUOxSPMowB0uyQlB+pQAHKSkq0lPjz0e701vvbyk9vIm
  60465. MMkQyh2I+3QZH4VFvbBsUfk2ftv1TDI6QU9bR8/oCy22xBmddMVHxjtqD6wU2zz0c5ypBd8A3HR4
  60466. +vg1YFkCExh8vPtNsCBtQ7tgMHpnM1zFmdH4LTlSc/uMqpclXHLZCB6rTjzjgTGfA6b7wP4piFXa
  60467. hNVQA7bihKOmNqoROgHhGEvWRGizPflTdISzRpFGlgC3gCy24eMQ4tui5yiPAZZiFj4A4xylNoEY
  60468. okxSdsARo27mHbrjWr42U8U+dY+GaSlYU7Wcu2+fXMUY7N0v4ZjJ/L7fCg0=
  60469. -----END CERTIFICATE-----
  60470. Certigna
  60471. ========
  60472. -----BEGIN CERTIFICATE-----
  60473. MIIDqDCCApCgAwIBAgIJAP7c4wEPyUj/MA0GCSqGSIb3DQEBBQUAMDQxCzAJBgNVBAYTAkZSMRIw
  60474. EAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hMB4XDTA3MDYyOTE1MTMwNVoXDTI3
  60475. MDYyOTE1MTMwNVowNDELMAkGA1UEBhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczERMA8GA1UEAwwI
  60476. Q2VydGlnbmEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDIaPHJ1tazNHUmgh7stL7q
  60477. XOEm7RFHYeGifBZ4QCHkYJ5ayGPhxLGWkv8YbWkj4Sti993iNi+RB7lIzw7sebYs5zRLcAglozyH
  60478. GxnygQcPOJAZ0xH+hrTy0V4eHpbNgGzOOzGTtvKg0KmVEn2lmsxryIRWijOp5yIVUxbwzBfsV1/p
  60479. ogqYCd7jX5xv3EjjhQsVWqa6n6xI4wmy9/Qy3l40vhx4XUJbzg4ij02Q130yGLMLLGq/jj8UEYkg
  60480. DncUtT2UCIf3JR7VsmAA7G8qKCVuKj4YYxclPz5EIBb2JsglrgVKtOdjLPOMFlN+XPsRGgjBRmKf
  60481. Irjxwo1p3Po6WAbfAgMBAAGjgbwwgbkwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUGu3+QTmQ
  60482. tCRZvgHyUtVF9lo53BEwZAYDVR0jBF0wW4AUGu3+QTmQtCRZvgHyUtVF9lo53BGhOKQ2MDQxCzAJ
  60483. BgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hggkA/tzjAQ/J
  60484. SP8wDgYDVR0PAQH/BAQDAgEGMBEGCWCGSAGG+EIBAQQEAwIABzANBgkqhkiG9w0BAQUFAAOCAQEA
  60485. hQMeknH2Qq/ho2Ge6/PAD/Kl1NqV5ta+aDY9fm4fTIrv0Q8hbV6lUmPOEvjvKtpv6zf+EwLHyzs+
  60486. ImvaYS5/1HI93TDhHkxAGYwP15zRgzB7mFncfca5DClMoTOi62c6ZYTTluLtdkVwj7Ur3vkj1klu
  60487. PBS1xp81HlDQwY9qcEQCYsuuHWhBp6pX6FOqB9IG9tUUBguRA3UsbHK1YZWaDYu5Def131TN3ubY
  60488. 1gkIl2PlwS6wt0QmwCbAr1UwnjvVNioZBPRcHv/PLLf/0P2HQBHVESO7SMAhqaQoLf0V+LBOK/Qw
  60489. WyH8EZE0vkHve52Xdf+XlcCWWC/qu0bXu+TZLg==
  60490. -----END CERTIFICATE-----
  60491. Cybertrust Global Root
  60492. ======================
  60493. -----BEGIN CERTIFICATE-----
  60494. MIIDoTCCAomgAwIBAgILBAAAAAABD4WqLUgwDQYJKoZIhvcNAQEFBQAwOzEYMBYGA1UEChMPQ3li
  60495. ZXJ0cnVzdCwgSW5jMR8wHQYDVQQDExZDeWJlcnRydXN0IEdsb2JhbCBSb290MB4XDTA2MTIxNTA4
  60496. MDAwMFoXDTIxMTIxNTA4MDAwMFowOzEYMBYGA1UEChMPQ3liZXJ0cnVzdCwgSW5jMR8wHQYDVQQD
  60497. ExZDeWJlcnRydXN0IEdsb2JhbCBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
  60498. +Mi8vRRQZhP/8NN57CPytxrHjoXxEnOmGaoQ25yiZXRadz5RfVb23CO21O1fWLE3TdVJDm71aofW
  60499. 0ozSJ8bi/zafmGWgE07GKmSb1ZASzxQG9Dvj1Ci+6A74q05IlG2OlTEQXO2iLb3VOm2yHLtgwEZL
  60500. AfVJrn5GitB0jaEMAs7u/OePuGtm839EAL9mJRQr3RAwHQeWP032a7iPt3sMpTjr3kfb1V05/Iin
  60501. 89cqdPHoWqI7n1C6poxFNcJQZZXcY4Lv3b93TZxiyWNzFtApD0mpSPCzqrdsxacwOUBdrsTiXSZT
  60502. 8M4cIwhhqJQZugRiQOwfOHB3EgZxpzAYXSUnpQIDAQABo4GlMIGiMA4GA1UdDwEB/wQEAwIBBjAP
  60503. BgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBS2CHsNesysIEyGVjJez6tuhS1wVzA/BgNVHR8EODA2
  60504. MDSgMqAwhi5odHRwOi8vd3d3Mi5wdWJsaWMtdHJ1c3QuY29tL2NybC9jdC9jdHJvb3QuY3JsMB8G
  60505. A1UdIwQYMBaAFLYIew16zKwgTIZWMl7Pq26FLXBXMA0GCSqGSIb3DQEBBQUAA4IBAQBW7wojoFRO
  60506. lZfJ+InaRcHUowAl9B8Tq7ejhVhpwjCt2BWKLePJzYFa+HMjWqd8BfP9IjsO0QbE2zZMcwSO5bAi
  60507. 5MXzLqXZI+O4Tkogp24CJJ8iYGd7ix1yCcUxXOl5n4BHPa2hCwcUPUf/A2kaDAtE52Mlp3+yybh2
  60508. hO0j9n0Hq0V+09+zv+mKts2oomcrUtW3ZfA5TGOgkXmTUg9U3YO7n9GPp1Nzw8v/MOx8BLjYRB+T
  60509. X3EJIrduPuocA06dGiBh+4E37F78CkWr1+cXVdCg6mCbpvbjjFspwgZgFJ0tl0ypkxWdYcQBX0jW
  60510. WL1WMRJOEcgh4LMRkWXbtKaIOM5V
  60511. -----END CERTIFICATE-----
  60512. ePKI Root Certification Authority
  60513. =================================
  60514. -----BEGIN CERTIFICATE-----
  60515. MIIFsDCCA5igAwIBAgIQFci9ZUdcr7iXAF7kBtK8nTANBgkqhkiG9w0BAQUFADBeMQswCQYDVQQG
  60516. EwJUVzEjMCEGA1UECgwaQ2h1bmdod2EgVGVsZWNvbSBDby4sIEx0ZC4xKjAoBgNVBAsMIWVQS0kg
  60517. Um9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNDEyMjAwMjMxMjdaFw0zNDEyMjAwMjMx
  60518. MjdaMF4xCzAJBgNVBAYTAlRXMSMwIQYDVQQKDBpDaHVuZ2h3YSBUZWxlY29tIENvLiwgTHRkLjEq
  60519. MCgGA1UECwwhZVBLSSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0B
  60520. AQEFAAOCAg8AMIICCgKCAgEA4SUP7o3biDN1Z82tH306Tm2d0y8U82N0ywEhajfqhFAHSyZbCUNs
  60521. IZ5qyNUD9WBpj8zwIuQf5/dqIjG3LBXy4P4AakP/h2XGtRrBp0xtInAhijHyl3SJCRImHJ7K2RKi
  60522. lTza6We/CKBk49ZCt0Xvl/T29de1ShUCWH2YWEtgvM3XDZoTM1PRYfl61dd4s5oz9wCGzh1NlDiv
  60523. qOx4UXCKXBCDUSH3ET00hl7lSM2XgYI1TBnsZfZrxQWh7kcT1rMhJ5QQCtkkO7q+RBNGMD+XPNjX
  60524. 12ruOzjjK9SXDrkb5wdJfzcq+Xd4z1TtW0ado4AOkUPB1ltfFLqfpo0kR0BZv3I4sjZsN/+Z0V0O
  60525. WQqraffAsgRFelQArr5T9rXn4fg8ozHSqf4hUmTFpmfwdQcGlBSBVcYn5AGPF8Fqcde+S/uUWH1+
  60526. ETOxQvdibBjWzwloPn9s9h6PYq2lY9sJpx8iQkEeb5mKPtf5P0B6ebClAZLSnT0IFaUQAS2zMnao
  60527. lQ2zepr7BxB4EW/hj8e6DyUadCrlHJhBmd8hh+iVBmoKs2pHdmX2Os+PYhcZewoozRrSgx4hxyy/
  60528. vv9haLdnG7t4TY3OZ+XkwY63I2binZB1NJipNiuKmpS5nezMirH4JYlcWrYvjB9teSSnUmjDhDXi
  60529. Zo1jDiVN1Rmy5nk3pyKdVDECAwEAAaNqMGgwHQYDVR0OBBYEFB4M97Zn8uGSJglFwFU5Lnc/Qkqi
  60530. MAwGA1UdEwQFMAMBAf8wOQYEZyoHAAQxMC8wLQIBADAJBgUrDgMCGgUAMAcGBWcqAwAABBRFsMLH
  60531. ClZ87lt4DJX5GFPBphzYEDANBgkqhkiG9w0BAQUFAAOCAgEACbODU1kBPpVJufGBuvl2ICO1J2B0
  60532. 1GqZNF5sAFPZn/KmsSQHRGoqxqWOeBLoR9lYGxMqXnmbnwoqZ6YlPwZpVnPDimZI+ymBV3QGypzq
  60533. KOg4ZyYr8dW1P2WT+DZdjo2NQCCHGervJ8A9tDkPJXtoUHRVnAxZfVo9QZQlUgjgRywVMRnVvwdV
  60534. xrsStZf0X4OFunHB2WyBEXYKCrC/gpf36j36+uwtqSiUO1bd0lEursC9CBWMd1I0ltabrNMdjmEP
  60535. NXubrjlpC2JgQCA2j6/7Nu4tCEoduL+bXPjqpRugc6bY+G7gMwRfaKonh+3ZwZCc7b3jajWvY9+r
  60536. GNm65ulK6lCKD2GTHuItGeIwlDWSXQ62B68ZgI9HkFFLLk3dheLSClIKF5r8GrBQAuUBo2M3IUxE
  60537. xJtRmREOc5wGj1QupyheRDmHVi03vYVElOEMSyycw5KFNGHLD7ibSkNS/jQ6fbjpKdx2qcgw+BRx
  60538. gMYeNkh0IkFch4LoGHGLQYlE535YW6i4jRPpp2zDR+2zGp1iro2C6pSe3VkQw63d4k3jMdXH7Ojy
  60539. sP6SHhYKGvzZ8/gntsm+HbRsZJB/9OTEW9c3rkIO3aQab3yIVMUWbuF6aC74Or8NpDyJO3inTmOD
  60540. BCEIZ43ygknQW/2xzQ+DhNQ+IIX3Sj0rnP0qCglN6oH4EZw=
  60541. -----END CERTIFICATE-----
  60542. certSIGN ROOT CA
  60543. ================
  60544. -----BEGIN CERTIFICATE-----
  60545. MIIDODCCAiCgAwIBAgIGIAYFFnACMA0GCSqGSIb3DQEBBQUAMDsxCzAJBgNVBAYTAlJPMREwDwYD
  60546. VQQKEwhjZXJ0U0lHTjEZMBcGA1UECxMQY2VydFNJR04gUk9PVCBDQTAeFw0wNjA3MDQxNzIwMDRa
  60547. Fw0zMTA3MDQxNzIwMDRaMDsxCzAJBgNVBAYTAlJPMREwDwYDVQQKEwhjZXJ0U0lHTjEZMBcGA1UE
  60548. CxMQY2VydFNJR04gUk9PVCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALczuX7I
  60549. JUqOtdu0KBuqV5Do0SLTZLrTk+jUrIZhQGpgV2hUhE28alQCBf/fm5oqrl0Hj0rDKH/v+yv6efHH
  60550. rfAQUySQi2bJqIirr1qjAOm+ukbuW3N7LBeCgV5iLKECZbO9xSsAfsT8AzNXDe3i+s5dRdY4zTW2
  60551. ssHQnIFKquSyAVwdj1+ZxLGt24gh65AIgoDzMKND5pCCrlUoSe1b16kQOA7+j0xbm0bqQfWwCHTD
  60552. 0IgztnzXdN/chNFDDnU5oSVAKOp4yw4sLjmdjItuFhwvJoIQ4uNllAoEwF73XVv4EOLQunpL+943
  60553. AAAaWyjj0pxzPjKHmKHJUS/X3qwzs08CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8B
  60554. Af8EBAMCAcYwHQYDVR0OBBYEFOCMm9slSbPxfIbWskKHC9BroNnkMA0GCSqGSIb3DQEBBQUAA4IB
  60555. AQA+0hyJLjX8+HXd5n9liPRyTMks1zJO890ZeUe9jjtbkw9QSSQTaxQGcu8J06Gh40CEyecYMnQ8
  60556. SG4Pn0vU9x7Tk4ZkVJdjclDVVc/6IJMCopvDI5NOFlV2oHB5bc0hH88vLbwZ44gx+FkagQnIl6Z0
  60557. x2DEW8xXjrJ1/RsCCdtZb3KTafcxQdaIOL+Hsr0Wefmq5L6IJd1hJyMctTEHBDa0GpC9oHRxUIlt
  60558. vBTjD4au8as+x6AJzKNI0eDbZOeStc+vckNwi/nDhDwTqn6Sm1dTk/pwwpEOMfmbZ13pljheX7Nz
  60559. TogVZ96edhBiIL5VaZVDADlN9u6wWk5JRFRYX0KD
  60560. -----END CERTIFICATE-----
  60561. GeoTrust Primary Certification Authority - G3
  60562. =============================================
  60563. -----BEGIN CERTIFICATE-----
  60564. MIID/jCCAuagAwIBAgIQFaxulBmyeUtB9iepwxgPHzANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UE
  60565. BhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsTMChjKSAyMDA4IEdlb1RydXN0
  60566. IEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTE2MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFy
  60567. eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEczMB4XDTA4MDQwMjAwMDAwMFoXDTM3MTIwMTIz
  60568. NTk1OVowgZgxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAo
  60569. YykgMjAwOCBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0BgNVBAMT
  60570. LUdlb1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZI
  60571. hvcNAQEBBQADggEPADCCAQoCggEBANziXmJYHTNXOTIz+uvLh4yn1ErdBojqZI4xmKU4kB6Yzy5j
  60572. K/BGvESyiaHAKAxJcCGVn2TAppMSAmUmhsalifD614SgcK9PGpc/BkTVyetyEH3kMSj7HGHmKAdE
  60573. c5IiaacDiGydY8hS2pgn5whMcD60yRLBxWeDXTPzAxHsatBT4tG6NmCUgLthY2xbF37fQJQeqw3C
  60574. IShwiP/WJmxsYAQlTlV+fe+/lEjetx3dcI0FX4ilm/LC7urRQEFtYjgdVgbFA0dRIBn8exALDmKu
  60575. dlW/X3e+PkkBUz2YJQN2JFodtNuJ6nnltrM7P7pMKEF/BqxqjsHQ9gUdfeZChuOl1UcCAwEAAaNC
  60576. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMR5yo6hTgMdHNxr
  60577. 2zFblD4/MH8tMA0GCSqGSIb3DQEBCwUAA4IBAQAtxRPPVoB7eni9n64smefv2t+UXglpp+duaIy9
  60578. cr5HqQ6XErhK8WTTOd8lNNTBzU6B8A8ExCSzNJbGpqow32hhc9f5joWJ7w5elShKKiePEI4ufIbE
  60579. Ap7aDHdlDkQNkv39sxY2+hENHYwOB4lqKVb3cvTdFZx3NWZXqxNT2I7BQMXXExZacse3aQHEerGD
  60580. AWh9jUGhlBjBJVz88P6DAod8DQ3PLghcSkANPuyBYeYk28rgDi0Hsj5W3I31QYUHSJsMC8tJP33s
  60581. t/3LjWeJGqvtux6jAAgIFyqCXDFdRootD4abdNlF+9RAsXqqaC2Gspki4cErx5z481+oghLrGREt
  60582. -----END CERTIFICATE-----
  60583. thawte Primary Root CA - G2
  60584. ===========================
  60585. -----BEGIN CERTIFICATE-----
  60586. MIICiDCCAg2gAwIBAgIQNfwmXNmET8k9Jj1Xm67XVjAKBggqhkjOPQQDAzCBhDELMAkGA1UEBhMC
  60587. VVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjE4MDYGA1UECxMvKGMpIDIwMDcgdGhhd3RlLCBJbmMu
  60588. IC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxJDAiBgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3Qg
  60589. Q0EgLSBHMjAeFw0wNzExMDUwMDAwMDBaFw0zODAxMTgyMzU5NTlaMIGEMQswCQYDVQQGEwJVUzEV
  60590. MBMGA1UEChMMdGhhd3RlLCBJbmMuMTgwNgYDVQQLEy8oYykgMjAwNyB0aGF3dGUsIEluYy4gLSBG
  60591. b3IgYXV0aG9yaXplZCB1c2Ugb25seTEkMCIGA1UEAxMbdGhhd3RlIFByaW1hcnkgUm9vdCBDQSAt
  60592. IEcyMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEotWcgnuVnfFSeIf+iha/BebfowJPDQfGAFG6DAJS
  60593. LSKkQjnE/o/qycG+1E3/n3qe4rF8mq2nhglzh9HnmuN6papu+7qzcMBniKI11KOasf2twu8x+qi5
  60594. 8/sIxpHR+ymVo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU
  60595. mtgAMADna3+FGO6Lts6KDPgR4bswCgYIKoZIzj0EAwMDaQAwZgIxAN344FdHW6fmCsO99YCKlzUN
  60596. G4k8VIZ3KMqh9HneteY4sPBlcIx/AlTCv//YoT7ZzwIxAMSNlPzcU9LcnXgWHxUzI1NS41oxXZ3K
  60597. rr0TKUQNJ1uo52icEvdYPy5yAlejj6EULg==
  60598. -----END CERTIFICATE-----
  60599. thawte Primary Root CA - G3
  60600. ===========================
  60601. -----BEGIN CERTIFICATE-----
  60602. MIIEKjCCAxKgAwIBAgIQYAGXt0an6rS0mtZLL/eQ+zANBgkqhkiG9w0BAQsFADCBrjELMAkGA1UE
  60603. BhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2
  60604. aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIwMDggdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhv
  60605. cml6ZWQgdXNlIG9ubHkxJDAiBgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EgLSBHMzAeFw0w
  60606. ODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIGuMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMdGhh
  60607. d3RlLCBJbmMuMSgwJgYDVQQLEx9DZXJ0aWZpY2F0aW9uIFNlcnZpY2VzIERpdmlzaW9uMTgwNgYD
  60608. VQQLEy8oYykgMjAwOCB0aGF3dGUsIEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTEkMCIG
  60609. A1UEAxMbdGhhd3RlIFByaW1hcnkgUm9vdCBDQSAtIEczMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  60610. MIIBCgKCAQEAsr8nLPvb2FvdeHsbnndmgcs+vHyu86YnmjSjaDFxODNi5PNxZnmxqWWjpYvVj2At
  60611. P0LMqmsywCPLLEHd5N/8YZzic7IilRFDGF/Eth9XbAoFWCLINkw6fKXRz4aviKdEAhN0cXMKQlkC
  60612. +BsUa0Lfb1+6a4KinVvnSr0eAXLbS3ToO39/fR8EtCab4LRarEc9VbjXsCZSKAExQGbY2SS99irY
  60613. 7CFJXJv2eul/VTV+lmuNk5Mny5K76qxAwJ/C+IDPXfRa3M50hqY+bAtTyr2SzhkGcuYMXDhpxwTW
  60614. vGzOW/b3aJzcJRVIiKHpqfiYnODz1TEoYRFsZ5aNOZnLwkUkOQIDAQABo0IwQDAPBgNVHRMBAf8E
  60615. BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUrWyqlGCc7eT/+j4KdCtjA/e2Wb8wDQYJ
  60616. KoZIhvcNAQELBQADggEBABpA2JVlrAmSicY59BDlqQ5mU1143vokkbvnRFHfxhY0Cu9qRFHqKweK
  60617. A3rD6z8KLFIWoCtDuSWQP3CpMyVtRRooOyfPqsMpQhvfO0zAMzRbQYi/aytlryjvsvXDqmbOe1bu
  60618. t8jLZ8HJnBoYuMTDSQPxYA5QzUbF83d597YV4Djbxy8ooAw/dyZ02SUS2jHaGh7cKUGRIjxpp7sC
  60619. 8rZcJwOJ9Abqm+RyguOhCcHpABnTPtRwa7pxpqpYrvS76Wy274fMm7v/OeZWYdMKp8RcTGB7BXcm
  60620. er/YB1IsYvdwY9k5vG8cwnncdimvzsUsZAReiDZuMdRAGmI0Nj81Aa6sY6A=
  60621. -----END CERTIFICATE-----
  60622. GeoTrust Primary Certification Authority - G2
  60623. =============================================
  60624. -----BEGIN CERTIFICATE-----
  60625. MIICrjCCAjWgAwIBAgIQPLL0SAoA4v7rJDteYD7DazAKBggqhkjOPQQDAzCBmDELMAkGA1UEBhMC
  60626. VVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsTMChjKSAyMDA3IEdlb1RydXN0IElu
  60627. Yy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTE2MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFyeSBD
  60628. ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMB4XDTA3MTEwNTAwMDAwMFoXDTM4MDExODIzNTk1
  60629. OVowgZgxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAoYykg
  60630. MjAwNyBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0BgNVBAMTLUdl
  60631. b1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMjB2MBAGByqGSM49AgEG
  60632. BSuBBAAiA2IABBWx6P0DFUPlrOuHNxFi79KDNlJ9RVcLSo17VDs6bl8VAsBQps8lL33KSLjHUGMc
  60633. KiEIfJo22Av+0SbFWDEwKCXzXV2juLaltJLtbCyf691DiaI8S0iRHVDsJt/WYC69IaNCMEAwDwYD
  60634. VR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFBVfNVdRVfslsq0DafwBo/q+
  60635. EVXVMAoGCCqGSM49BAMDA2cAMGQCMGSWWaboCd6LuvpaiIjwH5HTRqjySkwCY/tsXzjbLkGTqQ7m
  60636. ndwxHLKgpxgceeHHNgIwOlavmnRs9vuD4DPTCF+hnMJbn0bWtsuRBmOiBuczrD6ogRLQy7rQkgu2
  60637. npaqBA+K
  60638. -----END CERTIFICATE-----
  60639. VeriSign Universal Root Certification Authority
  60640. ===============================================
  60641. -----BEGIN CERTIFICATE-----
  60642. MIIEuTCCA6GgAwIBAgIQQBrEZCGzEyEDDrvkEhrFHTANBgkqhkiG9w0BAQsFADCBvTELMAkGA1UE
  60643. BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO
  60644. ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwOCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk
  60645. IHVzZSBvbmx5MTgwNgYDVQQDEy9WZXJpU2lnbiBVbml2ZXJzYWwgUm9vdCBDZXJ0aWZpY2F0aW9u
  60646. IEF1dGhvcml0eTAeFw0wODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIG9MQswCQYDVQQGEwJV
  60647. UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv
  60648. cmsxOjA4BgNVBAsTMShjKSAyMDA4IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl
  60649. IG9ubHkxODA2BgNVBAMTL1ZlcmlTaWduIFVuaXZlcnNhbCBSb290IENlcnRpZmljYXRpb24gQXV0
  60650. aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx2E3XrEBNNti1xWb/1hajCMj
  60651. 1mCOkdeQmIN65lgZOIzF9uVkhbSicfvtvbnazU0AtMgtc6XHaXGVHzk8skQHnOgO+k1KxCHfKWGP
  60652. MiJhgsWHH26MfF8WIFFE0XBPV+rjHOPMee5Y2A7Cs0WTwCznmhcrewA3ekEzeOEz4vMQGn+HLL72
  60653. 9fdC4uW/h2KJXwBL38Xd5HVEMkE6HnFuacsLdUYI0crSK5XQz/u5QGtkjFdN/BMReYTtXlT2NJ8I
  60654. AfMQJQYXStrxHXpma5hgZqTZ79IugvHw7wnqRMkVauIDbjPTrJ9VAMf2CGqUuV/c4DPxhGD5WycR
  60655. tPwW8rtWaoAljQIDAQABo4GyMIGvMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMG0G
  60656. CCsGAQUFBwEMBGEwX6FdoFswWTBXMFUWCWltYWdlL2dpZjAhMB8wBwYFKw4DAhoEFI/l0xqGrI2O
  60657. a8PPgGrUSBgsexkuMCUWI2h0dHA6Ly9sb2dvLnZlcmlzaWduLmNvbS92c2xvZ28uZ2lmMB0GA1Ud
  60658. DgQWBBS2d/ppSEefUxLVwuoHMnYH0ZcHGTANBgkqhkiG9w0BAQsFAAOCAQEASvj4sAPmLGd75JR3
  60659. Y8xuTPl9Dg3cyLk1uXBPY/ok+myDjEedO2Pzmvl2MpWRsXe8rJq+seQxIcaBlVZaDrHC1LGmWazx
  60660. Y8u4TB1ZkErvkBYoH1quEPuBUDgMbMzxPcP1Y+Oz4yHJJDnp/RVmRvQbEdBNc6N9Rvk97ahfYtTx
  60661. P/jgdFcrGJ2BtMQo2pSXpXDrrB2+BxHw1dvd5Yzw1TKwg+ZX4o+/vqGqvz0dtdQ46tewXDpPaj+P
  60662. wGZsY6rp2aQW9IHRlRQOfc2VNNnSj3BzgXucfr2YYdhFh5iQxeuGMMY1v/D/w1WIg0vvBZIGcfK4
  60663. mJO37M2CYfE45k+XmCpajQ==
  60664. -----END CERTIFICATE-----
  60665. VeriSign Class 3 Public Primary Certification Authority - G4
  60666. ============================================================
  60667. -----BEGIN CERTIFICATE-----
  60668. MIIDhDCCAwqgAwIBAgIQL4D+I4wOIg9IZxIokYesszAKBggqhkjOPQQDAzCByjELMAkGA1UEBhMC
  60669. VVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3
  60670. b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVz
  60671. ZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmlj
  60672. YXRpb24gQXV0aG9yaXR5IC0gRzQwHhcNMDcxMTA1MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCByjEL
  60673. MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBU
  60674. cnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRo
  60675. b3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5
  60676. IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzQwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAASnVnp8
  60677. Utpkmw4tXNherJI9/gHmGUo9FANL+mAnINmDiWn6VMaaGF5VKmTeBvaNSjutEDxlPZCIBIngMGGz
  60678. rl0Bp3vefLK+ymVhAIau2o970ImtTR1ZmkGxvEeA3J5iw/mjgbIwga8wDwYDVR0TAQH/BAUwAwEB
  60679. /zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2UvZ2lmMCEw
  60680. HzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVyaXNpZ24u
  60681. Y29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFLMWkf3upm7ktS5Jj4d4gYDs5bG1MAoGCCqGSM49BAMD
  60682. A2gAMGUCMGYhDBgmYFo4e1ZC4Kf8NoRRkSAsdk1DPcQdhCPQrNZ8NQbOzWm9kA3bbEhCHQ6qQgIx
  60683. AJw9SDkjOVgaFRJZap7v1VmyHVIsmXHNxynfGyphe3HR3vPA5Q06Sqotp9iGKt0uEA==
  60684. -----END CERTIFICATE-----
  60685. NetLock Arany (Class Gold) Főtanúsítvány
  60686. ========================================
  60687. -----BEGIN CERTIFICATE-----
  60688. MIIEFTCCAv2gAwIBAgIGSUEs5AAQMA0GCSqGSIb3DQEBCwUAMIGnMQswCQYDVQQGEwJIVTERMA8G
  60689. A1UEBwwIQnVkYXBlc3QxFTATBgNVBAoMDE5ldExvY2sgS2Z0LjE3MDUGA1UECwwuVGFuw7pzw610
  60690. dsOhbnlraWFkw7NrIChDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzKTE1MDMGA1UEAwwsTmV0TG9jayBB
  60691. cmFueSAoQ2xhc3MgR29sZCkgRsWRdGFuw7pzw610dsOhbnkwHhcNMDgxMjExMTUwODIxWhcNMjgx
  60692. MjA2MTUwODIxWjCBpzELMAkGA1UEBhMCSFUxETAPBgNVBAcMCEJ1ZGFwZXN0MRUwEwYDVQQKDAxO
  60693. ZXRMb2NrIEtmdC4xNzA1BgNVBAsMLlRhbsO6c8OtdHbDoW55a2lhZMOzayAoQ2VydGlmaWNhdGlv
  60694. biBTZXJ2aWNlcykxNTAzBgNVBAMMLE5ldExvY2sgQXJhbnkgKENsYXNzIEdvbGQpIEbFkXRhbsO6
  60695. c8OtdHbDoW55MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxCRec75LbRTDofTjl5Bu
  60696. 0jBFHjzuZ9lk4BqKf8owyoPjIMHj9DrTlF8afFttvzBPhCf2nx9JvMaZCpDyD/V/Q4Q3Y1GLeqVw
  60697. /HpYzY6b7cNGbIRwXdrzAZAj/E4wqX7hJ2Pn7WQ8oLjJM2P+FpD/sLj916jAwJRDC7bVWaaeVtAk
  60698. H3B5r9s5VA1lddkVQZQBr17s9o3x/61k/iCa11zr/qYfCGSji3ZVrR47KGAuhyXoqq8fxmRGILdw
  60699. fzzeSNuWU7c5d+Qa4scWhHaXWy+7GRWF+GmF9ZmnqfI0p6m2pgP8b4Y9VHx2BJtr+UBdADTHLpl1
  60700. neWIA6pN+APSQnbAGwIDAKiLo0UwQzASBgNVHRMBAf8ECDAGAQH/AgEEMA4GA1UdDwEB/wQEAwIB
  60701. BjAdBgNVHQ4EFgQUzPpnk/C2uNClwB7zU/2MU9+D15YwDQYJKoZIhvcNAQELBQADggEBAKt/7hwW
  60702. qZw8UQCgwBEIBaeZ5m8BiFRhbvG5GK1Krf6BQCOUL/t1fC8oS2IkgYIL9WHxHG64YTjrgfpioTta
  60703. YtOUZcTh5m2C+C8lcLIhJsFyUR+MLMOEkMNaj7rP9KdlpeuY0fsFskZ1FSNqb4VjMIDw1Z4fKRzC
  60704. bLBQWV2QWzuoDTDPv31/zvGdg73JRm4gpvlhUbohL3u+pRVjodSVh/GeufOJ8z2FuLjbvrW5Kfna
  60705. NwUASZQDhETnv0Mxz3WLJdH0pmT1kvarBes96aULNmLazAZfNou2XjG4Kvte9nHfRCaexOYNkbQu
  60706. dZWAUWpLMKawYqGT8ZvYzsRjdT9ZR7E=
  60707. -----END CERTIFICATE-----
  60708. Hongkong Post Root CA 1
  60709. =======================
  60710. -----BEGIN CERTIFICATE-----
  60711. MIIDMDCCAhigAwIBAgICA+gwDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCSEsxFjAUBgNVBAoT
  60712. DUhvbmdrb25nIFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3QgUm9vdCBDQSAxMB4XDTAzMDUx
  60713. NTA1MTMxNFoXDTIzMDUxNTA0NTIyOVowRzELMAkGA1UEBhMCSEsxFjAUBgNVBAoTDUhvbmdrb25n
  60714. IFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3QgUm9vdCBDQSAxMIIBIjANBgkqhkiG9w0BAQEF
  60715. AAOCAQ8AMIIBCgKCAQEArP84tulmAknjorThkPlAj3n54r15/gK97iSSHSL22oVyaf7XPwnU3ZG1
  60716. ApzQjVrhVcNQhrkpJsLj2aDxaQMoIIBFIi1WpztUlVYiWR8o3x8gPW2iNr4joLFutbEnPzlTCeqr
  60717. auh0ssJlXI6/fMN4hM2eFvz1Lk8gKgifd/PFHsSaUmYeSF7jEAaPIpjhZY4bXSNmO7ilMlHIhqqh
  60718. qZ5/dpTCpmy3QfDVyAY45tQM4vM7TG1QjMSDJ8EThFk9nnV0ttgCXjqQesBCNnLsak3c78QA3xMY
  60719. V18meMjWCnl3v/evt3a5pQuEF10Q6m/hq5URX208o1xNg1vysxmKgIsLhwIDAQABoyYwJDASBgNV
  60720. HRMBAf8ECDAGAQH/AgEDMA4GA1UdDwEB/wQEAwIBxjANBgkqhkiG9w0BAQUFAAOCAQEADkbVPK7i
  60721. h9legYsCmEEIjEy82tvuJxuC52pF7BaLT4Wg87JwvVqWuspube5Gi27nKi6Wsxkz67SfqLI37pio
  60722. l7Yutmcn1KZJ/RyTZXaeQi/cImyaT/JaFTmxcdcrUehtHJjA2Sr0oYJ71clBoiMBdDhViw+5Lmei
  60723. IAQ32pwL0xch4I+XeTRvhEgCIDMb5jREn5Fw9IBehEPCKdJsEhTkYY2sEJCehFC78JZvRZ+K88ps
  60724. T/oROhUVRsPNH4NbLUES7VBnQRM9IauUiqpOfMGx+6fWtScvl6tu4B3i0RwsH0Ti/L6RoZz71ilT
  60725. c4afU9hDDl3WY4JxHYB0yvbiAmvZWg==
  60726. -----END CERTIFICATE-----
  60727. SecureSign RootCA11
  60728. ===================
  60729. -----BEGIN CERTIFICATE-----
  60730. MIIDbTCCAlWgAwIBAgIBATANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQGEwJKUDErMCkGA1UEChMi
  60731. SmFwYW4gQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcywgSW5jLjEcMBoGA1UEAxMTU2VjdXJlU2lnbiBS
  60732. b290Q0ExMTAeFw0wOTA0MDgwNDU2NDdaFw0yOTA0MDgwNDU2NDdaMFgxCzAJBgNVBAYTAkpQMSsw
  60733. KQYDVQQKEyJKYXBhbiBDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzLCBJbmMuMRwwGgYDVQQDExNTZWN1
  60734. cmVTaWduIFJvb3RDQTExMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA/XeqpRyQBTvL
  60735. TJszi1oURaTnkBbR31fSIRCkF/3frNYfp+TbfPfs37gD2pRY/V1yfIw/XwFndBWW4wI8h9uuywGO
  60736. wvNmxoVF9ALGOrVisq/6nL+k5tSAMJjzDbaTj6nU2DbysPyKyiyhFTOVMdrAG/LuYpmGYz+/3ZMq
  60737. g6h2uRMft85OQoWPIucuGvKVCbIFtUROd6EgvanyTgp9UK31BQ1FT0Zx/Sg+U/sE2C3XZR1KG/rP
  60738. O7AxmjVuyIsG0wCR8pQIZUyxNAYAeoni8McDWc/V1uinMrPmmECGxc0nEovMe863ETxiYAcjPitA
  60739. bpSACW22s293bzUIUPsCh8U+iQIDAQABo0IwQDAdBgNVHQ4EFgQUW/hNT7KlhtQ60vFjmqC+CfZX
  60740. t94wDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAKCh
  60741. OBZmLqdWHyGcBvod7bkixTgm2E5P7KN/ed5GIaGHd48HCJqypMWvDzKYC3xmKbabfSVSSUOrTC4r
  60742. bnpwrxYO4wJs+0LmGJ1F2FXI6Dvd5+H0LgscNFxsWEr7jIhQX5Ucv+2rIrVls4W6ng+4reV6G4pQ
  60743. Oh29Dbx7VFALuUKvVaAYga1lme++5Jy/xIWrQbJUb9wlze144o4MjQlJ3WN7WmmWAiGovVJZ6X01
  60744. y8hSyn+B/tlr0/cR7SXf+Of5pPpyl4RTDaXQMhhRdlkUbA/r7F+AjHVDg8OFmP9Mni0N5HeDk061
  60745. lgeLKBObjBmNQSdJQO7e5iNEOdyhIta6A/I=
  60746. -----END CERTIFICATE-----
  60747. Microsec e-Szigno Root CA 2009
  60748. ==============================
  60749. -----BEGIN CERTIFICATE-----
  60750. MIIECjCCAvKgAwIBAgIJAMJ+QwRORz8ZMA0GCSqGSIb3DQEBCwUAMIGCMQswCQYDVQQGEwJIVTER
  60751. MA8GA1UEBwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jv
  60752. c2VjIGUtU3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5o
  60753. dTAeFw0wOTA2MTYxMTMwMThaFw0yOTEyMzAxMTMwMThaMIGCMQswCQYDVQQGEwJIVTERMA8GA1UE
  60754. BwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jvc2VjIGUt
  60755. U3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5odTCCASIw
  60756. DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOn4j/NjrdqG2KfgQvvPkd6mJviZpWNwrZuuyjNA
  60757. fW2WbqEORO7hE52UQlKavXWFdCyoDh2Tthi3jCyoz/tccbna7P7ofo/kLx2yqHWH2Leh5TvPmUpG
  60758. 0IMZfcChEhyVbUr02MelTTMuhTlAdX4UfIASmFDHQWe4oIBhVKZsTh/gnQ4H6cm6M+f+wFUoLAKA
  60759. pxn1ntxVUwOXewdI/5n7N4okxFnMUBBjjqqpGrCEGob5X7uxUG6k0QrM1XF+H6cbfPVTbiJfyyvm
  60760. 1HxdrtbCxkzlBQHZ7Vf8wSN5/PrIJIOV87VqUQHQd9bpEqH5GoP7ghu5sJf0dgYzQ0mg/wu1+rUC
  60761. AwEAAaOBgDB+MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTLD8bf
  60762. QkPMPcu1SCOhGnqmKrs0aDAfBgNVHSMEGDAWgBTLD8bfQkPMPcu1SCOhGnqmKrs0aDAbBgNVHREE
  60763. FDASgRBpbmZvQGUtc3ppZ25vLmh1MA0GCSqGSIb3DQEBCwUAA4IBAQDJ0Q5eLtXMs3w+y/w9/w0o
  60764. lZMEyL/azXm4Q5DwpL7v8u8hmLzU1F0G9u5C7DBsoKqpyvGvivo/C3NqPuouQH4frlRheesuCDfX
  60765. I/OMn74dseGkddug4lQUsbocKaQY9hK6ohQU4zE1yED/t+AFdlfBHFny+L/k7SViXITwfn4fs775
  60766. tyERzAMBVnCnEJIeGzSBHq2cGsMEPO0CYdYeBvNfOofyK/FFh+U9rNHHV4S9a67c2Pm2G2JwCz02
  60767. yULyMtd6YebS2z3PyKnJm9zbWETXbzivf3jTo60adbocwTZ8jx5tHMN1Rq41Bab2XD0h7lbwyYIi
  60768. LXpUq3DDfSJlgnCW
  60769. -----END CERTIFICATE-----
  60770. GlobalSign Root CA - R3
  60771. =======================
  60772. -----BEGIN CERTIFICATE-----
  60773. MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4GA1UECxMXR2xv
  60774. YmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh
  60775. bFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT
  60776. aWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln
  60777. bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWt
  60778. iHL8RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsTgHeMCOFJ
  60779. 0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmmKPZpO/bLyCiR5Z2KYVc3
  60780. rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zdQQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjl
  60781. OCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZXriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2
  60782. xmmFghcCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
  60783. FI/wS3+oLkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZURUm7
  60784. lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMpjjM5RcOO5LlXbKr8
  60785. EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK6fBdRoyV3XpYKBovHd7NADdBj+1E
  60786. bddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQXmcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18
  60787. YIvDQVETI53O9zJrlAGomecsMx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7r
  60788. kpeDMdmztcpHWD9f
  60789. -----END CERTIFICATE-----
  60790. Autoridad de Certificacion Firmaprofesional CIF A62634068
  60791. =========================================================
  60792. -----BEGIN CERTIFICATE-----
  60793. MIIGFDCCA/ygAwIBAgIIU+w77vuySF8wDQYJKoZIhvcNAQEFBQAwUTELMAkGA1UEBhMCRVMxQjBA
  60794. BgNVBAMMOUF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1hcHJvZmVzaW9uYWwgQ0lGIEE2
  60795. MjYzNDA2ODAeFw0wOTA1MjAwODM4MTVaFw0zMDEyMzEwODM4MTVaMFExCzAJBgNVBAYTAkVTMUIw
  60796. QAYDVQQDDDlBdXRvcmlkYWQgZGUgQ2VydGlmaWNhY2lvbiBGaXJtYXByb2Zlc2lvbmFsIENJRiBB
  60797. NjI2MzQwNjgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKlmuO6vj78aI14H9M2uDD
  60798. Utd9thDIAl6zQyrET2qyyhxdKJp4ERppWVevtSBC5IsP5t9bpgOSL/UR5GLXMnE42QQMcas9UX4P
  60799. B99jBVzpv5RvwSmCwLTaUbDBPLutN0pcyvFLNg4kq7/DhHf9qFD0sefGL9ItWY16Ck6WaVICqjaY
  60800. 7Pz6FIMMNx/Jkjd/14Et5cS54D40/mf0PmbR0/RAz15iNA9wBj4gGFrO93IbJWyTdBSTo3OxDqqH
  60801. ECNZXyAFGUftaI6SEspd/NYrspI8IM/hX68gvqB2f3bl7BqGYTM+53u0P6APjqK5am+5hyZvQWyI
  60802. plD9amML9ZMWGxmPsu2bm8mQ9QEM3xk9Dz44I8kvjwzRAv4bVdZO0I08r0+k8/6vKtMFnXkIoctX
  60803. MbScyJCyZ/QYFpM6/EfY0XiWMR+6KwxfXZmtY4laJCB22N/9q06mIqqdXuYnin1oKaPnirjaEbsX
  60804. LZmdEyRG98Xi2J+Of8ePdG1asuhy9azuJBCtLxTa/y2aRnFHvkLfuwHb9H/TKI8xWVvTyQKmtFLK
  60805. bpf7Q8UIJm+K9Lv9nyiqDdVF8xM6HdjAeI9BZzwelGSuewvF6NkBiDkal4ZkQdU7hwxu+g/GvUgU
  60806. vzlN1J5Bto+WHWOWk9mVBngxaJ43BjuAiUVhOSPHG0SjFeUc+JIwuwIDAQABo4HvMIHsMBIGA1Ud
  60807. EwEB/wQIMAYBAf8CAQEwDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBRlzeurNR4APn7VdMActHNH
  60808. DhpkLzCBpgYDVR0gBIGeMIGbMIGYBgRVHSAAMIGPMC8GCCsGAQUFBwIBFiNodHRwOi8vd3d3LmZp
  60809. cm1hcHJvZmVzaW9uYWwuY29tL2NwczBcBggrBgEFBQcCAjBQHk4AUABhAHMAZQBvACAAZABlACAA
  60810. bABhACAAQgBvAG4AYQBuAG8AdgBhACAANAA3ACAAQgBhAHIAYwBlAGwAbwBuAGEAIAAwADgAMAAx
  60811. ADcwDQYJKoZIhvcNAQEFBQADggIBABd9oPm03cXF661LJLWhAqvdpYhKsg9VSytXjDvlMd3+xDLx
  60812. 51tkljYyGOylMnfX40S2wBEqgLk9am58m9Ot/MPWo+ZkKXzR4Tgegiv/J2Wv+xYVxC5xhOW1//qk
  60813. R71kMrv2JYSiJ0L1ILDCExARzRAVukKQKtJE4ZYm6zFIEv0q2skGz3QeqUvVhyj5eTSSPi5E6PaP
  60814. T481PyWzOdxjKpBrIF/EUhJOlywqrJ2X3kjyo2bbwtKDlaZmp54lD+kLM5FlClrD2VQS3a/DTg4f
  60815. Jl4N3LON7NWBcN7STyQF82xO9UxJZo3R/9ILJUFI/lGExkKvgATP0H5kSeTy36LssUzAKh3ntLFl
  60816. osS88Zj0qnAHY7S42jtM+kAiMFsRpvAFDsYCA0irhpuF3dvd6qJ2gHN99ZwExEWN57kci57q13XR
  60817. crHedUTnQn3iV2t93Jm8PYMo6oCTjcVMZcFwgbg4/EMxsvYDNEeyrPsiBsse3RdHHF9mudMaotoR
  60818. saS8I8nkvof/uZS2+F0gStRf571oe2XyFR7SOqkt6dhrJKyXWERHrVkY8SFlcN7ONGCoQPHzPKTD
  60819. KCOM/iczQ0CgFzzr6juwcqajuUpLXhZI9LK8yIySxZ2frHI2vDSANGupi5LAuBft7HZT9SQBjLMi
  60820. 6Et8Vcad+qMUu2WFbm5PEn4KPJ2V
  60821. -----END CERTIFICATE-----
  60822. Izenpe.com
  60823. ==========
  60824. -----BEGIN CERTIFICATE-----
  60825. MIIF8TCCA9mgAwIBAgIQALC3WhZIX7/hy/WL1xnmfTANBgkqhkiG9w0BAQsFADA4MQswCQYDVQQG
  60826. EwJFUzEUMBIGA1UECgwLSVpFTlBFIFMuQS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wHhcNMDcxMjEz
  60827. MTMwODI4WhcNMzcxMjEzMDgyNzI1WjA4MQswCQYDVQQGEwJFUzEUMBIGA1UECgwLSVpFTlBFIFMu
  60828. QS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDJ
  60829. 03rKDx6sp4boFmVqscIbRTJxldn+EFvMr+eleQGPicPK8lVx93e+d5TzcqQsRNiekpsUOqHnJJAK
  60830. ClaOxdgmlOHZSOEtPtoKct2jmRXagaKH9HtuJneJWK3W6wyyQXpzbm3benhB6QiIEn6HLmYRY2xU
  60831. +zydcsC8Lv/Ct90NduM61/e0aL6i9eOBbsFGb12N4E3GVFWJGjMxCrFXuaOKmMPsOzTFlUFpfnXC
  60832. PCDFYbpRR6AgkJOhkEvzTnyFRVSa0QUmQbC1TR0zvsQDyCV8wXDbO/QJLVQnSKwv4cSsPsjLkkxT
  60833. OTcj7NMB+eAJRE1NZMDhDVqHIrytG6P+JrUV86f8hBnp7KGItERphIPzidF0BqnMC9bC3ieFUCbK
  60834. F7jJeodWLBoBHmy+E60QrLUk9TiRodZL2vG70t5HtfG8gfZZa88ZU+mNFctKy6lvROUbQc/hhqfK
  60835. 0GqfvEyNBjNaooXlkDWgYlwWTvDjovoDGrQscbNYLN57C9saD+veIR8GdwYDsMnvmfzAuU8Lhij+
  60836. 0rnq49qlw0dpEuDb8PYZi+17cNcC1u2HGCgsBCRMd+RIihrGO5rUD8r6ddIBQFqNeb+Lz0vPqhbB
  60837. leStTIo+F5HUsWLlguWABKQDfo2/2n+iD5dPDNMN+9fR5XJ+HMh3/1uaD7euBUbl8agW7EekFwID
  60838. AQABo4H2MIHzMIGwBgNVHREEgagwgaWBD2luZm9AaXplbnBlLmNvbaSBkTCBjjFHMEUGA1UECgw+
  60839. SVpFTlBFIFMuQS4gLSBDSUYgQTAxMzM3MjYwLVJNZXJjLlZpdG9yaWEtR2FzdGVpeiBUMTA1NSBG
  60840. NjIgUzgxQzBBBgNVBAkMOkF2ZGEgZGVsIE1lZGl0ZXJyYW5lbyBFdG9yYmlkZWEgMTQgLSAwMTAx
  60841. MCBWaXRvcmlhLUdhc3RlaXowDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O
  60842. BBYEFB0cZQ6o8iV7tJHP5LGx5r1VdGwFMA0GCSqGSIb3DQEBCwUAA4ICAQB4pgwWSp9MiDrAyw6l
  60843. Fn2fuUhfGI8NYjb2zRlrrKvV9pF9rnHzP7MOeIWblaQnIUdCSnxIOvVFfLMMjlF4rJUT3sb9fbga
  60844. kEyrkgPH7UIBzg/YsfqikuFgba56awmqxinuaElnMIAkejEWOVt+8Rwu3WwJrfIxwYJOubv5vr8q
  60845. hT/AQKM6WfxZSzwoJNu0FXWuDYi6LnPAvViH5ULy617uHjAimcs30cQhbIHsvm0m5hzkQiCeR7Cs
  60846. g1lwLDXWrzY0tM07+DKo7+N4ifuNRSzanLh+QBxh5z6ikixL8s36mLYp//Pye6kfLqCTVyvehQP5
  60847. aTfLnnhqBbTFMXiJ7HqnheG5ezzevh55hM6fcA5ZwjUukCox2eRFekGkLhObNA5me0mrZJfQRsN5
  60848. nXJQY6aYWwa9SG3YOYNw6DXwBdGqvOPbyALqfP2C2sJbUjWumDqtujWTI6cfSN01RpiyEGjkpTHC
  60849. ClguGYEQyVB1/OpaFs4R1+7vUIgtYf8/QnMFlEPVjjxOAToZpR9GTnfQXeWBIiGH/pR9hNiTrdZo
  60850. Q0iy2+tzJOeRf1SktoA+naM8THLCV8Sg1Mw4J87VBp6iSNnpn86CcDaTmjvfliHjWbcM2pE38P1Z
  60851. WrOZyGlsQyYBNWNgVYkDOnXYukrZVP/u3oDYLdE41V4tC5h9Pmzb/CaIxw==
  60852. -----END CERTIFICATE-----
  60853. Chambers of Commerce Root - 2008
  60854. ================================
  60855. -----BEGIN CERTIFICATE-----
  60856. MIIHTzCCBTegAwIBAgIJAKPaQn6ksa7aMA0GCSqGSIb3DQEBBQUAMIGuMQswCQYDVQQGEwJFVTFD
  60857. MEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNv
  60858. bS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMu
  60859. QS4xKTAnBgNVBAMTIENoYW1iZXJzIG9mIENvbW1lcmNlIFJvb3QgLSAyMDA4MB4XDTA4MDgwMTEy
  60860. Mjk1MFoXDTM4MDczMTEyMjk1MFowga4xCzAJBgNVBAYTAkVVMUMwQQYDVQQHEzpNYWRyaWQgKHNl
  60861. ZSBjdXJyZW50IGFkZHJlc3MgYXQgd3d3LmNhbWVyZmlybWEuY29tL2FkZHJlc3MpMRIwEAYDVQQF
  60862. EwlBODI3NDMyODcxGzAZBgNVBAoTEkFDIENhbWVyZmlybWEgUy5BLjEpMCcGA1UEAxMgQ2hhbWJl
  60863. cnMgb2YgQ29tbWVyY2UgUm9vdCAtIDIwMDgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC
  60864. AQCvAMtwNyuAWko6bHiUfaN/Gh/2NdW928sNRHI+JrKQUrpjOyhYb6WzbZSm891kDFX29ufyIiKA
  60865. XuFixrYp4YFs8r/lfTJqVKAyGVn+H4vXPWCGhSRv4xGzdz4gljUha7MI2XAuZPeEklPWDrCQiorj
  60866. h40G072QDuKZoRuGDtqaCrsLYVAGUvGef3bsyw/QHg3PmTA9HMRFEFis1tPo1+XqxQEHd9ZR5gN/
  60867. ikilTWh1uem8nk4ZcfUyS5xtYBkL+8ydddy/Js2Pk3g5eXNeJQ7KXOt3EgfLZEFHcpOrUMPrCXZk
  60868. NNI5t3YRCQ12RcSprj1qr7V9ZS+UWBDsXHyvfuK2GNnQm05aSd+pZgvMPMZ4fKecHePOjlO+Bd5g
  60869. D2vlGts/4+EhySnB8esHnFIbAURRPHsl18TlUlRdJQfKFiC4reRB7noI/plvg6aRArBsNlVq5331
  60870. lubKgdaX8ZSD6e2wsWsSaR6s+12pxZjptFtYer49okQ6Y1nUCyXeG0+95QGezdIp1Z8XGQpvvwyQ
  60871. 0wlf2eOKNcx5Wk0ZN5K3xMGtr/R5JJqyAQuxr1yW84Ay+1w9mPGgP0revq+ULtlVmhduYJ1jbLhj
  60872. ya6BXBg14JC7vjxPNyK5fuvPnnchpj04gftI2jE9K+OJ9dC1vX7gUMQSibMjmhAxhduub+84Mxh2
  60873. EQIDAQABo4IBbDCCAWgwEgYDVR0TAQH/BAgwBgEB/wIBDDAdBgNVHQ4EFgQU+SSsD7K1+HnA+mCI
  60874. G8TZTQKeFxkwgeMGA1UdIwSB2zCB2IAU+SSsD7K1+HnA+mCIG8TZTQKeFxmhgbSkgbEwga4xCzAJ
  60875. BgNVBAYTAkVVMUMwQQYDVQQHEzpNYWRyaWQgKHNlZSBjdXJyZW50IGFkZHJlc3MgYXQgd3d3LmNh
  60876. bWVyZmlybWEuY29tL2FkZHJlc3MpMRIwEAYDVQQFEwlBODI3NDMyODcxGzAZBgNVBAoTEkFDIENh
  60877. bWVyZmlybWEgUy5BLjEpMCcGA1UEAxMgQ2hhbWJlcnMgb2YgQ29tbWVyY2UgUm9vdCAtIDIwMDiC
  60878. CQCj2kJ+pLGu2jAOBgNVHQ8BAf8EBAMCAQYwPQYDVR0gBDYwNDAyBgRVHSAAMCowKAYIKwYBBQUH
  60879. AgEWHGh0dHA6Ly9wb2xpY3kuY2FtZXJmaXJtYS5jb20wDQYJKoZIhvcNAQEFBQADggIBAJASryI1
  60880. wqM58C7e6bXpeHxIvj99RZJe6dqxGfwWPJ+0W2aeaufDuV2I6A+tzyMP3iU6XsxPpcG1Lawk0lgH
  60881. 3qLPaYRgM+gQDROpI9CF5Y57pp49chNyM/WqfcZjHwj0/gF/JM8rLFQJ3uIrbZLGOU8W6jx+ekbU
  60882. RWpGqOt1glanq6B8aBMz9p0w8G8nOSQjKpD9kCk18pPfNKXG9/jvjA9iSnyu0/VU+I22mlaHFoI6
  60883. M6taIgj3grrqLuBHmrS1RaMFO9ncLkVAO+rcf+g769HsJtg1pDDFOqxXnrN2pSB7+R5KBWIBpih1
  60884. YJeSDW4+TTdDDZIVnBgizVGZoCkaPF+KMjNbMMeJL0eYD6MDxvbxrN8y8NmBGuScvfaAFPDRLLmF
  60885. 9dijscilIeUcE5fuDr3fKanvNFNb0+RqE4QGtjICxFKuItLcsiFCGtpA8CnJ7AoMXOLQusxI0zcK
  60886. zBIKinmwPQN/aUv0NCB9szTqjktk9T79syNnFQ0EuPAtwQlRPLJsFfClI9eDdOTlLsn+mCdCxqvG
  60887. nrDQWzilm1DefhiYtUU79nm06PcaewaD+9CL2rvHvRirCG88gGtAPxkZumWK5r7VXNM21+9AUiRg
  60888. OGcEMeyP84LG3rlV8zsxkVrctQgVrXYlCg17LofiDKYGvCYQbTed7N14jHyAxfDZd0jQ
  60889. -----END CERTIFICATE-----
  60890. Global Chambersign Root - 2008
  60891. ==============================
  60892. -----BEGIN CERTIFICATE-----
  60893. MIIHSTCCBTGgAwIBAgIJAMnN0+nVfSPOMA0GCSqGSIb3DQEBBQUAMIGsMQswCQYDVQQGEwJFVTFD
  60894. MEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNv
  60895. bS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMu
  60896. QS4xJzAlBgNVBAMTHkdsb2JhbCBDaGFtYmVyc2lnbiBSb290IC0gMjAwODAeFw0wODA4MDExMjMx
  60897. NDBaFw0zODA3MzExMjMxNDBaMIGsMQswCQYDVQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUg
  60898. Y3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAGA1UEBRMJ
  60899. QTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMuQS4xJzAlBgNVBAMTHkdsb2JhbCBD
  60900. aGFtYmVyc2lnbiBSb290IC0gMjAwODCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMDf
  60901. VtPkOpt2RbQT2//BthmLN0EYlVJH6xedKYiONWwGMi5HYvNJBL99RDaxccy9Wglz1dmFRP+RVyXf
  60902. XjaOcNFccUMd2drvXNL7G706tcuto8xEpw2uIRU/uXpbknXYpBI4iRmKt4DS4jJvVpyR1ogQC7N0
  60903. ZJJ0YPP2zxhPYLIj0Mc7zmFLmY/CDNBAspjcDahOo7kKrmCgrUVSY7pmvWjg+b4aqIG7HkF4ddPB
  60904. /gBVsIdU6CeQNR1MM62X/JcumIS/LMmjv9GYERTtY/jKmIhYF5ntRQOXfjyGHoiMvvKRhI9lNNgA
  60905. TH23MRdaKXoKGCQwoze1eqkBfSbW+Q6OWfH9GzO1KTsXO0G2Id3UwD2ln58fQ1DJu7xsepeY7s2M
  60906. H/ucUa6LcL0nn3HAa6x9kGbo1106DbDVwo3VyJ2dwW3Q0L9R5OP4wzg2rtandeavhENdk5IMagfe
  60907. Ox2YItaswTXbo6Al/3K1dh3ebeksZixShNBFks4c5eUzHdwHU1SjqoI7mjcv3N2gZOnm3b2u/GSF
  60908. HTynyQbehP9r6GsaPMWis0L7iwk+XwhSx2LE1AVxv8Rk5Pihg+g+EpuoHtQ2TS9x9o0o9oOpE9Jh
  60909. wZG7SMA0j0GMS0zbaRL/UJScIINZc+18ofLx/d33SdNDWKBWY8o9PeU1VlnpDsogzCtLkykPAgMB
  60910. AAGjggFqMIIBZjASBgNVHRMBAf8ECDAGAQH/AgEMMB0GA1UdDgQWBBS5CcqcHtvTbDprru1U8VuT
  60911. BjUuXjCB4QYDVR0jBIHZMIHWgBS5CcqcHtvTbDprru1U8VuTBjUuXqGBsqSBrzCBrDELMAkGA1UE
  60912. BhMCRVUxQzBBBgNVBAcTOk1hZHJpZCAoc2VlIGN1cnJlbnQgYWRkcmVzcyBhdCB3d3cuY2FtZXJm
  60913. aXJtYS5jb20vYWRkcmVzcykxEjAQBgNVBAUTCUE4Mjc0MzI4NzEbMBkGA1UEChMSQUMgQ2FtZXJm
  60914. aXJtYSBTLkEuMScwJQYDVQQDEx5HbG9iYWwgQ2hhbWJlcnNpZ24gUm9vdCAtIDIwMDiCCQDJzdPp
  60915. 1X0jzjAOBgNVHQ8BAf8EBAMCAQYwPQYDVR0gBDYwNDAyBgRVHSAAMCowKAYIKwYBBQUHAgEWHGh0
  60916. dHA6Ly9wb2xpY3kuY2FtZXJmaXJtYS5jb20wDQYJKoZIhvcNAQEFBQADggIBAICIf3DekijZBZRG
  60917. /5BXqfEv3xoNa/p8DhxJJHkn2EaqbylZUohwEurdPfWbU1Rv4WCiqAm57OtZfMY18dwY6fFn5a+6
  60918. ReAJ3spED8IXDneRRXozX1+WLGiLwUePmJs9wOzL9dWCkoQ10b42OFZyMVtHLaoXpGNR6woBrX/s
  60919. dZ7LoR/xfxKxueRkf2fWIyr0uDldmOghp+G9PUIadJpwr2hsUF1Jz//7Dl3mLEfXgTpZALVza2Mg
  60920. 9jFFCDkO9HB+QHBaP9BrQql0PSgvAm11cpUJjUhjxsYjV5KTXjXBjfkK9yydYhz2rXzdpjEetrHH
  60921. foUm+qRqtdpjMNHvkzeyZi99Bffnt0uYlDXA2TopwZ2yUDMdSqlapskD7+3056huirRXhOukP9Du
  60922. qqqHW2Pok+JrqNS4cnhrG+055F3Lm6qH1U9OAP7Zap88MQ8oAgF9mOinsKJknnn4SPIVqczmyETr
  60923. P3iZ8ntxPjzxmKfFGBI/5rsoM0LpRQp8bfKGeS/Fghl9CYl8slR2iK7ewfPM4W7bMdaTrpmg7yVq
  60924. c5iJWzouE4gev8CSlDQb4ye3ix5vQv/n6TebUB0tovkC7stYWDpxvGjjqsGvHCgfotwjZT+B6q6Z
  60925. 09gwzxMNTxXJhLynSC34MCN32EZLeW32jO06f2ARePTpm67VVMB0gNELQp/B
  60926. -----END CERTIFICATE-----
  60927. Go Daddy Root Certificate Authority - G2
  60928. ========================================
  60929. -----BEGIN CERTIFICATE-----
  60930. MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  60931. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoTEUdvRGFkZHkuY29tLCBJbmMu
  60932. MTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5
  60933. MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6
  60934. b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8G
  60935. A1UEAxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZI
  60936. hvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKDE6bFIEMBO4Tx5oVJnyfq
  60937. 9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH/PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD
  60938. +qK+ihVqf94Lw7YZFAXK6sOoBJQ7RnwyDfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutd
  60939. fMh8+7ArU6SSYmlRJQVhGkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMl
  60940. NAJWJwGRtDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEAAaNC
  60941. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFDqahQcQZyi27/a9
  60942. BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmXWWcDYfF+OwYxdS2hII5PZYe096ac
  60943. vNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r
  60944. 5N9ss4UXnT3ZJE95kTXWXwTrgIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYV
  60945. N8Gb5DKj7Tjo2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO
  60946. LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI4uJEvlz36hz1
  60947. -----END CERTIFICATE-----
  60948. Starfield Root Certificate Authority - G2
  60949. =========================================
  60950. -----BEGIN CERTIFICATE-----
  60951. MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  60952. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s
  60953. b2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVsZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0
  60954. eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAw
  60955. DgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQg
  60956. VGVjaG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZpY2F0ZSBB
  60957. dXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL3twQP89o/8ArFv
  60958. W59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMgnLRJdzIpVv257IzdIvpy3Cdhl+72WoTs
  60959. bhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNk
  60960. N3mSwOxGXn/hbVNMYq/NHwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7Nf
  60961. ZTD4p7dNdloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0HZbU
  60962. JtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  60963. AQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0GCSqGSIb3DQEBCwUAA4IBAQARWfol
  60964. TwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjUsHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx
  60965. 4mcujJUDJi5DnUox9g61DLu34jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUw
  60966. F5okxBDgBPfg8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K
  60967. pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1mMpYjn0q7pBZ
  60968. c2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0
  60969. -----END CERTIFICATE-----
  60970. Starfield Services Root Certificate Authority - G2
  60971. ==================================================
  60972. -----BEGIN CERTIFICATE-----
  60973. MIID7zCCAtegAwIBAgIBADANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  60974. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s
  60975. b2dpZXMsIEluYy4xOzA5BgNVBAMTMlN0YXJmaWVsZCBTZXJ2aWNlcyBSb290IENlcnRpZmljYXRl
  60976. IEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgZgxCzAJBgNV
  60977. BAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxT
  60978. dGFyZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTswOQYDVQQDEzJTdGFyZmllbGQgU2VydmljZXMg
  60979. Um9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
  60980. AQoCggEBANUMOsQq+U7i9b4Zl1+OiFOxHz/Lz58gE20pOsgPfTz3a3Y4Y9k2YKibXlwAgLIvWX/2
  60981. h/klQ4bnaRtSmpDhcePYLQ1Ob/bISdm28xpWriu2dBTrz/sm4xq6HZYuajtYlIlHVv8loJNwU4Pa
  60982. hHQUw2eeBGg6345AWh1KTs9DkTvnVtYAcMtS7nt9rjrnvDH5RfbCYM8TWQIrgMw0R9+53pBlbQLP
  60983. LJGmpufehRhJfGZOozptqbXuNC66DQO4M99H67FrjSXZm86B0UVGMpZwh94CDklDhbZsc7tk6mFB
  60984. rMnUVN+HL8cisibMn1lUaJ/8viovxFUcdUBgF4UCVTmLfwUCAwEAAaNCMEAwDwYDVR0TAQH/BAUw
  60985. AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJxfAN+qAdcwKziIorhtSpzyEZGDMA0GCSqG
  60986. SIb3DQEBCwUAA4IBAQBLNqaEd2ndOxmfZyMIbw5hyf2E3F/YNoHN2BtBLZ9g3ccaaNnRbobhiCPP
  60987. E95Dz+I0swSdHynVv/heyNXBve6SbzJ08pGCL72CQnqtKrcgfU28elUSwhXqvfdqlS5sdJ/PHLTy
  60988. xQGjhdByPq1zqwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd
  60989. iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn0q23KXB56jza
  60990. YyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCNsSi6
  60991. -----END CERTIFICATE-----
  60992. AffirmTrust Commercial
  60993. ======================
  60994. -----BEGIN CERTIFICATE-----
  60995. MIIDTDCCAjSgAwIBAgIId3cGJyapsXwwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UEBhMCVVMxFDAS
  60996. BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMB4XDTEw
  60997. MDEyOTE0MDYwNloXDTMwMTIzMTE0MDYwNlowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly
  60998. bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMIIBIjANBgkqhkiG9w0BAQEF
  60999. AAOCAQ8AMIIBCgKCAQEA9htPZwcroRX1BiLLHwGy43NFBkRJLLtJJRTWzsO3qyxPxkEylFf6Eqdb
  61000. DuKPHx6GGaeqtS25Xw2Kwq+FNXkyLbscYjfysVtKPcrNcV/pQr6U6Mje+SJIZMblq8Yrba0F8PrV
  61001. C8+a5fBQpIs7R6UjW3p6+DM/uO+Zl+MgwdYoic+U+7lF7eNAFxHUdPALMeIrJmqbTFeurCA+ukV6
  61002. BfO9m2kVrn1OIGPENXY6BwLJN/3HR+7o8XYdcxXyl6S1yHp52UKqK39c/s4mT6NmgTWvRLpUHhww
  61003. MmWd5jyTXlBOeuM61G7MGvv50jeuJCqrVwMiKA1JdX+3KNp1v47j3A55MQIDAQABo0IwQDAdBgNV
  61004. HQ4EFgQUnZPGU4teyq8/nx4P5ZmVvCT2lI8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  61005. AQYwDQYJKoZIhvcNAQELBQADggEBAFis9AQOzcAN/wr91LoWXym9e2iZWEnStB03TX8nfUYGXUPG
  61006. hi4+c7ImfU+TqbbEKpqrIZcUsd6M06uJFdhrJNTxFq7YpFzUf1GO7RgBsZNjvbz4YYCanrHOQnDi
  61007. qX0GJX0nof5v7LMeJNrjS1UaADs1tDvZ110w/YETifLCBivtZ8SOyUOyXGsViQK8YvxO8rUzqrJv
  61008. 0wqiUOP2O+guRMLbZjipM1ZI8W0bM40NjD9gN53Tym1+NH4Nn3J2ixufcv1SNUFFApYvHLKac0kh
  61009. sUlHRUe072o0EclNmsxZt9YCnlpOZbWUrhvfKbAW8b8Angc6F2S1BLUjIZkKlTuXfO8=
  61010. -----END CERTIFICATE-----
  61011. AffirmTrust Networking
  61012. ======================
  61013. -----BEGIN CERTIFICATE-----
  61014. MIIDTDCCAjSgAwIBAgIIfE8EORzUmS0wDQYJKoZIhvcNAQEFBQAwRDELMAkGA1UEBhMCVVMxFDAS
  61015. BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMB4XDTEw
  61016. MDEyOTE0MDgyNFoXDTMwMTIzMTE0MDgyNFowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly
  61017. bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMIIBIjANBgkqhkiG9w0BAQEF
  61018. AAOCAQ8AMIIBCgKCAQEAtITMMxcua5Rsa2FSoOujz3mUTOWUgJnLVWREZY9nZOIG41w3SfYvm4SE
  61019. Hi3yYJ0wTsyEheIszx6e/jarM3c1RNg1lho9Nuh6DtjVR6FqaYvZ/Ls6rnla1fTWcbuakCNrmreI
  61020. dIcMHl+5ni36q1Mr3Lt2PpNMCAiMHqIjHNRqrSK6mQEubWXLviRmVSRLQESxG9fhwoXA3hA/Pe24
  61021. /PHxI1Pcv2WXb9n5QHGNfb2V1M6+oF4nI979ptAmDgAp6zxG8D1gvz9Q0twmQVGeFDdCBKNwV6gb
  61022. h+0t+nvujArjqWaJGctB+d1ENmHP4ndGyH329JKBNv3bNPFyfvMMFr20FQIDAQABo0IwQDAdBgNV
  61023. HQ4EFgQUBx/S55zawm6iQLSwelAQUHTEyL0wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  61024. AQYwDQYJKoZIhvcNAQEFBQADggEBAIlXshZ6qML91tmbmzTCnLQyFE2npN/svqe++EPbkTfOtDIu
  61025. UFUaNU52Q3Eg75N3ThVwLofDwR1t3Mu1J9QsVtFSUzpE0nPIxBsFZVpikpzuQY0x2+c06lkh1QF6
  61026. 12S4ZDnNye2v7UsDSKegmQGA3GWjNq5lWUhPgkvIZfFXHeVZLgo/bNjR9eUJtGxUAArgFU2HdW23
  61027. WJZa3W3SAKD0m0i+wzekujbgfIeFlxoVot4uolu9rxj5kFDNcFn4J2dHy8egBzp90SxdbBk6ZrV9
  61028. /ZFvgrG+CJPbFEfxojfHRZ48x3evZKiT3/Zpg4Jg8klCNO1aAFSFHBY2kgxc+qatv9s=
  61029. -----END CERTIFICATE-----
  61030. AffirmTrust Premium
  61031. ===================
  61032. -----BEGIN CERTIFICATE-----
  61033. MIIFRjCCAy6gAwIBAgIIbYwURrGmCu4wDQYJKoZIhvcNAQEMBQAwQTELMAkGA1UEBhMCVVMxFDAS
  61034. BgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMB4XDTEwMDEy
  61035. OTE0MTAzNloXDTQwMTIzMTE0MTAzNlowQTELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRy
  61036. dXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  61037. MIICCgKCAgEAxBLfqV/+Qd3d9Z+K4/as4Tx4mrzY8H96oDMq3I0gW64tb+eT2TZwamjPjlGjhVtn
  61038. BKAQJG9dKILBl1fYSCkTtuG+kU3fhQxTGJoeJKJPj/CihQvL9Cl/0qRY7iZNyaqoe5rZ+jjeRFcV
  61039. 5fiMyNlI4g0WJx0eyIOFJbe6qlVBzAMiSy2RjYvmia9mx+n/K+k8rNrSs8PhaJyJ+HoAVt70VZVs
  61040. +7pk3WKL3wt3MutizCaam7uqYoNMtAZ6MMgpv+0GTZe5HMQxK9VfvFMSF5yZVylmd2EhMQcuJUmd
  61041. GPLu8ytxjLW6OQdJd/zvLpKQBY0tL3d770O/Nbua2Plzpyzy0FfuKE4mX4+QaAkvuPjcBukumj5R
  61042. p9EixAqnOEhss/n/fauGV+O61oV4d7pD6kh/9ti+I20ev9E2bFhc8e6kGVQa9QPSdubhjL08s9NI
  61043. S+LI+H+SqHZGnEJlPqQewQcDWkYtuJfzt9WyVSHvutxMAJf7FJUnM7/oQ0dG0giZFmA7mn7S5u04
  61044. 6uwBHjxIVkkJx0w3AJ6IDsBz4W9m6XJHMD4Q5QsDyZpCAGzFlH5hxIrff4IaC1nEWTJ3s7xgaVY5
  61045. /bQGeyzWZDbZvUjthB9+pSKPKrhC9IK31FOQeE4tGv2Bb0TXOwF0lkLgAOIua+rF7nKsu7/+6qqo
  61046. +Nz2snmKtmcCAwEAAaNCMEAwHQYDVR0OBBYEFJ3AZ6YMItkm9UWrpmVSESfYRaxjMA8GA1UdEwEB
  61047. /wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBDAUAA4ICAQCzV00QYk465KzquByv
  61048. MiPIs0laUZx2KI15qldGF9X1Uva3ROgIRL8YhNILgM3FEv0AVQVhh0HctSSePMTYyPtwni94loMg
  61049. Nt58D2kTiKV1NpgIpsbfrM7jWNa3Pt668+s0QNiigfV4Py/VpfzZotReBA4Xrf5B8OWycvpEgjNC
  61050. 6C1Y91aMYj+6QrCcDFx+LmUmXFNPALJ4fqENmS2NuB2OosSw/WDQMKSOyARiqcTtNd56l+0OOF6S
  61051. L5Nwpamcb6d9Ex1+xghIsV5n61EIJenmJWtSKZGc0jlzCFfemQa0W50QBuHCAKi4HEoCChTQwUHK
  61052. +4w1IX2COPKpVJEZNZOUbWo6xbLQu4mGk+ibyQ86p3q4ofB4Rvr8Ny/lioTz3/4E2aFooC8k4gmV
  61053. BtWVyuEklut89pMFu+1z6S3RdTnX5yTb2E5fQ4+e0BQ5v1VwSJlXMbSc7kqYA5YwH2AG7hsj/oFg
  61054. IxpHYoWlzBk0gG+zrBrjn/B7SK3VAdlntqlyk+otZrWyuOQ9PLLvTIzq6we/qzWaVYa8GKa1qF60
  61055. g2xraUDTn9zxw2lrueFtCfTxqlB2Cnp9ehehVZZCmTEJ3WARjQUwfuaORtGdFNrHF+QFlozEJLUb
  61056. zxQHskD4o55BhrwE0GuWyCqANP2/7waj3VjFhT0+j/6eKeC2uAloGRwYQw==
  61057. -----END CERTIFICATE-----
  61058. AffirmTrust Premium ECC
  61059. =======================
  61060. -----BEGIN CERTIFICATE-----
  61061. MIIB/jCCAYWgAwIBAgIIdJclisc/elQwCgYIKoZIzj0EAwMwRTELMAkGA1UEBhMCVVMxFDASBgNV
  61062. BAoMC0FmZmlybVRydXN0MSAwHgYDVQQDDBdBZmZpcm1UcnVzdCBQcmVtaXVtIEVDQzAeFw0xMDAx
  61063. MjkxNDIwMjRaFw00MDEyMzExNDIwMjRaMEUxCzAJBgNVBAYTAlVTMRQwEgYDVQQKDAtBZmZpcm1U
  61064. cnVzdDEgMB4GA1UEAwwXQWZmaXJtVHJ1c3QgUHJlbWl1bSBFQ0MwdjAQBgcqhkjOPQIBBgUrgQQA
  61065. IgNiAAQNMF4bFZ0D0KF5Nbc6PJJ6yhUczWLznCZcBz3lVPqj1swS6vQUX+iOGasvLkjmrBhDeKzQ
  61066. N8O9ss0s5kfiGuZjuD0uL3jET9v0D6RoTFVya5UdThhClXjMNzyR4ptlKymjQjBAMB0GA1UdDgQW
  61067. BBSaryl6wBE1NSZRMADDav5A1a7WPDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAK
  61068. BggqhkjOPQQDAwNnADBkAjAXCfOHiFBar8jAQr9HX/VsaobgxCd05DhT1wV/GzTjxi+zygk8N53X
  61069. 57hG8f2h4nECMEJZh0PUUd+60wkyWs6Iflc9nF9Ca/UHLbXwgpP5WW+uZPpY5Yse42O+tYHNbwKM
  61070. eQ==
  61071. -----END CERTIFICATE-----
  61072. Certum Trusted Network CA
  61073. =========================
  61074. -----BEGIN CERTIFICATE-----
  61075. MIIDuzCCAqOgAwIBAgIDBETAMA0GCSqGSIb3DQEBBQUAMH4xCzAJBgNVBAYTAlBMMSIwIAYDVQQK
  61076. ExlVbml6ZXRvIFRlY2hub2xvZ2llcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlv
  61077. biBBdXRob3JpdHkxIjAgBgNVBAMTGUNlcnR1bSBUcnVzdGVkIE5ldHdvcmsgQ0EwHhcNMDgxMDIy
  61078. MTIwNzM3WhcNMjkxMjMxMTIwNzM3WjB+MQswCQYDVQQGEwJQTDEiMCAGA1UEChMZVW5pemV0byBU
  61079. ZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  61080. MSIwIAYDVQQDExlDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENBMIIBIjANBgkqhkiG9w0BAQEFAAOC
  61081. AQ8AMIIBCgKCAQEA4/t9o3K6wvDJFIf1awFO4W5AB7ptJ11/91sts1rHUV+rpDKmYYe2bg+G0jAC
  61082. l/jXaVehGDldamR5xgFZrDwxSjh80gTSSyjoIF87B6LMTXPb865Px1bVWqeWifrzq2jUI4ZZJ88J
  61083. J7ysbnKDHDBy3+Ci6dLhdHUZvSqeexVUBBvXQzmtVSjF4hq79MDkrjhJM8x2hZ85RdKknvISjFH4
  61084. fOQtf/WsX+sWn7Et0brMkUJ3TCXJkDhv2/DM+44el1k+1WBO5gUo7Ul5E0u6SNsv+XLTOcr+H9g0
  61085. cvW0QM8xAcPs3hEtF10fuFDRXhmnad4HMyjKUJX5p1TLVIZQRan5SQIDAQABo0IwQDAPBgNVHRMB
  61086. Af8EBTADAQH/MB0GA1UdDgQWBBQIds3LB/8k9sXN7buQvOKEN0Z19zAOBgNVHQ8BAf8EBAMCAQYw
  61087. DQYJKoZIhvcNAQEFBQADggEBAKaorSLOAT2mo/9i0Eidi15ysHhE49wcrwn9I0j6vSrEuVUEtRCj
  61088. jSfeC4Jj0O7eDDd5QVsisrCaQVymcODU0HfLI9MA4GxWL+FpDQ3Zqr8hgVDZBqWo/5U30Kr+4rP1
  61089. mS1FhIrlQgnXdAIv94nYmem8J9RHjboNRhx3zxSkHLmkMcScKHQDNP8zGSal6Q10tz6XxnboJ5aj
  61090. Zt3hrvJBW8qYVoNzcOSGGtIxQbovvi0TWnZvTuhOgQ4/WwMioBK+ZlgRSssDxLQqKi2WF+A5VLxI
  61091. 03YnnZotBqbJ7DnSq9ufmgsnAjUpsUCV5/nonFWIGUbWtzT1fs45mtk48VH3Tyw=
  61092. -----END CERTIFICATE-----
  61093. TWCA Root Certification Authority
  61094. =================================
  61095. -----BEGIN CERTIFICATE-----
  61096. MIIDezCCAmOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJUVzESMBAGA1UECgwJ
  61097. VEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NBIFJvb3QgQ2VydGlmaWNh
  61098. dGlvbiBBdXRob3JpdHkwHhcNMDgwODI4MDcyNDMzWhcNMzAxMjMxMTU1OTU5WjBfMQswCQYDVQQG
  61099. EwJUVzESMBAGA1UECgwJVEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NB
  61100. IFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
  61101. AoIBAQCwfnK4pAOU5qfeCTiRShFAh6d8WWQUe7UREN3+v9XAu1bihSX0NXIP+FPQQeFEAcK0HMMx
  61102. QhZHhTMidrIKbw/lJVBPhYa+v5guEGcevhEFhgWQxFnQfHgQsIBct+HHK3XLfJ+utdGdIzdjp9xC
  61103. oi2SBBtQwXu4PhvJVgSLL1KbralW6cH/ralYhzC2gfeXRfwZVzsrb+RH9JlF/h3x+JejiB03HFyP
  61104. 4HYlmlD4oFT/RJB2I9IyxsOrBr/8+7/zrX2SYgJbKdM1o5OaQ2RgXbL6Mv87BK9NQGr5x+PvI/1r
  61105. y+UPizgN7gr8/g+YnzAx3WxSZfmLgb4i4RxYA7qRG4kHAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIB
  61106. BjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqOFsmjd6LWvJPelSDGRjjCDWmujANBgkqhkiG
  61107. 9w0BAQUFAAOCAQEAPNV3PdrfibqHDAhUaiBQkr6wQT25JmSDCi/oQMCXKCeCMErJk/9q56YAf4lC
  61108. mtYR5VPOL8zy2gXE/uJQxDqGfczafhAJO5I1KlOy/usrBdlsXebQ79NqZp4VKIV66IIArB6nCWlW
  61109. QtNoURi+VJq/REG6Sb4gumlc7rh3zc5sH62Dlhh9DrUUOYTxKOkto557HnpyWoOzeW/vtPzQCqVY
  61110. T0bf+215WfKEIlKuD8z7fDvnaspHYcN6+NOSBB+4IIThNlQWx0DeO4pz3N/GCUzf7Nr/1FNCocny
  61111. Yh0igzyXxfkZYiesZSLX0zzG5Y6yU8xJzrww/nsOM5D77dIUkR8Hrw==
  61112. -----END CERTIFICATE-----
  61113. Security Communication RootCA2
  61114. ==============================
  61115. -----BEGIN CERTIFICATE-----
  61116. MIIDdzCCAl+gAwIBAgIBADANBgkqhkiG9w0BAQsFADBdMQswCQYDVQQGEwJKUDElMCMGA1UEChMc
  61117. U0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEnMCUGA1UECxMeU2VjdXJpdHkgQ29tbXVuaWNh
  61118. dGlvbiBSb290Q0EyMB4XDTA5MDUyOTA1MDAzOVoXDTI5MDUyOTA1MDAzOVowXTELMAkGA1UEBhMC
  61119. SlAxJTAjBgNVBAoTHFNFQ09NIFRydXN0IFN5c3RlbXMgQ08uLExURC4xJzAlBgNVBAsTHlNlY3Vy
  61120. aXR5IENvbW11bmljYXRpb24gUm9vdENBMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  61121. ANAVOVKxUrO6xVmCxF1SrjpDZYBLx/KWvNs2l9amZIyoXvDjChz335c9S672XewhtUGrzbl+dp++
  61122. +T42NKA7wfYxEUV0kz1XgMX5iZnK5atq1LXaQZAQwdbWQonCv/Q4EpVMVAX3NuRFg3sUZdbcDE3R
  61123. 3n4MqzvEFb46VqZab3ZpUql6ucjrappdUtAtCms1FgkQhNBqyjoGADdH5H5XTz+L62e4iKrFvlNV
  61124. spHEfbmwhRkGeC7bYRr6hfVKkaHnFtWOojnflLhwHyg/i/xAXmODPIMqGplrz95Zajv8bxbXH/1K
  61125. EOtOghY6rCcMU/Gt1SSwawNQwS08Ft1ENCcadfsCAwEAAaNCMEAwHQYDVR0OBBYEFAqFqXdlBZh8
  61126. QIH4D5csOPEK7DzPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEB
  61127. CwUAA4IBAQBMOqNErLlFsceTfsgLCkLfZOoc7llsCLqJX2rKSpWeeo8HxdpFcoJxDjrSzG+ntKEj
  61128. u/Ykn8sX/oymzsLS28yN/HH8AynBbF0zX2S2ZTuJbxh2ePXcokgfGT+Ok+vx+hfuzU7jBBJV1uXk
  61129. 3fs+BXziHV7Gp7yXT2g69ekuCkO2r1dcYmh8t/2jioSgrGK+KwmHNPBqAbubKVY8/gA3zyNs8U6q
  61130. tnRGEmyR7jTV7JqR50S+kDFy1UkC9gLl9B/rfNmWVan/7Ir5mUf/NVoCqgTLiluHcSmRvaS0eg29
  61131. mvVXIwAHIRc/SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03
  61132. -----END CERTIFICATE-----
  61133. EC-ACC
  61134. ======
  61135. -----BEGIN CERTIFICATE-----
  61136. MIIFVjCCBD6gAwIBAgIQ7is969Qh3hSoYqwE893EATANBgkqhkiG9w0BAQUFADCB8zELMAkGA1UE
  61137. BhMCRVMxOzA5BgNVBAoTMkFnZW5jaWEgQ2F0YWxhbmEgZGUgQ2VydGlmaWNhY2lvIChOSUYgUS0w
  61138. ODAxMTc2LUkpMSgwJgYDVQQLEx9TZXJ2ZWlzIFB1YmxpY3MgZGUgQ2VydGlmaWNhY2lvMTUwMwYD
  61139. VQQLEyxWZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5ldC92ZXJhcnJlbCAoYykwMzE1MDMGA1UE
  61140. CxMsSmVyYXJxdWlhIEVudGl0YXRzIGRlIENlcnRpZmljYWNpbyBDYXRhbGFuZXMxDzANBgNVBAMT
  61141. BkVDLUFDQzAeFw0wMzAxMDcyMzAwMDBaFw0zMTAxMDcyMjU5NTlaMIHzMQswCQYDVQQGEwJFUzE7
  61142. MDkGA1UEChMyQWdlbmNpYSBDYXRhbGFuYSBkZSBDZXJ0aWZpY2FjaW8gKE5JRiBRLTA4MDExNzYt
  61143. SSkxKDAmBgNVBAsTH1NlcnZlaXMgUHVibGljcyBkZSBDZXJ0aWZpY2FjaW8xNTAzBgNVBAsTLFZl
  61144. Z2V1IGh0dHBzOi8vd3d3LmNhdGNlcnQubmV0L3ZlcmFycmVsIChjKTAzMTUwMwYDVQQLEyxKZXJh
  61145. cnF1aWEgRW50aXRhdHMgZGUgQ2VydGlmaWNhY2lvIENhdGFsYW5lczEPMA0GA1UEAxMGRUMtQUND
  61146. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsyLHT+KXQpWIR4NA9h0X84NzJB5R85iK
  61147. w5K4/0CQBXCHYMkAqbWUZRkiFRfCQ2xmRJoNBD45b6VLeqpjt4pEndljkYRm4CgPukLjbo73FCeT
  61148. ae6RDqNfDrHrZqJyTxIThmV6PttPB/SnCWDaOkKZx7J/sxaVHMf5NLWUhdWZXqBIoH7nF2W4onW4
  61149. HvPlQn2v7fOKSGRdghST2MDk/7NQcvJ29rNdQlB50JQ+awwAvthrDk4q7D7SzIKiGGUzE3eeml0a
  61150. E9jD2z3Il3rucO2n5nzbcc8tlGLfbdb1OL4/pYUKGbio2Al1QnDE6u/LDsg0qBIimAy4E5S2S+zw
  61151. 0JDnJwIDAQABo4HjMIHgMB0GA1UdEQQWMBSBEmVjX2FjY0BjYXRjZXJ0Lm5ldDAPBgNVHRMBAf8E
  61152. BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUoMOLRKo3pUW/l4Ba0fF4opvpXY0wfwYD
  61153. VR0gBHgwdjB0BgsrBgEEAfV4AQMBCjBlMCwGCCsGAQUFBwIBFiBodHRwczovL3d3dy5jYXRjZXJ0
  61154. Lm5ldC92ZXJhcnJlbDA1BggrBgEFBQcCAjApGidWZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5l
  61155. dC92ZXJhcnJlbCAwDQYJKoZIhvcNAQEFBQADggEBAKBIW4IB9k1IuDlVNZyAelOZ1Vr/sXE7zDkJ
  61156. lF7W2u++AVtd0x7Y/X1PzaBB4DSTv8vihpw3kpBWHNzrKQXlxJ7HNd+KDM3FIUPpqojlNcAZQmNa
  61157. Al6kSBg6hW/cnbw/nZzBh7h6YQjpdwt/cKt63dmXLGQehb+8dJahw3oS7AwaboMMPOhyRp/7SNVe
  61158. l+axofjk70YllJyJ22k4vuxcDlbHZVHlUIiIv0LVKz3l+bqeLrPK9HOSAgu+TGbrIP65y7WZf+a2
  61159. E/rKS03Z7lNGBjvGTq2TWoF+bCpLagVFjPIhpDGQh2xlnJ2lYJU6Un/10asIbvPuW/mIPX64b24D
  61160. 5EI=
  61161. -----END CERTIFICATE-----
  61162. Hellenic Academic and Research Institutions RootCA 2011
  61163. =======================================================
  61164. -----BEGIN CERTIFICATE-----
  61165. MIIEMTCCAxmgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBlTELMAkGA1UEBhMCR1IxRDBCBgNVBAoT
  61166. O0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9y
  61167. aXR5MUAwPgYDVQQDEzdIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25z
  61168. IFJvb3RDQSAyMDExMB4XDTExMTIwNjEzNDk1MloXDTMxMTIwMTEzNDk1MlowgZUxCzAJBgNVBAYT
  61169. AkdSMUQwQgYDVQQKEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25z
  61170. IENlcnQuIEF1dGhvcml0eTFAMD4GA1UEAxM3SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNo
  61171. IEluc3RpdHV0aW9ucyBSb290Q0EgMjAxMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  61172. AKlTAOMupvaO+mDYLZU++CwqVE7NuYRhlFhPjz2L5EPzdYmNUeTDN9KKiE15HrcS3UN4SoqS5tdI
  61173. 1Q+kOilENbgH9mgdVc04UfCMJDGFr4PJfel3r+0ae50X+bOdOFAPplp5kYCvN66m0zH7tSYJnTxa
  61174. 71HFK9+WXesyHgLacEnsbgzImjeN9/E2YEsmLIKe0HjzDQ9jpFEw4fkrJxIH2Oq9GGKYsFk3fb7u
  61175. 8yBRQlqD75O6aRXxYp2fmTmCobd0LovUxQt7L/DICto9eQqakxylKHJzkUOap9FNhYS5qXSPFEDH
  61176. 3N6sQWRstBmbAmNtJGSPRLIl6s5ddAxjMlyNh+UCAwEAAaOBiTCBhjAPBgNVHRMBAf8EBTADAQH/
  61177. MAsGA1UdDwQEAwIBBjAdBgNVHQ4EFgQUppFC/RNhSiOeCKQp5dgTBCPuQSUwRwYDVR0eBEAwPqA8
  61178. MAWCAy5ncjAFggMuZXUwBoIELmVkdTAGggQub3JnMAWBAy5ncjAFgQMuZXUwBoEELmVkdTAGgQQu
  61179. b3JnMA0GCSqGSIb3DQEBBQUAA4IBAQAf73lB4XtuP7KMhjdCSk4cNx6NZrokgclPEg8hwAOXhiVt
  61180. XdMiKahsog2p6z0GW5k6x8zDmjR/qw7IThzh+uTczQ2+vyT+bOdrwg3IBp5OjWEopmr95fZi6hg8
  61181. TqBTnbI6nOulnJEWtk2C4AwFSKls9cz4y51JtPACpf1wA+2KIaWuE4ZJwzNzvoc7dIsXRSZMFpGD
  61182. /md9zU1jZ/rzAxKWeAaNsWftjj++n08C9bMJL/NMh98qy5V8AcysNnq/onN694/BtZqhFLKPM58N
  61183. 7yLcZnuEvUUXBj08yrl3NI/K6s8/MT7jiOOASSXIl7WdmplNsDz4SgCbZN2fOUvRJ9e4
  61184. -----END CERTIFICATE-----
  61185. Actalis Authentication Root CA
  61186. ==============================
  61187. -----BEGIN CERTIFICATE-----
  61188. MIIFuzCCA6OgAwIBAgIIVwoRl0LE48wwDQYJKoZIhvcNAQELBQAwazELMAkGA1UEBhMCSVQxDjAM
  61189. BgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UE
  61190. AwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290IENBMB4XDTExMDkyMjExMjIwMloXDTMwMDky
  61191. MjExMjIwMlowazELMAkGA1UEBhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlz
  61192. IFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290
  61193. IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAp8bEpSmkLO/lGMWwUKNvUTufClrJ
  61194. wkg4CsIcoBh/kbWHuUA/3R1oHwiD1S0eiKD4j1aPbZkCkpAW1V8IbInX4ay8IMKx4INRimlNAJZa
  61195. by/ARH6jDuSRzVju3PvHHkVH3Se5CAGfpiEd9UEtL0z9KK3giq0itFZljoZUj5NDKd45RnijMCO6
  61196. zfB9E1fAXdKDa0hMxKufgFpbOr3JpyI/gCczWw63igxdBzcIy2zSekciRDXFzMwujt0q7bd9Zg1f
  61197. YVEiVRvjRuPjPdA1YprbrxTIW6HMiRvhMCb8oJsfgadHHwTrozmSBp+Z07/T6k9QnBn+locePGX2
  61198. oxgkg4YQ51Q+qDp2JE+BIcXjDwL4k5RHILv+1A7TaLndxHqEguNTVHnd25zS8gebLra8Pu2Fbe8l
  61199. EfKXGkJh90qX6IuxEAf6ZYGyojnP9zz/GPvG8VqLWeICrHuS0E4UT1lF9gxeKF+w6D9Fz8+vm2/7
  61200. hNN3WpVvrJSEnu68wEqPSpP4RCHiMUVhUE4Q2OM1fEwZtN4Fv6MGn8i1zeQf1xcGDXqVdFUNaBr8
  61201. EBtiZJ1t4JWgw5QHVw0U5r0F+7if5t+L4sbnfpb2U8WANFAoWPASUHEXMLrmeGO89LKtmyuy/uE5
  61202. jF66CyCU3nuDuP/jVo23Eek7jPKxwV2dpAtMK9myGPW1n0sCAwEAAaNjMGEwHQYDVR0OBBYEFFLY
  61203. iDrIn3hm7YnzezhwlMkCAjbQMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUUtiIOsifeGbt
  61204. ifN7OHCUyQICNtAwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBCwUAA4ICAQALe3KHwGCmSUyI
  61205. WOYdiPcUZEim2FgKDk8TNd81HdTtBjHIgT5q1d07GjLukD0R0i70jsNjLiNmsGe+b7bAEzlgqqI0
  61206. JZN1Ut6nna0Oh4lScWoWPBkdg/iaKWW+9D+a2fDzWochcYBNy+A4mz+7+uAwTc+G02UQGRjRlwKx
  61207. K3JCaKygvU5a2hi/a5iB0P2avl4VSM0RFbnAKVy06Ij3Pjaut2L9HmLecHgQHEhb2rykOLpn7VU+
  61208. Xlff1ANATIGk0k9jpwlCCRT8AKnCgHNPLsBA2RF7SOp6AsDT6ygBJlh0wcBzIm2Tlf05fbsq4/aC
  61209. 4yyXX04fkZT6/iyj2HYauE2yOE+b+h1IYHkm4vP9qdCa6HCPSXrW5b0KDtst842/6+OkfcvHlXHo
  61210. 2qN8xcL4dJIEG4aspCJTQLas/kx2z/uUMsA1n3Y/buWQbqCmJqK4LL7RK4X9p2jIugErsWx0Hbhz
  61211. lefut8cl8ABMALJ+tguLHPPAUJ4lueAI3jZm/zel0btUZCzJJ7VLkn5l/9Mt4blOvH+kQSGQQXem
  61212. OR/qnuOf0GZvBeyqdn6/axag67XH/JJULysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9
  61213. vwGYT7JZVEc+NHt4bVaTLnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg==
  61214. -----END CERTIFICATE-----
  61215. Trustis FPS Root CA
  61216. ===================
  61217. -----BEGIN CERTIFICATE-----
  61218. MIIDZzCCAk+gAwIBAgIQGx+ttiD5JNM2a/fH8YygWTANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQG
  61219. EwJHQjEYMBYGA1UEChMPVHJ1c3RpcyBMaW1pdGVkMRwwGgYDVQQLExNUcnVzdGlzIEZQUyBSb290
  61220. IENBMB4XDTAzMTIyMzEyMTQwNloXDTI0MDEyMTExMzY1NFowRTELMAkGA1UEBhMCR0IxGDAWBgNV
  61221. BAoTD1RydXN0aXMgTGltaXRlZDEcMBoGA1UECxMTVHJ1c3RpcyBGUFMgUm9vdCBDQTCCASIwDQYJ
  61222. KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMVQe547NdDfxIzNjpvto8A2mfRC6qc+gIMPpqdZh8mQ
  61223. RUN+AOqGeSoDvT03mYlmt+WKVoaTnGhLaASMk5MCPjDSNzoiYYkchU59j9WvezX2fihHiTHcDnlk
  61224. H5nSW7r+f2C/revnPDgpai/lkQtV/+xvWNUtyd5MZnGPDNcE2gfmHhjjvSkCqPoc4Vu5g6hBSLwa
  61225. cY3nYuUtsuvffM/bq1rKMfFMIvMFE/eC+XN5DL7XSxzA0RU8k0Fk0ea+IxciAIleH2ulrG6nS4zt
  61226. o3Lmr2NNL4XSFDWaLk6M6jKYKIahkQlBOrTh4/L68MkKokHdqeMDx4gVOxzUGpTXn2RZEm0CAwEA
  61227. AaNTMFEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBS6+nEleYtXQSUhhgtx67JkDoshZzAd
  61228. BgNVHQ4EFgQUuvpxJXmLV0ElIYYLceuyZA6LIWcwDQYJKoZIhvcNAQEFBQADggEBAH5Y//01GX2c
  61229. GE+esCu8jowU/yyg2kdbw++BLa8F6nRIW/M+TgfHbcWzk88iNVy2P3UnXwmWzaD+vkAMXBJV+JOC
  61230. yinpXj9WV4s4NvdFGkwozZ5BuO1WTISkQMi4sKUraXAEasP41BIy+Q7DsdwyhEQsb8tGD+pmQQ9P
  61231. 8Vilpg0ND2HepZ5dfWWhPBfnqFVO76DH7cZEf1T1o+CP8HxVIo8ptoGj4W1OLBuAZ+ytIJ8MYmHV
  61232. l/9D7S3B2l0pKoU/rGXuhg8FjZBf3+6f9L/uHfuY5H+QK4R4EA5sSVPvFVtlRkpdr7r7OnIdzfYl
  61233. iB6XzCGcKQENZetX2fNXlrtIzYE=
  61234. -----END CERTIFICATE-----
  61235. Buypass Class 2 Root CA
  61236. =======================
  61237. -----BEGIN CERTIFICATE-----
  61238. MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU
  61239. QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMiBSb290IENBMB4X
  61240. DTEwMTAyNjA4MzgwM1oXDTQwMTAyNjA4MzgwM1owTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1
  61241. eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDIgUm9vdCBDQTCCAiIw
  61242. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANfHXvfBB9R3+0Mh9PT1aeTuMgHbo4Yf5FkNuud1
  61243. g1Lr6hxhFUi7HQfKjK6w3Jad6sNgkoaCKHOcVgb/S2TwDCo3SbXlzwx87vFKu3MwZfPVL4O2fuPn
  61244. 9Z6rYPnT8Z2SdIrkHJasW4DptfQxh6NR/Md+oW+OU3fUl8FVM5I+GC911K2GScuVr1QGbNgGE41b
  61245. /+EmGVnAJLqBcXmQRFBoJJRfuLMR8SlBYaNByyM21cHxMlAQTn/0hpPshNOOvEu/XAFOBz3cFIqU
  61246. CqTqc/sLUegTBxj6DvEr0VQVfTzh97QZQmdiXnfgolXsttlpF9U6r0TtSsWe5HonfOV116rLJeff
  61247. awrbD02TTqigzXsu8lkBarcNuAeBfos4GzjmCleZPe4h6KP1DBbdi+w0jpwqHAAVF41og9JwnxgI
  61248. zRFo1clrUs3ERo/ctfPYV3Me6ZQ5BL/T3jjetFPsaRyifsSP5BtwrfKi+fv3FmRmaZ9JUaLiFRhn
  61249. Bkp/1Wy1TbMz4GHrXb7pmA8y1x1LPC5aAVKRCfLf6o3YBkBjqhHk/sM3nhRSP/TizPJhk9H9Z2vX
  61250. Uq6/aKtAQ6BXNVN48FP4YUIHZMbXb5tMOA1jrGKvNouicwoN9SG9dKpN6nIDSdvHXx1iY8f93ZHs
  61251. M+71bbRuMGjeyNYmsHVee7QHIJihdjK4TWxPAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  61252. VR0OBBYEFMmAd+BikoL1RpzzuvdMw964o605MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF
  61253. AAOCAgEAU18h9bqwOlI5LJKwbADJ784g7wbylp7ppHR/ehb8t/W2+xUbP6umwHJdELFx7rxP462s
  61254. A20ucS6vxOOto70MEae0/0qyexAQH6dXQbLArvQsWdZHEIjzIVEpMMpghq9Gqx3tOluwlN5E40EI
  61255. osHsHdb9T7bWR9AUC8rmyrV7d35BH16Dx7aMOZawP5aBQW9gkOLo+fsicdl9sz1Gv7SEr5AcD48S
  61256. aq/v7h56rgJKihcrdv6sVIkkLE8/trKnToyokZf7KcZ7XC25y2a2t6hbElGFtQl+Ynhw/qlqYLYd
  61257. DnkM/crqJIByw5c/8nerQyIKx+u2DISCLIBrQYoIwOula9+ZEsuK1V6ADJHgJgg2SMX6OBE1/yWD
  61258. LfJ6v9r9jv6ly0UsH8SIU653DtmadsWOLB2jutXsMq7Aqqz30XpN69QH4kj3Io6wpJ9qzo6ysmD0
  61259. oyLQI+uUWnpp3Q+/QFesa1lQ2aOZ4W7+jQF5JyMV3pKdewlNWudLSDBaGOYKbeaP4NK75t98biGC
  61260. wWg5TbSYWGZizEqQXsP6JwSxeRV0mcy+rSDeJmAc61ZRpqPq5KM/p/9h3PFaTWwyI0PurKju7koS
  61261. CTxdccK+efrCh2gdC/1cacwG0Jp9VJkqyTkaGa9LKkPzY11aWOIv4x3kqdbQCtCev9eBCfHJxyYN
  61262. rJgWVqA=
  61263. -----END CERTIFICATE-----
  61264. Buypass Class 3 Root CA
  61265. =======================
  61266. -----BEGIN CERTIFICATE-----
  61267. MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU
  61268. QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMyBSb290IENBMB4X
  61269. DTEwMTAyNjA4Mjg1OFoXDTQwMTAyNjA4Mjg1OFowTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1
  61270. eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDMgUm9vdCBDQTCCAiIw
  61271. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKXaCpUWUOOV8l6ddjEGMnqb8RB2uACatVI2zSRH
  61272. sJ8YZLya9vrVediQYkwiL944PdbgqOkcLNt4EemOaFEVcsfzM4fkoF0LXOBXByow9c3EN3coTRiR
  61273. 5r/VUv1xLXA+58bEiuPwKAv0dpihi4dVsjoT/Lc+JzeOIuOoTyrvYLs9tznDDgFHmV0ST9tD+leh
  61274. 7fmdvhFHJlsTmKtdFoqwNxxXnUX/iJY2v7vKB3tvh2PX0DJq1l1sDPGzbjniazEuOQAnFN44wOwZ
  61275. ZoYS6J1yFhNkUsepNxz9gjDthBgd9K5c/3ATAOux9TN6S9ZV+AWNS2mw9bMoNlwUxFFzTWsL8TQH
  61276. 2xc519woe2v1n/MuwU8XKhDzzMro6/1rqy6any2CbgTUUgGTLT2G/H783+9CHaZr77kgxve9oKeV
  61277. /afmiSTYzIw0bOIjL9kSGiG5VZFvC5F5GQytQIgLcOJ60g7YaEi7ghM5EFjp2CoHxhLbWNvSO1UQ
  61278. RwUVZ2J+GGOmRj8JDlQyXr8NYnon74Do29lLBlo3WiXQCBJ31G8JUJc9yB3D34xFMFbG02SrZvPA
  61279. Xpacw8Tvw3xrizp5f7NJzz3iiZ+gMEuFuZyUJHmPfWupRWgPK9Dx2hzLabjKSWJtyNBjYt1gD1iq
  61280. j6G8BaVmos8bdrKEZLFMOVLAMLrwjEsCsLa3AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  61281. VR0OBBYEFEe4zf/lb+74suwvTg75JbCOPGvDMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF
  61282. AAOCAgEAACAjQTUEkMJAYmDv4jVM1z+s4jSQuKFvdvoWFqRINyzpkMLyPPgKn9iB5btb2iUspKdV
  61283. cSQy9sgL8rxq+JOssgfCX5/bzMiKqr5qb+FJEMwx14C7u8jYog5kV+qi9cKpMRXSIGrs/CIBKM+G
  61284. uIAeqcwRpTzyFrNHnfzSgCHEy9BHcEGhyoMZCCxt8l13nIoUE9Q2HJLw5QY33KbmkJs4j1xrG0aG
  61285. Q0JfPgEHU1RdZX33inOhmlRaHylDFCfChQ+1iHsaO5S3HWCntZznKWlXWpuTekMwGwPXYshApqr8
  61286. ZORK15FTAaggiG6cX0S5y2CBNOxv033aSF/rtJC8LakcC6wc1aJoIIAE1vyxjy+7SjENSoYc6+I2
  61287. KSb12tjE8nVhz36udmNKekBlk4f4HoCMhuWG1o8O/FMsYOgWYRqiPkN7zTlgVGr18okmAWiDSKIz
  61288. 6MkEkbIRNBE+6tBDGR8Dk5AM/1E9V/RBbuHLoL7ryWPNbczk+DaqaJ3tvV2XcEQNtg413OEMXbug
  61289. UZTLfhbrES+jkkXITHHZvMmZUldGL1DPvTVp9D0VzgalLA8+9oG6lLvDu79leNKGef9JOxqDDPDe
  61290. eOzI8k1MGt6CKfjBWtrt7uYnXuhF0J0cUahoq0Tj0Itq4/g7u9xN12TyUb7mqqta6THuBrxzvxNi
  61291. Cp/HuZc=
  61292. -----END CERTIFICATE-----
  61293. T-TeleSec GlobalRoot Class 3
  61294. ============================
  61295. -----BEGIN CERTIFICATE-----
  61296. MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM
  61297. IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU
  61298. cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwHhcNMDgx
  61299. MDAxMTAyOTU2WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz
  61300. dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD
  61301. ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwggEiMA0GCSqGSIb3
  61302. DQEBAQUAA4IBDwAwggEKAoIBAQC9dZPwYiJvJK7genasfb3ZJNW4t/zN8ELg63iIVl6bmlQdTQyK
  61303. 9tPPcPRStdiTBONGhnFBSivwKixVA9ZIw+A5OO3yXDw/RLyTPWGrTs0NvvAgJ1gORH8EGoel15YU
  61304. NpDQSXuhdfsaa3Ox+M6pCSzyU9XDFES4hqX2iys52qMzVNn6chr3IhUciJFrf2blw2qAsCTz34ZF
  61305. iP0Zf3WHHx+xGwpzJFu5ZeAsVMhg02YXP+HMVDNzkQI6pn97djmiH5a2OK61yJN0HZ65tOVgnS9W
  61306. 0eDrXltMEnAMbEQgqxHY9Bn20pxSN+f6tsIxO0rUFJmtxxr1XV/6B7h8DR/Wgx6zAgMBAAGjQjBA
  61307. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS1A/d2O2GCahKqGFPr
  61308. AyGUv/7OyjANBgkqhkiG9w0BAQsFAAOCAQEAVj3vlNW92nOyWL6ukK2YJ5f+AbGwUgC4TeQbIXQb
  61309. fsDuXmkqJa9c1h3a0nnJ85cp4IaH3gRZD/FZ1GSFS5mvJQQeyUapl96Cshtwn5z2r3Ex3XsFpSzT
  61310. ucpH9sry9uetuUg/vBa3wW306gmv7PO15wWeph6KU1HWk4HMdJP2udqmJQV0eVp+QD6CSyYRMG7h
  61311. P0HHRwA11fXT91Q+gT3aSWqas+8QPebrb9HIIkfLzM8BMZLZGOMivgkeGj5asuRrDFR6fUNOuIml
  61312. e9eiPZaGzPImNC1qkp2aGtAw4l1OBLBfiyB+d8E9lYLRRpo7PHi4b6HQDWSieB4pTpPDpFQUWw==
  61313. -----END CERTIFICATE-----
  61314. EE Certification Centre Root CA
  61315. ===============================
  61316. -----BEGIN CERTIFICATE-----
  61317. MIIEAzCCAuugAwIBAgIQVID5oHPtPwBMyonY43HmSjANBgkqhkiG9w0BAQUFADB1MQswCQYDVQQG
  61318. EwJFRTEiMCAGA1UECgwZQVMgU2VydGlmaXRzZWVyaW1pc2tlc2t1czEoMCYGA1UEAwwfRUUgQ2Vy
  61319. dGlmaWNhdGlvbiBDZW50cmUgUm9vdCBDQTEYMBYGCSqGSIb3DQEJARYJcGtpQHNrLmVlMCIYDzIw
  61320. MTAxMDMwMTAxMDMwWhgPMjAzMDEyMTcyMzU5NTlaMHUxCzAJBgNVBAYTAkVFMSIwIAYDVQQKDBlB
  61321. UyBTZXJ0aWZpdHNlZXJpbWlza2Vza3VzMSgwJgYDVQQDDB9FRSBDZXJ0aWZpY2F0aW9uIENlbnRy
  61322. ZSBSb290IENBMRgwFgYJKoZIhvcNAQkBFglwa2lAc2suZWUwggEiMA0GCSqGSIb3DQEBAQUAA4IB
  61323. DwAwggEKAoIBAQDIIMDs4MVLqwd4lfNE7vsLDP90jmG7sWLqI9iroWUyeuuOF0+W2Ap7kaJjbMeM
  61324. TC55v6kF/GlclY1i+blw7cNRfdCT5mzrMEvhvH2/UpvObntl8jixwKIy72KyaOBhU8E2lf/slLo2
  61325. rpwcpzIP5Xy0xm90/XsY6KxX7QYgSzIwWFv9zajmofxwvI6Sc9uXp3whrj3B9UiHbCe9nyV0gVWw
  61326. 93X2PaRka9ZP585ArQ/dMtO8ihJTmMmJ+xAdTX7Nfh9WDSFwhfYggx/2uh8Ej+p3iDXE/+pOoYtN
  61327. P2MbRMNE1CV2yreN1x5KZmTNXMWcg+HCCIia7E6j8T4cLNlsHaFLAgMBAAGjgYowgYcwDwYDVR0T
  61328. AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFBLyWj7qVhy/zQas8fElyalL1BSZ
  61329. MEUGA1UdJQQ+MDwGCCsGAQUFBwMCBggrBgEFBQcDAQYIKwYBBQUHAwMGCCsGAQUFBwMEBggrBgEF
  61330. BQcDCAYIKwYBBQUHAwkwDQYJKoZIhvcNAQEFBQADggEBAHv25MANqhlHt01Xo/6tu7Fq1Q+e2+Rj
  61331. xY6hUFaTlrg4wCQiZrxTFGGVv9DHKpY5P30osxBAIWrEr7BSdxjhlthWXePdNl4dp1BUoMUq5KqM
  61332. lIpPnTX/dqQGE5Gion0ARD9V04I8GtVbvFZMIi5GQ4okQC3zErg7cBqklrkar4dBGmoYDQZPxz5u
  61333. uSlNDUmJEYcyW+ZLBMjkXOZ0c5RdFpgTlf7727FE5TpwrDdr5rMzcijJs1eg9gIWiAYLtqZLICjU
  61334. 3j2LrTcFU3T+bsy8QxdxXvnFzBqpYe73dgzzcvRyrc9yAjYHR8/vGVCJYMzpJJUPwssd8m92kMfM
  61335. dcGWxZ0=
  61336. -----END CERTIFICATE-----
  61337. D-TRUST Root Class 3 CA 2 2009
  61338. ==============================
  61339. -----BEGIN CERTIFICATE-----
  61340. MIIEMzCCAxugAwIBAgIDCYPzMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  61341. DAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTAe
  61342. Fw0wOTExMDUwODM1NThaFw0yOTExMDUwODM1NThaME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxE
  61343. LVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTCCASIw
  61344. DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANOySs96R+91myP6Oi/WUEWJNTrGa9v+2wBoqOAD
  61345. ER03UAifTUpolDWzU9GUY6cgVq/eUXjsKj3zSEhQPgrfRlWLJ23DEE0NkVJD2IfgXU42tSHKXzlA
  61346. BF9bfsyjxiupQB7ZNoTWSPOSHjRGICTBpFGOShrvUD9pXRl/RcPHAY9RySPocq60vFYJfxLLHLGv
  61347. KZAKyVXMD9O0Gu1HNVpK7ZxzBCHQqr0ME7UAyiZsxGsMlFqVlNpQmvH/pStmMaTJOKDfHR+4CS7z
  61348. p+hnUquVH+BGPtikw8paxTGA6Eian5Rp/hnd2HN8gcqW3o7tszIFZYQ05ub9VxC1X3a/L7AQDcUC
  61349. AwEAAaOCARowggEWMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFP3aFMSfMN4hvR5COfyrYyNJ
  61350. 4PGEMA4GA1UdDwEB/wQEAwIBBjCB0wYDVR0fBIHLMIHIMIGAoH6gfIZ6bGRhcDovL2RpcmVjdG9y
  61351. eS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwUm9vdCUyMENsYXNzJTIwMyUyMENBJTIwMiUyMDIw
  61352. MDksTz1ELVRydXN0JTIwR21iSCxDPURFP2NlcnRpZmljYXRlcmV2b2NhdGlvbmxpc3QwQ6BBoD+G
  61353. PWh0dHA6Ly93d3cuZC10cnVzdC5uZXQvY3JsL2QtdHJ1c3Rfcm9vdF9jbGFzc18zX2NhXzJfMjAw
  61354. OS5jcmwwDQYJKoZIhvcNAQELBQADggEBAH+X2zDI36ScfSF6gHDOFBJpiBSVYEQBrLLpME+bUMJm
  61355. 2H6NMLVwMeniacfzcNsgFYbQDfC+rAF1hM5+n02/t2A7nPPKHeJeaNijnZflQGDSNiH+0LS4F9p0
  61356. o3/U37CYAqxva2ssJSRyoWXuJVrl5jLn8t+rSfrzkGkj2wTZ51xY/GXUl77M/C4KzCUqNQT4YJEV
  61357. dT1B/yMfGchs64JTBKbkTCJNjYy6zltz7GRUUG3RnFX7acM2w4y8PIWmawomDeCTmGCufsYkl4ph
  61358. X5GOZpIJhzbNi5stPvZR1FDUWSi9g/LMKHtThm3YJohw1+qRzT65ysCQblrGXnRl11z+o+I=
  61359. -----END CERTIFICATE-----
  61360. D-TRUST Root Class 3 CA 2 EV 2009
  61361. =================================
  61362. -----BEGIN CERTIFICATE-----
  61363. MIIEQzCCAyugAwIBAgIDCYP0MA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  61364. DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw
  61365. OTAeFw0wOTExMDUwODUwNDZaFw0yOTExMDUwODUwNDZaMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  61366. DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw
  61367. OTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJnxhDRwui+3MKCOvXwEz75ivJn9gpfS
  61368. egpnljgJ9hBOlSJzmY3aFS3nBfwZcyK3jpgAvDw9rKFs+9Z5JUut8Mxk2og+KbgPCdM03TP1YtHh
  61369. zRnp7hhPTFiu4h7WDFsVWtg6uMQYZB7jM7K1iXdODL/ZlGsTl28So/6ZqQTMFexgaDbtCHu39b+T
  61370. 7WYxg4zGcTSHThfqr4uRjRxWQa4iN1438h3Z0S0NL2lRp75mpoo6Kr3HGrHhFPC+Oh25z1uxav60
  61371. sUYgovseO3Dvk5h9jHOW8sXvhXCtKSb8HgQ+HKDYD8tSg2J87otTlZCpV6LqYQXY+U3EJ/pure35
  61372. 11H3a6UCAwEAAaOCASQwggEgMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFNOUikxiEyoZLsyv
  61373. cop9NteaHNxnMA4GA1UdDwEB/wQEAwIBBjCB3QYDVR0fBIHVMIHSMIGHoIGEoIGBhn9sZGFwOi8v
  61374. ZGlyZWN0b3J5LmQtdHJ1c3QubmV0L0NOPUQtVFJVU1QlMjBSb290JTIwQ2xhc3MlMjAzJTIwQ0El
  61375. MjAyJTIwRVYlMjAyMDA5LE89RC1UcnVzdCUyMEdtYkgsQz1ERT9jZXJ0aWZpY2F0ZXJldm9jYXRp
  61376. b25saXN0MEagRKBChkBodHRwOi8vd3d3LmQtdHJ1c3QubmV0L2NybC9kLXRydXN0X3Jvb3RfY2xh
  61377. c3NfM19jYV8yX2V2XzIwMDkuY3JsMA0GCSqGSIb3DQEBCwUAA4IBAQA07XtaPKSUiO8aEXUHL7P+
  61378. PPoeUSbrh/Yp3uDx1MYkCenBz1UbtDDZzhr+BlGmFaQt77JLvyAoJUnRpjZ3NOhk31KxEcdzes05
  61379. nsKtjHEh8lprr988TlWvsoRlFIm5d8sqMb7Po23Pb0iUMkZv53GMoKaEGTcH8gNFCSuGdXzfX2lX
  61380. ANtu2KZyIktQ1HWYVt+3GP9DQ1CuekR78HlR10M9p9OB0/DJT7naxpeG0ILD5EJt/rDiZE4OJudA
  61381. NCa1CInXCGNjOCd1HjPqbqjdn5lPdE2BiYBL3ZqXKVwvvoFBuYz/6n1gBp7N1z3TLqMVvKjmJuVv
  61382. w9y4AyHqnxbxLFS1
  61383. -----END CERTIFICATE-----
  61384. CA Disig Root R2
  61385. ================
  61386. -----BEGIN CERTIFICATE-----
  61387. MIIFaTCCA1GgAwIBAgIJAJK4iNuwisFjMA0GCSqGSIb3DQEBCwUAMFIxCzAJBgNVBAYTAlNLMRMw
  61388. EQYDVQQHEwpCcmF0aXNsYXZhMRMwEQYDVQQKEwpEaXNpZyBhLnMuMRkwFwYDVQQDExBDQSBEaXNp
  61389. ZyBSb290IFIyMB4XDTEyMDcxOTA5MTUzMFoXDTQyMDcxOTA5MTUzMFowUjELMAkGA1UEBhMCU0sx
  61390. EzARBgNVBAcTCkJyYXRpc2xhdmExEzARBgNVBAoTCkRpc2lnIGEucy4xGTAXBgNVBAMTEENBIERp
  61391. c2lnIFJvb3QgUjIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCio8QACdaFXS1tFPbC
  61392. w3OeNcJxVX6B+6tGUODBfEl45qt5WDza/3wcn9iXAng+a0EE6UG9vgMsRfYvZNSrXaNHPWSb6Wia
  61393. xswbP7q+sos0Ai6YVRn8jG+qX9pMzk0DIaPY0jSTVpbLTAwAFjxfGs3Ix2ymrdMxp7zo5eFm1tL7
  61394. A7RBZckQrg4FY8aAamkw/dLukO8NJ9+flXP04SXabBbeQTg06ov80egEFGEtQX6sx3dOy1FU+16S
  61395. GBsEWmjGycT6txOgmLcRK7fWV8x8nhfRyyX+hk4kLlYMeE2eARKmK6cBZW58Yh2EhN/qwGu1pSqV
  61396. g8NTEQxzHQuyRpDRQjrOQG6Vrf/GlK1ul4SOfW+eioANSW1z4nuSHsPzwfPrLgVv2RvPN3YEyLRa
  61397. 5Beny912H9AZdugsBbPWnDTYltxhh5EF5EQIM8HauQhl1K6yNg3ruji6DOWbnuuNZt2Zz9aJQfYE
  61398. koopKW1rOhzndX0CcQ7zwOe9yxndnWCywmZgtrEE7snmhrmaZkCo5xHtgUUDi/ZnWejBBhG93c+A
  61399. Ak9lQHhcR1DIm+YfgXvkRKhbhZri3lrVx/k6RGZL5DJUfORsnLMOPReisjQS1n6yqEm70XooQL6i
  61400. Fh/f5DcfEXP7kAplQ6INfPgGAVUzfbANuPT1rqVCV3w2EYx7XsQDnYx5nQIDAQABo0IwQDAPBgNV
  61401. HRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUtZn4r7CU9eMg1gqtzk5WpC5u
  61402. Qu0wDQYJKoZIhvcNAQELBQADggIBACYGXnDnZTPIgm7ZnBc6G3pmsgH2eDtpXi/q/075KMOYKmFM
  61403. tCQSin1tERT3nLXK5ryeJ45MGcipvXrA1zYObYVybqjGom32+nNjf7xueQgcnYqfGopTpti72TVV
  61404. sRHFqQOzVju5hJMiXn7B9hJSi+osZ7z+Nkz1uM/Rs0mSO9MpDpkblvdhuDvEK7Z4bLQjb/D907Je
  61405. dR+Zlais9trhxTF7+9FGs9K8Z7RiVLoJ92Owk6Ka+elSLotgEqv89WBW7xBci8QaQtyDW2QOy7W8
  61406. 1k/BfDxujRNt+3vrMNDcTa/F1balTFtxyegxvug4BkihGuLq0t4SOVga/4AOgnXmt8kHbA7v/zjx
  61407. mHHEt38OFdAlab0inSvtBfZGR6ztwPDUO+Ls7pZbkBNOHlY667DvlruWIxG68kOGdGSVyCh13x01
  61408. utI3gzhTODY7z2zp+WsO0PsE6E9312UBeIYMej4hYvF/Y3EMyZ9E26gnonW+boE+18DrG5gPcFw0
  61409. sorMwIUY6256s/daoQe/qUKS82Ail+QUoQebTnbAjn39pCXHR+3/H3OszMOl6W8KjptlwlCFtaOg
  61410. UxLMVYdh84GuEEZhvUQhuMI9dM9+JDX6HAcOmz0iyu8xL4ysEr3vQCj8KWefshNPZiTEUxnpHikV
  61411. 7+ZtsH8tZ/3zbBt1RqPlShfppNcL
  61412. -----END CERTIFICATE-----
  61413. ACCVRAIZ1
  61414. =========
  61415. -----BEGIN CERTIFICATE-----
  61416. MIIH0zCCBbugAwIBAgIIXsO3pkN/pOAwDQYJKoZIhvcNAQEFBQAwQjESMBAGA1UEAwwJQUNDVlJB
  61417. SVoxMRAwDgYDVQQLDAdQS0lBQ0NWMQ0wCwYDVQQKDARBQ0NWMQswCQYDVQQGEwJFUzAeFw0xMTA1
  61418. MDUwOTM3MzdaFw0zMDEyMzEwOTM3MzdaMEIxEjAQBgNVBAMMCUFDQ1ZSQUlaMTEQMA4GA1UECwwH
  61419. UEtJQUNDVjENMAsGA1UECgwEQUNDVjELMAkGA1UEBhMCRVMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  61420. DwAwggIKAoICAQCbqau/YUqXry+XZpp0X9DZlv3P4uRm7x8fRzPCRKPfmt4ftVTdFXxpNRFvu8gM
  61421. jmoYHtiP2Ra8EEg2XPBjs5BaXCQ316PWywlxufEBcoSwfdtNgM3802/J+Nq2DoLSRYWoG2ioPej0
  61422. RGy9ocLLA76MPhMAhN9KSMDjIgro6TenGEyxCQ0jVn8ETdkXhBilyNpAlHPrzg5XPAOBOp0KoVdD
  61423. aaxXbXmQeOW1tDvYvEyNKKGno6e6Ak4l0Squ7a4DIrhrIA8wKFSVf+DuzgpmndFALW4ir50awQUZ
  61424. 0m/A8p/4e7MCQvtQqR0tkw8jq8bBD5L/0KIV9VMJcRz/RROE5iZe+OCIHAr8Fraocwa48GOEAqDG
  61425. WuzndN9wrqODJerWx5eHk6fGioozl2A3ED6XPm4pFdahD9GILBKfb6qkxkLrQaLjlUPTAYVtjrs7
  61426. 8yM2x/474KElB0iryYl0/wiPgL/AlmXz7uxLaL2diMMxs0Dx6M/2OLuc5NF/1OVYm3z61PMOm3WR
  61427. 5LpSLhl+0fXNWhn8ugb2+1KoS5kE3fj5tItQo05iifCHJPqDQsGH+tUtKSpacXpkatcnYGMN285J
  61428. 9Y0fkIkyF/hzQ7jSWpOGYdbhdQrqeWZ2iE9x6wQl1gpaepPluUsXQA+xtrn13k/c4LOsOxFwYIRK
  61429. Q26ZIMApcQrAZQIDAQABo4ICyzCCAscwfQYIKwYBBQUHAQEEcTBvMEwGCCsGAQUFBzAChkBodHRw
  61430. Oi8vd3d3LmFjY3YuZXMvZmlsZWFkbWluL0FyY2hpdm9zL2NlcnRpZmljYWRvcy9yYWl6YWNjdjEu
  61431. Y3J0MB8GCCsGAQUFBzABhhNodHRwOi8vb2NzcC5hY2N2LmVzMB0GA1UdDgQWBBTSh7Tj3zcnk1X2
  61432. VuqB5TbMjB4/vTAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFNKHtOPfNyeTVfZW6oHlNsyM
  61433. Hj+9MIIBcwYDVR0gBIIBajCCAWYwggFiBgRVHSAAMIIBWDCCASIGCCsGAQUFBwICMIIBFB6CARAA
  61434. QQB1AHQAbwByAGkAZABhAGQAIABkAGUAIABDAGUAcgB0AGkAZgBpAGMAYQBjAGkA8wBuACAAUgBh
  61435. AO0AegAgAGQAZQAgAGwAYQAgAEEAQwBDAFYAIAAoAEEAZwBlAG4AYwBpAGEAIABkAGUAIABUAGUA
  61436. YwBuAG8AbABvAGcA7QBhACAAeQAgAEMAZQByAHQAaQBmAGkAYwBhAGMAaQDzAG4AIABFAGwAZQBj
  61437. AHQAcgDzAG4AaQBjAGEALAAgAEMASQBGACAAUQA0ADYAMAAxADEANQA2AEUAKQAuACAAQwBQAFMA
  61438. IABlAG4AIABoAHQAdABwADoALwAvAHcAdwB3AC4AYQBjAGMAdgAuAGUAczAwBggrBgEFBQcCARYk
  61439. aHR0cDovL3d3dy5hY2N2LmVzL2xlZ2lzbGFjaW9uX2MuaHRtMFUGA1UdHwROMEwwSqBIoEaGRGh0
  61440. dHA6Ly93d3cuYWNjdi5lcy9maWxlYWRtaW4vQXJjaGl2b3MvY2VydGlmaWNhZG9zL3JhaXphY2N2
  61441. MV9kZXIuY3JsMA4GA1UdDwEB/wQEAwIBBjAXBgNVHREEEDAOgQxhY2N2QGFjY3YuZXMwDQYJKoZI
  61442. hvcNAQEFBQADggIBAJcxAp/n/UNnSEQU5CmH7UwoZtCPNdpNYbdKl02125DgBS4OxnnQ8pdpD70E
  61443. R9m+27Up2pvZrqmZ1dM8MJP1jaGo/AaNRPTKFpV8M9xii6g3+CfYCS0b78gUJyCpZET/LtZ1qmxN
  61444. YEAZSUNUY9rizLpm5U9EelvZaoErQNV/+QEnWCzI7UiRfD+mAM/EKXMRNt6GGT6d7hmKG9Ww7Y49
  61445. nCrADdg9ZuM8Db3VlFzi4qc1GwQA9j9ajepDvV+JHanBsMyZ4k0ACtrJJ1vnE5Bc5PUzolVt3OAJ
  61446. TS+xJlsndQAJxGJ3KQhfnlmstn6tn1QwIgPBHnFk/vk4CpYY3QIUrCPLBhwepH2NDd4nQeit2hW3
  61447. sCPdK6jT2iWH7ehVRE2I9DZ+hJp4rPcOVkkO1jMl1oRQQmwgEh0q1b688nCBpHBgvgW1m54ERL5h
  61448. I6zppSSMEYCUWqKiuUnSwdzRp+0xESyeGabu4VXhwOrPDYTkF7eifKXeVSUG7szAh1xA2syVP1Xg
  61449. Nce4hL60Xc16gwFy7ofmXx2utYXGJt/mwZrpHgJHnyqobalbz+xFd3+YJ5oyXSrjhO7FmGYvliAd
  61450. 3djDJ9ew+f7Zfc3Qn48LFFhRny+Lwzgt3uiP1o2HpPVWQxaZLPSkVrQ0uGE3ycJYgBugl6H8WY3p
  61451. EfbRD0tVNEYqi4Y7
  61452. -----END CERTIFICATE-----
  61453. TWCA Global Root CA
  61454. ===================
  61455. -----BEGIN CERTIFICATE-----
  61456. MIIFQTCCAymgAwIBAgICDL4wDQYJKoZIhvcNAQELBQAwUTELMAkGA1UEBhMCVFcxEjAQBgNVBAoT
  61457. CVRBSVdBTi1DQTEQMA4GA1UECxMHUm9vdCBDQTEcMBoGA1UEAxMTVFdDQSBHbG9iYWwgUm9vdCBD
  61458. QTAeFw0xMjA2MjcwNjI4MzNaFw0zMDEyMzExNTU5NTlaMFExCzAJBgNVBAYTAlRXMRIwEAYDVQQK
  61459. EwlUQUlXQU4tQ0ExEDAOBgNVBAsTB1Jvb3QgQ0ExHDAaBgNVBAMTE1RXQ0EgR2xvYmFsIFJvb3Qg
  61460. Q0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCwBdvI64zEbooh745NnHEKH1Jw7W2C
  61461. nJfF10xORUnLQEK1EjRsGcJ0pDFfhQKX7EMzClPSnIyOt7h52yvVavKOZsTuKwEHktSz0ALfUPZV
  61462. r2YOy+BHYC8rMjk1Ujoog/h7FsYYuGLWRyWRzvAZEk2tY/XTP3VfKfChMBwqoJimFb3u/Rk28OKR
  61463. Q4/6ytYQJ0lM793B8YVwm8rqqFpD/G2Gb3PpN0Wp8DbHzIh1HrtsBv+baz4X7GGqcXzGHaL3SekV
  61464. tTzWoWH1EfcFbx39Eb7QMAfCKbAJTibc46KokWofwpFFiFzlmLhxpRUZyXx1EcxwdE8tmx2RRP1W
  61465. KKD+u4ZqyPpcC1jcxkt2yKsi2XMPpfRaAok/T54igu6idFMqPVMnaR1sjjIsZAAmY2E2TqNGtz99
  61466. sy2sbZCilaLOz9qC5wc0GZbpuCGqKX6mOL6OKUohZnkfs8O1CWfe1tQHRvMq2uYiN2DLgbYPoA/p
  61467. yJV/v1WRBXrPPRXAb94JlAGD1zQbzECl8LibZ9WYkTunhHiVJqRaCPgrdLQABDzfuBSO6N+pjWxn
  61468. kjMdwLfS7JLIvgm/LCkFbwJrnu+8vyq8W8BQj0FwcYeyTbcEqYSjMq+u7msXi7Kx/mzhkIyIqJdI
  61469. zshNy/MGz19qCkKxHh53L46g5pIOBvwFItIm4TFRfTLcDwIDAQABoyMwITAOBgNVHQ8BAf8EBAMC
  61470. AQYwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAXzSBdu+WHdXltdkCY4QWwa6g
  61471. cFGn90xHNcgL1yg9iXHZqjNB6hQbbCEAwGxCGX6faVsgQt+i0trEfJdLjbDorMjupWkEmQqSpqsn
  61472. LhpNgb+E1HAerUf+/UqdM+DyucRFCCEK2mlpc3INvjT+lIutwx4116KD7+U4x6WFH6vPNOw/KP4M
  61473. 8VeGTslV9xzU2KV9Bnpv1d8Q34FOIWWxtuEXeZVFBs5fzNxGiWNoRI2T9GRwoD2dKAXDOXC4Ynsg
  61474. /eTb6QihuJ49CcdP+yz4k3ZB3lLg4VfSnQO8d57+nile98FRYB/e2guyLXW3Q0iT5/Z5xoRdgFlg
  61475. lPx4mI88k1HtQJAH32RjJMtOcQWh15QaiDLxInQirqWm2BJpTGCjAu4r7NRjkgtevi92a6O2JryP
  61476. A9gK8kxkRr05YuWW6zRjESjMlfGt7+/cgFhI6Uu46mWs6fyAtbXIRfmswZ/ZuepiiI7E8UuDEq3m
  61477. i4TWnsLrgxifarsbJGAzcMzs9zLzXNl5fe+epP7JI8Mk7hWSsT2RTyaGvWZzJBPqpK5jwa19hAM8
  61478. EHiGG3njxPPyBJUgriOCxLM6AGK/5jYk4Ve6xx6QddVfP5VhK8E7zeWzaGHQRiapIVJpLesux+t3
  61479. zqY6tQMzT3bR51xUAV3LePTJDL/PEo4XLSNolOer/qmyKwbQBM0=
  61480. -----END CERTIFICATE-----
  61481. TeliaSonera Root CA v1
  61482. ======================
  61483. -----BEGIN CERTIFICATE-----
  61484. MIIFODCCAyCgAwIBAgIRAJW+FqD3LkbxezmCcvqLzZYwDQYJKoZIhvcNAQEFBQAwNzEUMBIGA1UE
  61485. CgwLVGVsaWFTb25lcmExHzAdBgNVBAMMFlRlbGlhU29uZXJhIFJvb3QgQ0EgdjEwHhcNMDcxMDE4
  61486. MTIwMDUwWhcNMzIxMDE4MTIwMDUwWjA3MRQwEgYDVQQKDAtUZWxpYVNvbmVyYTEfMB0GA1UEAwwW
  61487. VGVsaWFTb25lcmEgUm9vdCBDQSB2MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMK+
  61488. 6yfwIaPzaSZVfp3FVRaRXP3vIb9TgHot0pGMYzHw7CTww6XScnwQbfQ3t+XmfHnqjLWCi65ItqwA
  61489. 3GV17CpNX8GH9SBlK4GoRz6JI5UwFpB/6FcHSOcZrr9FZ7E3GwYq/t75rH2D+1665I+XZ75Ljo1k
  61490. B1c4VWk0Nj0TSO9P4tNmHqTPGrdeNjPUtAa9GAH9d4RQAEX1jF3oI7x+/jXh7VB7qTCNGdMJjmhn
  61491. Xb88lxhTuylixcpecsHHltTbLaC0H2kD7OriUPEMPPCs81Mt8Bz17Ww5OXOAFshSsCPN4D7c3TxH
  61492. oLs1iuKYaIu+5b9y7tL6pe0S7fyYGKkmdtwoSxAgHNN/Fnct7W+A90m7UwW7XWjH1Mh1Fj+JWov3
  61493. F0fUTPHSiXk+TT2YqGHeOh7S+F4D4MHJHIzTjU3TlTazN19jY5szFPAtJmtTfImMMsJu7D0hADnJ
  61494. oWjiUIMusDor8zagrC/kb2HCUQk5PotTubtn2txTuXZZNp1D5SDgPTJghSJRt8czu90VL6R4pgd7
  61495. gUY2BIbdeTXHlSw7sKMXNeVzH7RcWe/a6hBle3rQf5+ztCo3O3CLm1u5K7fsslESl1MpWtTwEhDc
  61496. TwK7EpIvYtQ/aUN8Ddb8WHUBiJ1YFkveupD/RwGJBmr2X7KQarMCpgKIv7NHfirZ1fpoeDVNAgMB
  61497. AAGjPzA9MA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1UdDgQWBBTwj1k4ALP1j5qW
  61498. DNXr+nuqF+gTEjANBgkqhkiG9w0BAQUFAAOCAgEAvuRcYk4k9AwI//DTDGjkk0kiP0Qnb7tt3oNm
  61499. zqjMDfz1mgbldxSR651Be5kqhOX//CHBXfDkH1e3damhXwIm/9fH907eT/j3HEbAek9ALCI18Bmx
  61500. 0GtnLLCo4MBANzX2hFxc469CeP6nyQ1Q6g2EdvZR74NTxnr/DlZJLo961gzmJ1TjTQpgcmLNkQfW
  61501. pb/ImWvtxBnmq0wROMVvMeJuScg/doAmAyYp4Db29iBT4xdwNBedY2gea+zDTYa4EzAvXUYNR0PV
  61502. G6pZDrlcjQZIrXSHX8f8MVRBE+LHIQ6e4B4N4cB7Q4WQxYpYxmUKeFfyxiMPAdkgS94P+5KFdSpc
  61503. c41teyWRyu5FrgZLAMzTsVlQ2jqIOylDRl6XK1TOU2+NSueW+r9xDkKLfP0ooNBIytrEgUy7onOT
  61504. JsjrDNYmiLbAJM+7vVvrdX3pCI6GMyx5dwlppYn8s3CQh3aP0yK7Qs69cwsgJirQmz1wHiRszYd2
  61505. qReWt88NkvuOGKmYSdGe/mBEciG5Ge3C9THxOUiIkCR1VBatzvT4aRRkOfujuLpwQMcnHL/EVlP6
  61506. Y2XQ8xwOFvVrhlhNGNTkDY6lnVuR3HYkUD/GKvvZt5y11ubQ2egZixVxSK236thZiNSQvxaz2ems
  61507. WWFUyBy6ysHK4bkgTI86k4mloMy/0/Z1pHWWbVY=
  61508. -----END CERTIFICATE-----
  61509. E-Tugra Certification Authority
  61510. ===============================
  61511. -----BEGIN CERTIFICATE-----
  61512. MIIGSzCCBDOgAwIBAgIIamg+nFGby1MwDQYJKoZIhvcNAQELBQAwgbIxCzAJBgNVBAYTAlRSMQ8w
  61513. DQYDVQQHDAZBbmthcmExQDA+BgNVBAoMN0UtVHXEn3JhIEVCRyBCaWxpxZ9pbSBUZWtub2xvamls
  61514. ZXJpIHZlIEhpem1ldGxlcmkgQS7Fni4xJjAkBgNVBAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBN
  61515. ZXJrZXppMSgwJgYDVQQDDB9FLVR1Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTEzMDMw
  61516. NTEyMDk0OFoXDTIzMDMwMzEyMDk0OFowgbIxCzAJBgNVBAYTAlRSMQ8wDQYDVQQHDAZBbmthcmEx
  61517. QDA+BgNVBAoMN0UtVHXEn3JhIEVCRyBCaWxpxZ9pbSBUZWtub2xvamlsZXJpIHZlIEhpem1ldGxl
  61518. cmkgQS7Fni4xJjAkBgNVBAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBNZXJrZXppMSgwJgYDVQQD
  61519. DB9FLVR1Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  61520. MIICCgKCAgEA4vU/kwVRHoViVF56C/UYB4Oufq9899SKa6VjQzm5S/fDxmSJPZQuVIBSOTkHS0vd
  61521. hQd2h8y/L5VMzH2nPbxHD5hw+IyFHnSOkm0bQNGZDbt1bsipa5rAhDGvykPL6ys06I+XawGb1Q5K
  61522. CKpbknSFQ9OArqGIW66z6l7LFpp3RMih9lRozt6Plyu6W0ACDGQXwLWTzeHxE2bODHnv0ZEoq1+g
  61523. ElIwcxmOj+GMB6LDu0rw6h8VqO4lzKRG+Bsi77MOQ7osJLjFLFzUHPhdZL3Dk14opz8n8Y4e0ypQ
  61524. BaNV2cvnOVPAmJ6MVGKLJrD3fY185MaeZkJVgkfnsliNZvcHfC425lAcP9tDJMW/hkd5s3kc91r0
  61525. E+xs+D/iWR+V7kI+ua2oMoVJl0b+SzGPWsutdEcf6ZG33ygEIqDUD13ieU/qbIWGvaimzuT6w+Gz
  61526. rt48Ue7LE3wBf4QOXVGUnhMMti6lTPk5cDZvlsouDERVxcr6XQKj39ZkjFqzAQqptQpHF//vkUAq
  61527. jqFGOjGY5RH8zLtJVor8udBhmm9lbObDyz51Sf6Pp+KJxWfXnUYTTjF2OySznhFlhqt/7x3U+Lzn
  61528. rFpct1pHXFXOVbQicVtbC/DP3KBhZOqp12gKY6fgDT+gr9Oq0n7vUaDmUStVkhUXU8u3Zg5mTPj5
  61529. dUyQ5xJwx0UCAwEAAaNjMGEwHQYDVR0OBBYEFC7j27JJ0JxUeVz6Jyr+zE7S6E5UMA8GA1UdEwEB
  61530. /wQFMAMBAf8wHwYDVR0jBBgwFoAULuPbsknQnFR5XPonKv7MTtLoTlQwDgYDVR0PAQH/BAQDAgEG
  61531. MA0GCSqGSIb3DQEBCwUAA4ICAQAFNzr0TbdF4kV1JI+2d1LoHNgQk2Xz8lkGpD4eKexd0dCrfOAK
  61532. kEh47U6YA5n+KGCRHTAduGN8qOY1tfrTYXbm1gdLymmasoR6d5NFFxWfJNCYExL/u6Au/U5Mh/jO
  61533. XKqYGwXgAEZKgoClM4so3O0409/lPun++1ndYYRP0lSWE2ETPo+Aab6TR7U1Q9Jauz1c77NCR807
  61534. VRMGsAnb/WP2OogKmW9+4c4bU2pEZiNRCHu8W1Ki/QY3OEBhj0qWuJA3+GbHeJAAFS6LrVE1Uweo
  61535. a2iu+U48BybNCAVwzDk/dr2l02cmAYamU9JgO3xDf1WKvJUawSg5TB9D0pH0clmKuVb8P7Sd2nCc
  61536. dlqMQ1DujjByTd//SffGqWfZbawCEeI6FiWnWAjLb1NBnEg4R2gz0dfHj9R0IdTDBZB6/86WiLEV
  61537. KV0jq9BgoRJP3vQXzTLlyb/IQ639Lo7xr+L0mPoSHyDYwKcMhcWQ9DstliaxLL5Mq+ux0orJ23gT
  61538. Dx4JnW2PAJ8C2sH6H3p6CcRK5ogql5+Ji/03X186zjhZhkuvcQu02PJwT58yE+Owp1fl2tpDy4Q0
  61539. 8ijE6m30Ku/Ba3ba+367hTzSU8JNvnHhRdH9I2cNE3X7z2VnIp2usAnRCf8dNL/+I5c30jn6PQ0G
  61540. C7TbO6Orb1wdtn7os4I07QZcJA==
  61541. -----END CERTIFICATE-----
  61542. T-TeleSec GlobalRoot Class 2
  61543. ============================
  61544. -----BEGIN CERTIFICATE-----
  61545. MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM
  61546. IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU
  61547. cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwHhcNMDgx
  61548. MDAxMTA0MDE0WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz
  61549. dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD
  61550. ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwggEiMA0GCSqGSIb3
  61551. DQEBAQUAA4IBDwAwggEKAoIBAQCqX9obX+hzkeXaXPSi5kfl82hVYAUdAqSzm1nzHoqvNK38DcLZ
  61552. SBnuaY/JIPwhqgcZ7bBcrGXHX+0CfHt8LRvWurmAwhiCFoT6ZrAIxlQjgeTNuUk/9k9uN0goOA/F
  61553. vudocP05l03Sx5iRUKrERLMjfTlH6VJi1hKTXrcxlkIF+3anHqP1wvzpesVsqXFP6st4vGCvx970
  61554. 2cu+fjOlbpSD8DT6IavqjnKgP6TeMFvvhk1qlVtDRKgQFRzlAVfFmPHmBiiRqiDFt1MmUUOyCxGV
  61555. WOHAD3bZwI18gfNycJ5v/hqO2V81xrJvNHy+SE/iWjnX2J14np+GPgNeGYtEotXHAgMBAAGjQjBA
  61556. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS/WSA2AHmgoCJrjNXy
  61557. YdK4LMuCSjANBgkqhkiG9w0BAQsFAAOCAQEAMQOiYQsfdOhyNsZt+U2e+iKo4YFWz827n+qrkRk4
  61558. r6p8FU3ztqONpfSO9kSpp+ghla0+AGIWiPACuvxhI+YzmzB6azZie60EI4RYZeLbK4rnJVM3YlNf
  61559. vNoBYimipidx5joifsFvHZVwIEoHNN/q/xWA5brXethbdXwFeilHfkCoMRN3zUA7tFFHei4R40cR
  61560. 3p1m0IvVVGb6g1XqfMIpiRvpb7PO4gWEyS8+eIVibslfwXhjdFjASBgMmTnrpMwatXlajRWc2BQN
  61561. 9noHV8cigwUtPJslJj0Ys6lDfMjIq2SPDqO/nBudMNva0Bkuqjzx+zOAduTNrRlPBSeOE6Fuwg==
  61562. -----END CERTIFICATE-----
  61563. Atos TrustedRoot 2011
  61564. =====================
  61565. -----BEGIN CERTIFICATE-----
  61566. MIIDdzCCAl+gAwIBAgIIXDPLYixfszIwDQYJKoZIhvcNAQELBQAwPDEeMBwGA1UEAwwVQXRvcyBU
  61567. cnVzdGVkUm9vdCAyMDExMQ0wCwYDVQQKDARBdG9zMQswCQYDVQQGEwJERTAeFw0xMTA3MDcxNDU4
  61568. MzBaFw0zMDEyMzEyMzU5NTlaMDwxHjAcBgNVBAMMFUF0b3MgVHJ1c3RlZFJvb3QgMjAxMTENMAsG
  61569. A1UECgwEQXRvczELMAkGA1UEBhMCREUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCV
  61570. hTuXbyo7LjvPpvMpNb7PGKw+qtn4TaA+Gke5vJrf8v7MPkfoepbCJI419KkM/IL9bcFyYie96mvr
  61571. 54rMVD6QUM+A1JX76LWC1BTFtqlVJVfbsVD2sGBkWXppzwO3bw2+yj5vdHLqqjAqc2K+SZFhyBH+
  61572. DgMq92og3AIVDV4VavzjgsG1xZ1kCWyjWZgHJ8cblithdHFsQ/H3NYkQ4J7sVaE3IqKHBAUsR320
  61573. HLliKWYoyrfhk/WklAOZuXCFteZI6o1Q/NnezG8HDt0Lcp2AMBYHlT8oDv3FdU9T1nSatCQujgKR
  61574. z3bFmx5VdJx4IbHwLfELn8LVlhgf8FQieowHAgMBAAGjfTB7MB0GA1UdDgQWBBSnpQaxLKYJYO7R
  61575. l+lwrrw7GWzbITAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFKelBrEspglg7tGX6XCuvDsZ
  61576. bNshMBgGA1UdIAQRMA8wDQYLKwYBBAGwLQMEAQEwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEB
  61577. CwUAA4IBAQAmdzTblEiGKkGdLD4GkGDEjKwLVLgfuXvTBznk+j57sj1O7Z8jvZfza1zv7v1Apt+h
  61578. k6EKhqzvINB5Ab149xnYJDE0BAGmuhWawyfc2E8PzBhj/5kPDpFrdRbhIfzYJsdHt6bPWHJxfrrh
  61579. TZVHO8mvbaG0weyJ9rQPOLXiZNwlz6bb65pcmaHFCN795trV1lpFDMS3wrUU77QR/w4VtfX128a9
  61580. 61qn8FYiqTxlVMYVqL2Gns2Dlmh6cYGJ4Qvh6hEbaAjMaZ7snkGeRDImeuKHCnE96+RapNLbxc3G
  61581. 3mB/ufNPRJLvKrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed
  61582. -----END CERTIFICATE-----
  61583. QuoVadis Root CA 1 G3
  61584. =====================
  61585. -----BEGIN CERTIFICATE-----
  61586. MIIFYDCCA0igAwIBAgIUeFhfLq0sGUvjNwc1NBMotZbUZZMwDQYJKoZIhvcNAQELBQAwSDELMAkG
  61587. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  61588. b3QgQ0EgMSBHMzAeFw0xMjAxMTIxNzI3NDRaFw00MjAxMTIxNzI3NDRaMEgxCzAJBgNVBAYTAkJN
  61589. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDEg
  61590. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCgvlAQjunybEC0BJyFuTHK3C3kEakE
  61591. PBtVwedYMB0ktMPvhd6MLOHBPd+C5k+tR4ds7FtJwUrVu4/sh6x/gpqG7D0DmVIB0jWerNrwU8lm
  61592. PNSsAgHaJNM7qAJGr6Qc4/hzWHa39g6QDbXwz8z6+cZM5cOGMAqNF34168Xfuw6cwI2H44g4hWf6
  61593. Pser4BOcBRiYz5P1sZK0/CPTz9XEJ0ngnjybCKOLXSoh4Pw5qlPafX7PGglTvF0FBM+hSo+LdoIN
  61594. ofjSxxR3W5A2B4GbPgb6Ul5jxaYA/qXpUhtStZI5cgMJYr2wYBZupt0lwgNm3fME0UDiTouG9G/l
  61595. g6AnhF4EwfWQvTA9xO+oabw4m6SkltFi2mnAAZauy8RRNOoMqv8hjlmPSlzkYZqn0ukqeI1RPToV
  61596. 7qJZjqlc3sX5kCLliEVx3ZGZbHqfPT2YfF72vhZooF6uCyP8Wg+qInYtyaEQHeTTRCOQiJ/GKubX
  61597. 9ZqzWB4vMIkIG1SitZgj7Ah3HJVdYdHLiZxfokqRmu8hqkkWCKi9YSgxyXSthfbZxbGL0eUQMk1f
  61598. iyA6PEkfM4VZDdvLCXVDaXP7a3F98N/ETH3Goy7IlXnLc6KOTk0k+17kBL5yG6YnLUlamXrXXAkg
  61599. t3+UuU/xDRxeiEIbEbfnkduebPRq34wGmAOtzCjvpUfzUwIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  61600. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUo5fW816iEOGrRZ88F2Q87gFwnMwwDQYJKoZI
  61601. hvcNAQELBQADggIBABj6W3X8PnrHX3fHyt/PX8MSxEBd1DKquGrX1RUVRpgjpeaQWxiZTOOtQqOC
  61602. MTaIzen7xASWSIsBx40Bz1szBpZGZnQdT+3Btrm0DWHMY37XLneMlhwqI2hrhVd2cDMT/uFPpiN3
  61603. GPoajOi9ZcnPP/TJF9zrx7zABC4tRi9pZsMbj/7sPtPKlL92CiUNqXsCHKnQO18LwIE6PWThv6ct
  61604. Tr1NxNgpxiIY0MWscgKCP6o6ojoilzHdCGPDdRS5YCgtW2jgFqlmgiNR9etT2DGbe+m3nUvriBbP
  61605. +V04ikkwj+3x6xn0dxoxGE1nVGwvb2X52z3sIexe9PSLymBlVNFxZPT5pqOBMzYzcfCkeF9OrYMh
  61606. 3jRJjehZrJ3ydlo28hP0r+AJx2EqbPfgna67hkooby7utHnNkDPDs3b69fBsnQGQ+p6Q9pxyz0fa
  61607. wx/kNSBT8lTR32GDpgLiJTjehTItXnOQUl1CxM49S+H5GYQd1aJQzEH7QRTDvdbJWqNjZgKAvQU6
  61608. O0ec7AAmTPWIUb+oI38YB7AL7YsmoWTTYUrrXJ/es69nA7Mf3W1daWhpq1467HxpvMc7hU6eFbm0
  61609. FU/DlXpY18ls6Wy58yljXrQs8C097Vpl4KlbQMJImYFtnh8GKjwStIsPm6Ik8KaN1nrgS7ZklmOV
  61610. hMJKzRwuJIczYOXD
  61611. -----END CERTIFICATE-----
  61612. QuoVadis Root CA 2 G3
  61613. =====================
  61614. -----BEGIN CERTIFICATE-----
  61615. MIIFYDCCA0igAwIBAgIURFc0JFuBiZs18s64KztbpybwdSgwDQYJKoZIhvcNAQELBQAwSDELMAkG
  61616. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  61617. b3QgQ0EgMiBHMzAeFw0xMjAxMTIxODU5MzJaFw00MjAxMTIxODU5MzJaMEgxCzAJBgNVBAYTAkJN
  61618. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDIg
  61619. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQChriWyARjcV4g/Ruv5r+LrI3HimtFh
  61620. ZiFfqq8nUeVuGxbULX1QsFN3vXg6YOJkApt8hpvWGo6t/x8Vf9WVHhLL5hSEBMHfNrMWn4rjyduY
  61621. NM7YMxcoRvynyfDStNVNCXJJ+fKH46nafaF9a7I6JaltUkSs+L5u+9ymc5GQYaYDFCDy54ejiK2t
  61622. oIz/pgslUiXnFgHVy7g1gQyjO/Dh4fxaXc6AcW34Sas+O7q414AB+6XrW7PFXmAqMaCvN+ggOp+o
  61623. MiwMzAkd056OXbxMmO7FGmh77FOm6RQ1o9/NgJ8MSPsc9PG/Srj61YxxSscfrf5BmrODXfKEVu+l
  61624. V0POKa2Mq1W/xPtbAd0jIaFYAI7D0GoT7RPjEiuA3GfmlbLNHiJuKvhB1PLKFAeNilUSxmn1uIZo
  61625. L1NesNKqIcGY5jDjZ1XHm26sGahVpkUG0CM62+tlXSoREfA7T8pt9DTEceT/AFr2XK4jYIVz8eQQ
  61626. sSWu1ZK7E8EM4DnatDlXtas1qnIhO4M15zHfeiFuuDIIfR0ykRVKYnLP43ehvNURG3YBZwjgQQvD
  61627. 6xVu+KQZ2aKrr+InUlYrAoosFCT5v0ICvybIxo/gbjh9Uy3l7ZizlWNof/k19N+IxWA1ksB8aRxh
  61628. lRbQ694Lrz4EEEVlWFA4r0jyWbYW8jwNkALGcC4BrTwV1wIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  61629. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU7edvdlq/YOxJW8ald7tyFnGbxD0wDQYJKoZI
  61630. hvcNAQELBQADggIBAJHfgD9DCX5xwvfrs4iP4VGyvD11+ShdyLyZm3tdquXK4Qr36LLTn91nMX66
  61631. AarHakE7kNQIXLJgapDwyM4DYvmL7ftuKtwGTTwpD4kWilhMSA/ohGHqPHKmd+RCroijQ1h5fq7K
  61632. pVMNqT1wvSAZYaRsOPxDMuHBR//47PERIjKWnML2W2mWeyAMQ0GaW/ZZGYjeVYg3UQt4XAoeo0L9
  61633. x52ID8DyeAIkVJOviYeIyUqAHerQbj5hLja7NQ4nlv1mNDthcnPxFlxHBlRJAHpYErAK74X9sbgz
  61634. dWqTHBLmYF5vHX/JHyPLhGGfHoJE+V+tYlUkmlKY7VHnoX6XOuYvHxHaU4AshZ6rNRDbIl9qxV6X
  61635. U/IyAgkwo1jwDQHVcsaxfGl7w/U2Rcxhbl5MlMVerugOXou/983g7aEOGzPuVBj+D77vfoRrQ+Nw
  61636. mNtddbINWQeFFSM51vHfqSYP1kjHs6Yi9TM3WpVHn3u6GBVv/9YUZINJ0gpnIdsPNWNgKCLjsZWD
  61637. zYWm3S8P52dSbrsvhXz1SnPnxT7AvSESBT/8twNJAlvIJebiVDj1eYeMHVOyToV7BjjHLPj4sHKN
  61638. JeV3UvQDHEimUF+IIDBu8oJDqz2XhOdT+yHBTw8imoa4WSr2Rz0ZiC3oheGe7IUIarFsNMkd7Egr
  61639. O3jtZsSOeWmD3n+M
  61640. -----END CERTIFICATE-----
  61641. QuoVadis Root CA 3 G3
  61642. =====================
  61643. -----BEGIN CERTIFICATE-----
  61644. MIIFYDCCA0igAwIBAgIULvWbAiin23r/1aOp7r0DoM8Sah0wDQYJKoZIhvcNAQELBQAwSDELMAkG
  61645. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  61646. b3QgQ0EgMyBHMzAeFw0xMjAxMTIyMDI2MzJaFw00MjAxMTIyMDI2MzJaMEgxCzAJBgNVBAYTAkJN
  61647. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDMg
  61648. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCzyw4QZ47qFJenMioKVjZ/aEzHs286
  61649. IxSR/xl/pcqs7rN2nXrpixurazHb+gtTTK/FpRp5PIpM/6zfJd5O2YIyC0TeytuMrKNuFoM7pmRL
  61650. Mon7FhY4futD4tN0SsJiCnMK3UmzV9KwCoWdcTzeo8vAMvMBOSBDGzXRU7Ox7sWTaYI+FrUoRqHe
  61651. 6okJ7UO4BUaKhvVZR74bbwEhELn9qdIoyhA5CcoTNs+cra1AdHkrAj80//ogaX3T7mH1urPnMNA3
  61652. I4ZyYUUpSFlob3emLoG+B01vr87ERRORFHAGjx+f+IdpsQ7vw4kZ6+ocYfx6bIrc1gMLnia6Et3U
  61653. VDmrJqMz6nWB2i3ND0/kA9HvFZcba5DFApCTZgIhsUfei5pKgLlVj7WiL8DWM2fafsSntARE60f7
  61654. 5li59wzweyuxwHApw0BiLTtIadwjPEjrewl5qW3aqDCYz4ByA4imW0aucnl8CAMhZa634RylsSqi
  61655. Md5mBPfAdOhx3v89WcyWJhKLhZVXGqtrdQtEPREoPHtht+KPZ0/l7DxMYIBpVzgeAVuNVejH38DM
  61656. dyM0SXV89pgR6y3e7UEuFAUCf+D+IOs15xGsIs5XPd7JMG0QA4XN8f+MFrXBsj6IbGB/kE+V9/Yt
  61657. rQE5BwT6dYB9v0lQ7e/JxHwc64B+27bQ3RP+ydOc17KXqQIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  61658. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUxhfQvKjqAkPyGwaZXSuQILnXnOQwDQYJKoZI
  61659. hvcNAQELBQADggIBADRh2Va1EodVTd2jNTFGu6QHcrxfYWLopfsLN7E8trP6KZ1/AvWkyaiTt3px
  61660. KGmPc+FSkNrVvjrlt3ZqVoAh313m6Tqe5T72omnHKgqwGEfcIHB9UqM+WXzBusnIFUBhynLWcKzS
  61661. t/Ac5IYp8M7vaGPQtSCKFWGafoaYtMnCdvvMujAWzKNhxnQT5WvvoxXqA/4Ti2Tk08HS6IT7SdEQ
  61662. TXlm66r99I0xHnAUrdzeZxNMgRVhvLfZkXdxGYFgu/BYpbWcC/ePIlUnwEsBbTuZDdQdm2NnL9Du
  61663. DcpmvJRPpq3t/O5jrFc/ZSXPsoaP0Aj/uHYUbt7lJ+yreLVTubY/6CD50qi+YUbKh4yE8/nxoGib
  61664. Ih6BJpsQBJFxwAYf3KDTuVan45gtf4Od34wrnDKOMpTwATwiKp9Dwi7DmDkHOHv8XgBCH/MyJnmD
  61665. hPbl8MFREsALHgQjDFSlTC9JxUrRtm5gDWv8a4uFJGS3iQ6rJUdbPM9+Sb3H6QrG2vd+DhcI00iX
  61666. 0HGS8A85PjRqHH3Y8iKuu2n0M7SmSFXRDw4m6Oy2Cy2nhTXN/VnIn9HNPlopNLk9hM6xZdRZkZFW
  61667. dSHBd575euFgndOtBBj0fOtek49TSiIp+EgrPk2GrFt/ywaZWWDYWGWVjUTR939+J399roD1B0y2
  61668. PpxxVJkES/1Y+Zj0
  61669. -----END CERTIFICATE-----
  61670. DigiCert Assured ID Root G2
  61671. ===========================
  61672. -----BEGIN CERTIFICATE-----
  61673. MIIDljCCAn6gAwIBAgIQC5McOtY5Z+pnI7/Dr5r0SzANBgkqhkiG9w0BAQsFADBlMQswCQYDVQQG
  61674. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw
  61675. IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIwHhcNMTMwODAxMTIwMDAwWhcNMzgw
  61676. MTE1MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL
  61677. ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIw
  61678. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDZ5ygvUj82ckmIkzTz+GoeMVSAn61UQbVH
  61679. 35ao1K+ALbkKz3X9iaV9JPrjIgwrvJUXCzO/GU1BBpAAvQxNEP4HteccbiJVMWWXvdMX0h5i89vq
  61680. bFCMP4QMls+3ywPgym2hFEwbid3tALBSfK+RbLE4E9HpEgjAALAcKxHad3A2m67OeYfcgnDmCXRw
  61681. VWmvo2ifv922ebPynXApVfSr/5Vh88lAbx3RvpO704gqu52/clpWcTs/1PPRCv4o76Pu2ZmvA9OP
  61682. YLfykqGxvYmJHzDNw6YuYjOuFgJ3RFrngQo8p0Quebg/BLxcoIfhG69Rjs3sLPr4/m3wOnyqi+Rn
  61683. lTGNAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTO
  61684. w0q5mVXyuNtgv6l+vVa1lzan1jANBgkqhkiG9w0BAQsFAAOCAQEAyqVVjOPIQW5pJ6d1Ee88hjZv
  61685. 0p3GeDgdaZaikmkuOGybfQTUiaWxMTeKySHMq2zNixya1r9I0jJmwYrA8y8678Dj1JGG0VDjA9tz
  61686. d29KOVPt3ibHtX2vK0LRdWLjSisCx1BL4GnilmwORGYQRI+tBev4eaymG+g3NJ1TyWGqolKvSnAW
  61687. hsI6yLETcDbYz+70CjTVW0z9B5yiutkBclzzTcHdDrEcDcRjvq30FPuJ7KJBDkzMyFdA0G4Dqs0M
  61688. jomZmWzwPDCvON9vvKO+KSAnq3T/EyJ43pdSVR6DtVQgA+6uwE9W3jfMw3+qBCe703e4YtsXfJwo
  61689. IhNzbM8m9Yop5w==
  61690. -----END CERTIFICATE-----
  61691. DigiCert Assured ID Root G3
  61692. ===========================
  61693. -----BEGIN CERTIFICATE-----
  61694. MIICRjCCAc2gAwIBAgIQC6Fa+h3foLVJRK/NJKBs7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV
  61695. UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQwIgYD
  61696. VQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1
  61697. MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
  61698. d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwdjAQ
  61699. BgcqhkjOPQIBBgUrgQQAIgNiAAQZ57ysRGXtzbg/WPuNsVepRC0FFfLvC/8QdJ+1YlJfZn4f5dwb
  61700. RXkLzMZTCp2NXQLZqVneAlr2lSoOjThKiknGvMYDOAdfVdp+CW7if17QRSAPWXYQ1qAk8C3eNvJs
  61701. KTmjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTL0L2p4ZgF
  61702. UaFNN6KDec6NHSrkhDAKBggqhkjOPQQDAwNnADBkAjAlpIFFAmsSS3V0T8gj43DydXLefInwz5Fy
  61703. YZ5eEJJZVrmDxxDnOOlYJjZ91eQ0hjkCMHw2U/Aw5WJjOpnitqM7mzT6HtoQknFekROn3aRukswy
  61704. 1vUhZscv6pZjamVFkpUBtA==
  61705. -----END CERTIFICATE-----
  61706. DigiCert Global Root G2
  61707. =======================
  61708. -----BEGIN CERTIFICATE-----
  61709. MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBhMQswCQYDVQQG
  61710. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw
  61711. HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMjAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUx
  61712. MjAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3
  61713. dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEcyMIIBIjANBgkq
  61714. hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuzfNNNx7a8myaJCtSnX/RrohCgiN9RlUyfuI2/Ou8jqJ
  61715. kTx65qsGGmvPrC3oXgkkRLpimn7Wo6h+4FR1IAWsULecYxpsMNzaHxmx1x7e/dfgy5SDN67sH0NO
  61716. 3Xss0r0upS/kqbitOtSZpLYl6ZtrAGCSYP9PIUkY92eQq2EGnI/yuum06ZIya7XzV+hdG82MHauV
  61717. BJVJ8zUtluNJbd134/tJS7SsVQepj5WztCO7TG1F8PapspUwtP1MVYwnSlcUfIKdzXOS0xZKBgyM
  61718. UNGPHgm+F6HmIcr9g+UQvIOlCsRnKPZzFBQ9RnbDhxSJITRNrw9FDKZJobq7nMWxM4MphQIDAQAB
  61719. o0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUTiJUIBiV5uNu
  61720. 5g/6+rkS7QYXjzkwDQYJKoZIhvcNAQELBQADggEBAGBnKJRvDkhj6zHd6mcY1Yl9PMWLSn/pvtsr
  61721. F9+wX3N3KjITOYFnQoQj8kVnNeyIv/iPsGEMNKSuIEyExtv4NeF22d+mQrvHRAiGfzZ0JFrabA0U
  61722. WTW98kndth/Jsw1HKj2ZL7tcu7XUIOGZX1NGFdtom/DzMNU+MeKNhJ7jitralj41E6Vf8PlwUHBH
  61723. QRFXGU7Aj64GxJUTFy8bJZ918rGOmaFvE7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/
  61724. iyK5S9kJRaTepLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl
  61725. MrY=
  61726. -----END CERTIFICATE-----
  61727. DigiCert Global Root G3
  61728. =======================
  61729. -----BEGIN CERTIFICATE-----
  61730. MIICPzCCAcWgAwIBAgIQBVVWvPJepDU1w6QP1atFcjAKBggqhkjOPQQDAzBhMQswCQYDVQQGEwJV
  61731. UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAwHgYD
  61732. VQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMzAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAw
  61733. MDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5k
  61734. aWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEczMHYwEAYHKoZIzj0C
  61735. AQYFK4EEACIDYgAE3afZu4q4C/sLfyHS8L6+c/MzXRq8NOrexpu80JX28MzQC7phW1FGfp4tn+6O
  61736. YwwX7Adw9c+ELkCDnOg/QW07rdOkFFk2eJ0DQ+4QE2xy3q6Ip6FrtUPOZ9wj/wMco+I+o0IwQDAP
  61737. BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUs9tIpPmhxdiuNkHMEWNp
  61738. Yim8S8YwCgYIKoZIzj0EAwMDaAAwZQIxAK288mw/EkrRLTnDCgmXc/SINoyIJ7vmiI1Qhadj+Z4y
  61739. 3maTD/HMsQmP3Wyr+mt/oAIwOWZbwmSNuJ5Q3KjVSaLtx9zRSX8XAbjIho9OjIgrqJqpisXRAL34
  61740. VOKa5Vt8sycX
  61741. -----END CERTIFICATE-----
  61742. DigiCert Trusted Root G4
  61743. ========================
  61744. -----BEGIN CERTIFICATE-----
  61745. MIIFkDCCA3igAwIBAgIQBZsbV56OITLiOQe9p3d1XDANBgkqhkiG9w0BAQwFADBiMQswCQYDVQQG
  61746. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSEw
  61747. HwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1
  61748. MTIwMDAwWjBiMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
  61749. d3cuZGlnaWNlcnQuY29tMSEwHwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwggIiMA0G
  61750. CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC/5pBzaN675F1KPDAiMGkz7MKnJS7JIT3yithZwuEp
  61751. pz1Yq3aaza57G4QNxDAf8xukOBbrVsaXbR2rsnnyyhHS5F/WBTxSD1Ifxp4VpX6+n6lXFllVcq9o
  61752. k3DCsrp1mWpzMpTREEQQLt+C8weE5nQ7bXHiLQwb7iDVySAdYyktzuxeTsiT+CFhmzTrBcZe7Fsa
  61753. vOvJz82sNEBfsXpm7nfISKhmV1efVFiODCu3T6cw2Vbuyntd463JT17lNecxy9qTXtyOj4DatpGY
  61754. QJB5w3jHtrHEtWoYOAMQjdjUN6QuBX2I9YI+EJFwq1WCQTLX2wRzKm6RAXwhTNS8rhsDdV14Ztk6
  61755. MUSaM0C/CNdaSaTC5qmgZ92kJ7yhTzm1EVgX9yRcRo9k98FpiHaYdj1ZXUJ2h4mXaXpI8OCiEhtm
  61756. mnTK3kse5w5jrubU75KSOp493ADkRSWJtppEGSt+wJS00mFt6zPZxd9LBADMfRyVw4/3IbKyEbe7
  61757. f/LVjHAsQWCqsWMYRJUadmJ+9oCw++hkpjPRiQfhvbfmQ6QYuKZ3AeEPlAwhHbJUKSWJbOUOUlFH
  61758. dL4mrLZBdd56rF+NP8m800ERElvlEFDrMcXKchYiCd98THU/Y+whX8QgUWtvsauGi0/C1kVfnSD8
  61759. oR7FwI+isX4KJpn15GkvmB0t9dmpsh3lGwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1Ud
  61760. DwEB/wQEAwIBhjAdBgNVHQ4EFgQU7NfjgtJxXWRM3y5nP+e6mK4cD08wDQYJKoZIhvcNAQEMBQAD
  61761. ggIBALth2X2pbL4XxJEbw6GiAI3jZGgPVs93rnD5/ZpKmbnJeFwMDF/k5hQpVgs2SV1EY+CtnJYY
  61762. ZhsjDT156W1r1lT40jzBQ0CuHVD1UvyQO7uYmWlrx8GnqGikJ9yd+SeuMIW59mdNOj6PWTkiU0Tr
  61763. yF0Dyu1Qen1iIQqAyHNm0aAFYF/opbSnr6j3bTWcfFqK1qI4mfN4i/RN0iAL3gTujJtHgXINwBQy
  61764. 7zBZLq7gcfJW5GqXb5JQbZaNaHqasjYUegbyJLkJEVDXCLG4iXqEI2FCKeWjzaIgQdfRnGTZ6iah
  61765. ixTXTBmyUEFxPT9NcCOGDErcgdLMMpSEDQgJlxxPwO5rIHQw0uA5NBCFIRUBCOhVMt5xSdkoF1BN
  61766. 5r5N0XWs0Mr7QbhDparTwwVETyw2m+L64kW4I1NsBm9nVX9GtUw/bihaeSbSpKhil9Ie4u1Ki7wb
  61767. /UdKDd9nZn6yW0HQO+T0O/QEY+nvwlQAUaCKKsnOeMzV6ocEGLPOr0mIr/OSmbaz5mEP0oUA51Aa
  61768. 5BuVnRmhuZyxm7EAHu/QD09CbMkKvO5D+jpxpchNJqU1/YldvIViHTLSoCtU7ZpXwdv6EM8Zt4tK
  61769. G48BtieVU+i2iW1bvGjUI+iLUaJW+fCmgKDWHrO8Dw9TdSmq6hN35N6MgSGtBxBHEa2HPQfRdbzP
  61770. 82Z+
  61771. -----END CERTIFICATE-----
  61772. COMODO RSA Certification Authority
  61773. ==================================
  61774. -----BEGIN CERTIFICATE-----
  61775. MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCBhTELMAkGA1UE
  61776. BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG
  61777. A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlv
  61778. biBBdXRob3JpdHkwHhcNMTAwMTE5MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMC
  61779. R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE
  61780. ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBB
  61781. dXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCR6FSS0gpWsawNJN3Fz0Rn
  61782. dJkrN6N9I3AAcbxT38T6KhKPS38QVr2fcHK3YX/JSw8Xpz3jsARh7v8Rl8f0hj4K+j5c+ZPmNHrZ
  61783. FGvnnLOFoIJ6dq9xkNfs/Q36nGz637CC9BR++b7Epi9Pf5l/tfxnQ3K9DADWietrLNPtj5gcFKt+
  61784. 5eNu/Nio5JIk2kNrYrhV/erBvGy2i/MOjZrkm2xpmfh4SDBF1a3hDTxFYPwyllEnvGfDyi62a+pG
  61785. x8cgoLEfZd5ICLqkTqnyg0Y3hOvozIFIQ2dOciqbXL1MGyiKXCJ7tKuY2e7gUYPDCUZObT6Z+pUX
  61786. 2nwzV0E8jVHtC7ZcryxjGt9XyD+86V3Em69FmeKjWiS0uqlWPc9vqv9JWL7wqP/0uK3pN/u6uPQL
  61787. OvnoQ0IeidiEyxPx2bvhiWC4jChWrBQdnArncevPDt09qZahSL0896+1DSJMwBGB7FY79tOi4lu3
  61788. sgQiUpWAk2nojkxl8ZEDLXB0AuqLZxUpaVICu9ffUGpVRr+goyhhf3DQw6KqLCGqR84onAZFdr+C
  61789. GCe01a60y1Dma/RMhnEw6abfFobg2P9A3fvQQoh/ozM6LlweQRGBY84YcWsr7KaKtzFcOmpH4MN5
  61790. WdYgGq/yapiqcrxXStJLnbsQ/LBMQeXtHT1eKJ2czL+zUdqnR+WEUwIDAQABo0IwQDAdBgNVHQ4E
  61791. FgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8w
  61792. DQYJKoZIhvcNAQEMBQADggIBAArx1UaEt65Ru2yyTUEUAJNMnMvlwFTPoCWOAvn9sKIN9SCYPBMt
  61793. rFaisNZ+EZLpLrqeLppysb0ZRGxhNaKatBYSaVqM4dc+pBroLwP0rmEdEBsqpIt6xf4FpuHA1sj+
  61794. nq6PK7o9mfjYcwlYRm6mnPTXJ9OV2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSg
  61795. tZx8jb8uk2IntznaFxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwW
  61796. sRqZCuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiKboHGhfKp
  61797. pC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmckejkk9u+UJueBPSZI9FoJA
  61798. zMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yLS0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHq
  61799. ZJx64SIDqZxubw5lT2yHh17zbqD5daWbQOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk52
  61800. 7RH89elWsn2/x20Kk4yl0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7I
  61801. LaZRfyHBNVOFBkpdn627G190
  61802. -----END CERTIFICATE-----
  61803. USERTrust RSA Certification Authority
  61804. =====================================
  61805. -----BEGIN CERTIFICATE-----
  61806. MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCBiDELMAkGA1UE
  61807. BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK
  61808. ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh
  61809. dGlvbiBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UE
  61810. BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK
  61811. ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh
  61812. dGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCAEmUXNg7D2wiz
  61813. 0KxXDXbtzSfTTK1Qg2HiqiBNCS1kCdzOiZ/MPans9s/B3PHTsdZ7NygRK0faOca8Ohm0X6a9fZ2j
  61814. Y0K2dvKpOyuR+OJv0OwWIJAJPuLodMkYtJHUYmTbf6MG8YgYapAiPLz+E/CHFHv25B+O1ORRxhFn
  61815. RghRy4YUVD+8M/5+bJz/Fp0YvVGONaanZshyZ9shZrHUm3gDwFA66Mzw3LyeTP6vBZY1H1dat//O
  61816. +T23LLb2VN3I5xI6Ta5MirdcmrS3ID3KfyI0rn47aGYBROcBTkZTmzNg95S+UzeQc0PzMsNT79uq
  61817. /nROacdrjGCT3sTHDN/hMq7MkztReJVni+49Vv4M0GkPGw/zJSZrM233bkf6c0Plfg6lZrEpfDKE
  61818. Y1WJxA3Bk1QwGROs0303p+tdOmw1XNtB1xLaqUkL39iAigmTYo61Zs8liM2EuLE/pDkP2QKe6xJM
  61819. lXzzawWpXhaDzLhn4ugTncxbgtNMs+1b/97lc6wjOy0AvzVVdAlJ2ElYGn+SNuZRkg7zJn0cTRe8
  61820. yexDJtC/QV9AqURE9JnnV4eeUB9XVKg+/XRjL7FQZQnmWEIuQxpMtPAlR1n6BB6T1CZGSlCBst6+
  61821. eLf8ZxXhyVeEHg9j1uliutZfVS7qXMYoCAQlObgOK6nyTJccBz8NUvXt7y+CDwIDAQABo0IwQDAd
  61822. BgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rIDZsswDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQF
  61823. MAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAFzUfA3P9wF9QZllDHPFUp/L+M+ZBn8b2kMVn54CVVeW
  61824. FPFSPCeHlCjtHzoBN6J2/FNQwISbxmtOuowhT6KOVWKR82kV2LyI48SqC/3vqOlLVSoGIG1VeCkZ
  61825. 7l8wXEskEVX/JJpuXior7gtNn3/3ATiUFJVDBwn7YKnuHKsSjKCaXqeYalltiz8I+8jRRa8YFWSQ
  61826. Eg9zKC7F4iRO/Fjs8PRF/iKz6y+O0tlFYQXBl2+odnKPi4w2r78NBc5xjeambx9spnFixdjQg3IM
  61827. 8WcRiQycE0xyNN+81XHfqnHd4blsjDwSXWXavVcStkNr/+XeTWYRUc+ZruwXtuhxkYzeSf7dNXGi
  61828. FSeUHM9h4ya7b6NnJSFd5t0dCy5oGzuCr+yDZ4XUmFF0sbmZgIn/f3gZXHlKYC6SQK5MNyosycdi
  61829. yA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9c
  61830. J2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRBVXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGw
  61831. sAvgnEzDHNb842m1R0aBL6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gx
  61832. Q+6IHdfGjjxDah2nGN59PRbxYvnKkKj9
  61833. -----END CERTIFICATE-----
  61834. USERTrust ECC Certification Authority
  61835. =====================================
  61836. -----BEGIN CERTIFICATE-----
  61837. MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDELMAkGA1UEBhMC
  61838. VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU
  61839. aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv
  61840. biBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMC
  61841. VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU
  61842. aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv
  61843. biBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQarFRaqfloI+d61SRvU8Za2EurxtW2
  61844. 0eZzca7dnNYMYf3boIkDuAUU7FfO7l0/4iGzzvfUinngo4N+LZfQYcTxmdwlkWOrfzCjtHDix6Ez
  61845. nPO/LlxTsV+zfTJ/ijTjeXmjQjBAMB0GA1UdDgQWBBQ64QmG1M8ZwpZ2dEl23OA1xmNjmjAOBgNV
  61846. HQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjA2Z6EWCNzklwBB
  61847. HU6+4WMBzzuqQhFkoJ2UOQIReVx7Hfpkue4WQrO/isIJxOzksU0CMQDpKmFHjFJKS04YcPbWRNZu
  61848. 9YO6bVi9JNlWSOrvxKJGgYhqOkbRqZtNyWHa0V1Xahg=
  61849. -----END CERTIFICATE-----
  61850. GlobalSign ECC Root CA - R4
  61851. ===========================
  61852. -----BEGIN CERTIFICATE-----
  61853. MIIB4TCCAYegAwIBAgIRKjikHJYKBN5CsiilC+g0mAIwCgYIKoZIzj0EAwIwUDEkMCIGA1UECxMb
  61854. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  61855. EwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoXDTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMb
  61856. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  61857. EwpHbG9iYWxTaWduMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEuMZ5049sJQ6fLjkZHAOkrprl
  61858. OQcJFspjsbmG+IpXwVfOQvpzofdlQv8ewQCybnMO/8ch5RikqtlxP6jUuc6MHaNCMEAwDgYDVR0P
  61859. AQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFFSwe61FuOJAf/sKbvu+M8k8o4TV
  61860. MAoGCCqGSM49BAMCA0gAMEUCIQDckqGgE6bPA7DmxCGXkPoUVy0D7O48027KqGx2vKLeuwIgJ6iF
  61861. JzWbVsaj8kfSt24bAgAXqmemFZHe+pTsewv4n4Q=
  61862. -----END CERTIFICATE-----
  61863. GlobalSign ECC Root CA - R5
  61864. ===========================
  61865. -----BEGIN CERTIFICATE-----
  61866. MIICHjCCAaSgAwIBAgIRYFlJ4CYuu1X5CneKcflK2GwwCgYIKoZIzj0EAwMwUDEkMCIGA1UECxMb
  61867. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  61868. EwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoXDTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMb
  61869. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  61870. EwpHbG9iYWxTaWduMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAER0UOlvt9Xb/pOdEh+J8LttV7HpI6
  61871. SFkc8GIxLcB6KP4ap1yztsyX50XUWPrRd21DosCHZTQKH3rd6zwzocWdTaRvQZU4f8kehOvRnkmS
  61872. h5SHDDqFSmafnVmTTZdhBoZKo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd
  61873. BgNVHQ4EFgQUPeYpSJvqB8ohREom3m7e0oPQn1kwCgYIKoZIzj0EAwMDaAAwZQIxAOVpEslu28Yx
  61874. uglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7
  61875. yFz9SO8NdCKoCOJuxUnOxwy8p2Fp8fc74SrL+SvzZpA3
  61876. -----END CERTIFICATE-----
  61877. Staat der Nederlanden Root CA - G3
  61878. ==================================
  61879. -----BEGIN CERTIFICATE-----
  61880. MIIFdDCCA1ygAwIBAgIEAJiiOTANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJOTDEeMBwGA1UE
  61881. CgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSswKQYDVQQDDCJTdGFhdCBkZXIgTmVkZXJsYW5kZW4g
  61882. Um9vdCBDQSAtIEczMB4XDTEzMTExNDExMjg0MloXDTI4MTExMzIzMDAwMFowWjELMAkGA1UEBhMC
  61883. TkwxHjAcBgNVBAoMFVN0YWF0IGRlciBOZWRlcmxhbmRlbjErMCkGA1UEAwwiU3RhYXQgZGVyIE5l
  61884. ZGVybGFuZGVuIFJvb3QgQ0EgLSBHMzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAL4y
  61885. olQPcPssXFnrbMSkUeiFKrPMSjTysF/zDsccPVMeiAho2G89rcKezIJnByeHaHE6n3WWIkYFsO2t
  61886. x1ueKt6c/DrGlaf1F2cY5y9JCAxcz+bMNO14+1Cx3Gsy8KL+tjzk7FqXxz8ecAgwoNzFs21v0IJy
  61887. EavSgWhZghe3eJJg+szeP4TrjTgzkApyI/o1zCZxMdFyKJLZWyNtZrVtB0LrpjPOktvA9mxjeM3K
  61888. Tj215VKb8b475lRgsGYeCasH/lSJEULR9yS6YHgamPfJEf0WwTUaVHXvQ9Plrk7O53vDxk5hUUur
  61889. mkVLoR9BvUhTFXFkC4az5S6+zqQbwSmEorXLCCN2QyIkHxcE1G6cxvx/K2Ya7Irl1s9N9WMJtxU5
  61890. 1nus6+N86U78dULI7ViVDAZCopz35HCz33JvWjdAidiFpNfxC95DGdRKWCyMijmev4SH8RY7Ngzp
  61891. 07TKbBlBUgmhHbBqv4LvcFEhMtwFdozL92TkA1CvjJFnq8Xy7ljY3r735zHPbMk7ccHViLVlvMDo
  61892. FxcHErVc0qsgk7TmgoNwNsXNo42ti+yjwUOH5kPiNL6VizXtBznaqB16nzaeErAMZRKQFWDZJkBE
  61893. 41ZgpRDUajz9QdwOWke275dhdU/Z/seyHdTtXUmzqWrLZoQT1Vyg3N9udwbRcXXIV2+vD3dbAgMB
  61894. AAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBRUrfrHkleu
  61895. yjWcLhL75LpdINyUVzANBgkqhkiG9w0BAQsFAAOCAgEAMJmdBTLIXg47mAE6iqTnB/d6+Oea31BD
  61896. U5cqPco8R5gu4RV78ZLzYdqQJRZlwJ9UXQ4DO1t3ApyEtg2YXzTdO2PCwyiBwpwpLiniyMMB8jPq
  61897. KqrMCQj3ZWfGzd/TtiunvczRDnBfuCPRy5FOCvTIeuXZYzbB1N/8Ipf3YF3qKS9Ysr1YvY2WTxB1
  61898. v0h7PVGHoTx0IsL8B3+A3MSs/mrBcDCw6Y5p4ixpgZQJut3+TcCDjJRYwEYgr5wfAvg1VUkvRtTA
  61899. 8KCWAg8zxXHzniN9lLf9OtMJgwYh/WA9rjLA0u6NpvDntIJ8CsxwyXmA+P5M9zWEGYox+wrZ13+b
  61900. 8KKaa8MFSu1BYBQw0aoRQm7TIwIEC8Zl3d1Sd9qBa7Ko+gE4uZbqKmxnl4mUnrzhVNXkanjvSr0r
  61901. mj1AfsbAddJu+2gw7OyLnflJNZoaLNmzlTnVHpL3prllL+U9bTpITAjc5CgSKL59NVzq4BZ+Extq
  61902. 1z7XnvwtdbLBFNUjA9tbbws+eC8N3jONFrdI54OagQ97wUNNVQQXOEpR1VmiiXTTn74eS9fGbbeI
  61903. JG9gkaSChVtWQbzQRKtqE77RLFi3EjNYsjdj3BP1lB0/QFH1T/U67cjF68IeHRaVesd+QnGTbksV
  61904. tzDfqu1XhUisHWrdOWnk4Xl4vs4Fv6EM94B7IWcnMFk=
  61905. -----END CERTIFICATE-----
  61906. Staat der Nederlanden EV Root CA
  61907. ================================
  61908. -----BEGIN CERTIFICATE-----
  61909. MIIFcDCCA1igAwIBAgIEAJiWjTANBgkqhkiG9w0BAQsFADBYMQswCQYDVQQGEwJOTDEeMBwGA1UE
  61910. CgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSkwJwYDVQQDDCBTdGFhdCBkZXIgTmVkZXJsYW5kZW4g
  61911. RVYgUm9vdCBDQTAeFw0xMDEyMDgxMTE5MjlaFw0yMjEyMDgxMTEwMjhaMFgxCzAJBgNVBAYTAk5M
  61912. MR4wHAYDVQQKDBVTdGFhdCBkZXIgTmVkZXJsYW5kZW4xKTAnBgNVBAMMIFN0YWF0IGRlciBOZWRl
  61913. cmxhbmRlbiBFViBSb290IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA48d+ifkk
  61914. SzrSM4M1LGns3Amk41GoJSt5uAg94JG6hIXGhaTK5skuU6TJJB79VWZxXSzFYGgEt9nCUiY4iKTW
  61915. O0Cmws0/zZiTs1QUWJZV1VD+hq2kY39ch/aO5ieSZxeSAgMs3NZmdO3dZ//BYY1jTw+bbRcwJu+r
  61916. 0h8QoPnFfxZpgQNH7R5ojXKhTbImxrpsX23Wr9GxE46prfNeaXUmGD5BKyF/7otdBwadQ8QpCiv8
  61917. Kj6GyzyDOvnJDdrFmeK8eEEzduG/L13lpJhQDBXd4Pqcfzho0LKmeqfRMb1+ilgnQ7O6M5HTp5gV
  61918. XJrm0w912fxBmJc+qiXbj5IusHsMX/FjqTf5m3VpTCgmJdrV8hJwRVXj33NeN/UhbJCONVrJ0yPr
  61919. 08C+eKxCKFhmpUZtcALXEPlLVPxdhkqHz3/KRawRWrUgUY0viEeXOcDPusBCAUCZSCELa6fS/ZbV
  61920. 0b5GnUngC6agIk440ME8MLxwjyx1zNDFjFE7PZQIZCZhfbnDZY8UnCHQqv0XcgOPvZuM5l5Tnrmd
  61921. 74K74bzickFbIZTTRTeU0d8JOV3nI6qaHcptqAqGhYqCvkIH1vI4gnPah1vlPNOePqc7nvQDs/nx
  61922. fRN0Av+7oeX6AHkcpmZBiFxgV6YuCcS6/ZrPpx9Aw7vMWgpVSzs4dlG4Y4uElBbmVvMCAwEAAaNC
  61923. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFP6rAJCYniT8qcwa
  61924. ivsnuL8wbqg7MA0GCSqGSIb3DQEBCwUAA4ICAQDPdyxuVr5Os7aEAJSrR8kN0nbHhp8dB9O2tLsI
  61925. eK9p0gtJ3jPFrK3CiAJ9Brc1AsFgyb/E6JTe1NOpEyVa/m6irn0F3H3zbPB+po3u2dfOWBfoqSmu
  61926. c0iH55vKbimhZF8ZE/euBhD/UcabTVUlT5OZEAFTdfETzsemQUHSv4ilf0X8rLiltTMMgsT7B/Zq
  61927. 5SWEXwbKwYY5EdtYzXc7LMJMD16a4/CrPmEbUCTCwPTxGfARKbalGAKb12NMcIxHowNDXLldRqAN
  61928. b/9Zjr7dn3LDWyvfjFvO5QxGbJKyCqNMVEIYFRIYvdr8unRu/8G2oGTYqV9Vrp9canaW2HNnh/tN
  61929. f1zuacpzEPuKqf2evTY4SUmH9A4U8OmHuD+nT3pajnnUk+S7aFKErGzp85hwVXIy+TSrK0m1zSBi
  61930. 5Dp6Z2Orltxtrpfs/J92VoguZs9btsmksNcFuuEnL5O7Jiqik7Ab846+HUCjuTaPPoIaGl6I6lD4
  61931. WeKDRikL40Rc4ZW2aZCaFG+XroHPaO+Zmr615+F/+PoTRxZMzG0IQOeLeG9QgkRQP2YGiqtDhFZK
  61932. DyAthg710tvSeopLzaXoTvFeJiUBWSOgftL2fiFX1ye8FVdMpEbB4IMeDExNH08GGeL5qPQ6gqGy
  61933. eUN51q1veieQA6TqJIc/2b3Z6fJfUEkc7uzXLg==
  61934. -----END CERTIFICATE-----
  61935. IdenTrust Commercial Root CA 1
  61936. ==============================
  61937. -----BEGIN CERTIFICATE-----
  61938. MIIFYDCCA0igAwIBAgIQCgFCgAAAAUUjyES1AAAAAjANBgkqhkiG9w0BAQsFADBKMQswCQYDVQQG
  61939. EwJVUzESMBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBS
  61940. b290IENBIDEwHhcNMTQwMTE2MTgxMjIzWhcNMzQwMTE2MTgxMjIzWjBKMQswCQYDVQQGEwJVUzES
  61941. MBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBSb290IENB
  61942. IDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCnUBneP5k91DNG8W9RYYKyqU+PZ4ld
  61943. hNlT3Qwo2dfw/66VQ3KZ+bVdfIrBQuExUHTRgQ18zZshq0PirK1ehm7zCYofWjK9ouuU+ehcCuz/
  61944. mNKvcbO0U59Oh++SvL3sTzIwiEsXXlfEU8L2ApeN2WIrvyQfYo3fw7gpS0l4PJNgiCL8mdo2yMKi
  61945. 1CxUAGc1bnO/AljwpN3lsKImesrgNqUZFvX9t++uP0D1bVoE/c40yiTcdCMbXTMTEl3EASX2MN0C
  61946. XZ/g1Ue9tOsbobtJSdifWwLziuQkkORiT0/Br4sOdBeo0XKIanoBScy0RnnGF7HamB4HWfp1IYVl
  61947. 3ZBWzvurpWCdxJ35UrCLvYf5jysjCiN2O/cz4ckA82n5S6LgTrx+kzmEB/dEcH7+B1rlsazRGMzy
  61948. NeVJSQjKVsk9+w8YfYs7wRPCTY/JTw436R+hDmrfYi7LNQZReSzIJTj0+kuniVyc0uMNOYZKdHzV
  61949. WYfCP04MXFL0PfdSgvHqo6z9STQaKPNBiDoT7uje/5kdX7rL6B7yuVBgwDHTc+XvvqDtMwt0viAg
  61950. xGds8AgDelWAf0ZOlqf0Hj7h9tgJ4TNkK2PXMl6f+cB7D3hvl7yTmvmcEpB4eoCHFddydJxVdHix
  61951. uuFucAS6T6C6aMN7/zHwcz09lCqxC0EOoP5NiGVreTO01wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMC
  61952. AQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU7UQZwNPwBovupHu+QucmVMiONnYwDQYJKoZI
  61953. hvcNAQELBQADggIBAA2ukDL2pkt8RHYZYR4nKM1eVO8lvOMIkPkp165oCOGUAFjvLi5+U1KMtlwH
  61954. 6oi6mYtQlNeCgN9hCQCTrQ0U5s7B8jeUeLBfnLOic7iPBZM4zY0+sLj7wM+x8uwtLRvM7Kqas6pg
  61955. ghstO8OEPVeKlh6cdbjTMM1gCIOQ045U8U1mwF10A0Cj7oV+wh93nAbowacYXVKV7cndJZ5t+qnt
  61956. ozo00Fl72u1Q8zW/7esUTTHHYPTa8Yec4kjixsU3+wYQ+nVZZjFHKdp2mhzpgq7vmrlR94gjmmmV
  61957. YjzlVYA211QC//G5Xc7UI2/YRYRKW2XviQzdFKcgyxilJbQN+QHwotL0AMh0jqEqSI5l2xPE4iUX
  61958. feu+h1sXIFRRk0pTAwvsXcoz7WL9RccvW9xYoIA55vrX/hMUpu09lEpCdNTDd1lzzY9GvlU47/ro
  61959. kTLql1gEIt44w8y8bckzOmoKaT+gyOpyj4xjhiO9bTyWnpXgSUyqorkqG5w2gXjtw+hG4iZZRHUe
  61960. 2XWJUc0QhJ1hYMtd+ZciTY6Y5uN/9lu7rs3KSoFrXgvzUeF0K+l+J6fZmUlO+KWA2yUPHGNiiskz
  61961. Z2s8EIPGrd6ozRaOjfAHN3Gf8qv8QfXBi+wAN10J5U6A7/qxXDgGpRtK4dw4LTzcqx+QGtVKnO7R
  61962. cGzM7vRX+Bi6hG6H
  61963. -----END CERTIFICATE-----
  61964. IdenTrust Public Sector Root CA 1
  61965. =================================
  61966. -----BEGIN CERTIFICATE-----
  61967. MIIFZjCCA06gAwIBAgIQCgFCgAAAAUUjz0Z8AAAAAjANBgkqhkiG9w0BAQsFADBNMQswCQYDVQQG
  61968. EwJVUzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3Rv
  61969. ciBSb290IENBIDEwHhcNMTQwMTE2MTc1MzMyWhcNMzQwMTE2MTc1MzMyWjBNMQswCQYDVQQGEwJV
  61970. UzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3RvciBS
  61971. b290IENBIDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2IpT8pEiv6EdrCvsnduTy
  61972. P4o7ekosMSqMjbCpwzFrqHd2hCa2rIFCDQjrVVi7evi8ZX3yoG2LqEfpYnYeEe4IFNGyRBb06tD6
  61973. Hi9e28tzQa68ALBKK0CyrOE7S8ItneShm+waOh7wCLPQ5CQ1B5+ctMlSbdsHyo+1W/CD80/HLaXI
  61974. rcuVIKQxKFdYWuSNG5qrng0M8gozOSI5Cpcu81N3uURF/YTLNiCBWS2ab21ISGHKTN9T0a9SvESf
  61975. qy9rg3LvdYDaBjMbXcjaY8ZNzaxmMc3R3j6HEDbhuaR672BQssvKplbgN6+rNBM5Jeg5ZuSYeqoS
  61976. mJxZZoY+rfGwyj4GD3vwEUs3oERte8uojHH01bWRNszwFcYr3lEXsZdMUD2xlVl8BX0tIdUAvwFn
  61977. ol57plzy9yLxkA2T26pEUWbMfXYD62qoKjgZl3YNa4ph+bz27nb9cCvdKTz4Ch5bQhyLVi9VGxyh
  61978. LrXHFub4qjySjmm2AcG1hp2JDws4lFTo6tyePSW8Uybt1as5qsVATFSrsrTZ2fjXctscvG29ZV/v
  61979. iDUqZi/u9rNl8DONfJhBaUYPQxxp+pu10GFqzcpL2UyQRqsVWaFHVCkugyhfHMKiq3IXAAaOReyL
  61980. 4jM9f9oZRORicsPfIsbyVtTdX5Vy7W1f90gDW/3FKqD2cyOEEBsB5wIDAQABo0IwQDAOBgNVHQ8B
  61981. Af8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU43HgntinQtnbcZFrlJPrw6PRFKMw
  61982. DQYJKoZIhvcNAQELBQADggIBAEf63QqwEZE4rU1d9+UOl1QZgkiHVIyqZJnYWv6IAcVYpZmxI1Qj
  61983. t2odIFflAWJBF9MJ23XLblSQdf4an4EKwt3X9wnQW3IV5B4Jaj0z8yGa5hV+rVHVDRDtfULAj+7A
  61984. mgjVQdZcDiFpboBhDhXAuM/FSRJSzL46zNQuOAXeNf0fb7iAaJg9TaDKQGXSc3z1i9kKlT/YPyNt
  61985. GtEqJBnZhbMX73huqVjRI9PHE+1yJX9dsXNw0H8GlwmEKYBhHfpe/3OsoOOJuBxxFcbeMX8S3OFt
  61986. m6/n6J91eEyrRjuazr8FGF1NFTwWmhlQBJqymm9li1JfPFgEKCXAZmExfrngdbkaqIHWchezxQMx
  61987. NRF4eKLg6TCMf4DfWN88uieW4oA0beOY02QnrEh+KHdcxiVhJfiFDGX6xDIvpZgF5PgLZxYWxoK4
  61988. Mhn5+bl53B/N66+rDt0b20XkeucC4pVd/GnwU2lhlXV5C15V5jgclKlZM57IcXR5f1GJtshquDDI
  61989. ajjDbp7hNxbqBWJMWxJH7ae0s1hWx0nzfxJoCTFx8G34Tkf71oXuxVhAGaQdp/lLQzfcaFpPz+vC
  61990. ZHTetBXZ9FRUGi8c15dxVJCO2SCdUyt/q4/i6jC8UDfv8Ue1fXwsBOxonbRJRBD0ckscZOf85muQ
  61991. 3Wl9af0AVqW3rLatt8o+Ae+c
  61992. -----END CERTIFICATE-----
  61993. Entrust Root Certification Authority - G2
  61994. =========================================
  61995. -----BEGIN CERTIFICATE-----
  61996. MIIEPjCCAyagAwIBAgIESlOMKDANBgkqhkiG9w0BAQsFADCBvjELMAkGA1UEBhMCVVMxFjAUBgNV
  61997. BAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVy
  61998. bXMxOTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ug
  61999. b25seTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIw
  62000. HhcNMDkwNzA3MTcyNTU0WhcNMzAxMjA3MTc1NTU0WjCBvjELMAkGA1UEBhMCVVMxFjAUBgNVBAoT
  62001. DUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMx
  62002. OTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25s
  62003. eTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIwggEi
  62004. MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC6hLZy254Ma+KZ6TABp3bqMriVQRrJ2mFOWHLP
  62005. /vaCeb9zYQYKpSfYs1/TRU4cctZOMvJyig/3gxnQaoCAAEUesMfnmr8SVycco2gvCoe9amsOXmXz
  62006. HHfV1IWNcCG0szLni6LVhjkCsbjSR87kyUnEO6fe+1R9V77w6G7CebI6C1XiUJgWMhNcL3hWwcKU
  62007. s/Ja5CeanyTXxuzQmyWC48zCxEXFjJd6BmsqEZ+pCm5IO2/b1BEZQvePB7/1U1+cPvQXLOZprE4y
  62008. TGJ36rfo5bs0vBmLrpxR57d+tVOxMyLlbc9wPBr64ptntoP0jaWvYkxN4FisZDQSA/i2jZRjJKRx
  62009. AgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqciZ6
  62010. 0B7vfec7aVHUbI2fkBJmqzANBgkqhkiG9w0BAQsFAAOCAQEAeZ8dlsa2eT8ijYfThwMEYGprmi5Z
  62011. iXMRrEPR9RP/jTkrwPK9T3CMqS/qF8QLVJ7UG5aYMzyorWKiAHarWWluBh1+xLlEjZivEtRh2woZ
  62012. Rkfz6/djwUAFQKXSt/S1mja/qYh2iARVBCuch38aNzx+LaUa2NSJXsq9rD1s2G2v1fN2D807iDgi
  62013. nWyTmsQ9v4IbZT+mD12q/OWyFcq1rca8PdCE6OoGcrBNOTJ4vz4RnAuknZoh8/CbCzB428Hch0P+
  62014. vGOaysXCHMnHjf87ElgI5rY97HosTvuDls4MPGmHVHOkc8KT/1EQrBVUAdj8BbGJoX90g5pJ19xO
  62015. e4pIb4tF9g==
  62016. -----END CERTIFICATE-----
  62017. Entrust Root Certification Authority - EC1
  62018. ==========================================
  62019. -----BEGIN CERTIFICATE-----
  62020. MIIC+TCCAoCgAwIBAgINAKaLeSkAAAAAUNCR+TAKBggqhkjOPQQDAzCBvzELMAkGA1UEBhMCVVMx
  62021. FjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVn
  62022. YWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDEyIEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXpl
  62023. ZCB1c2Ugb25seTEzMDEGA1UEAxMqRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  62024. IC0gRUMxMB4XDTEyMTIxODE1MjUzNloXDTM3MTIxODE1NTUzNlowgb8xCzAJBgNVBAYTAlVTMRYw
  62025. FAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0L2xlZ2Fs
  62026. LXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxMiBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhvcml6ZWQg
  62027. dXNlIG9ubHkxMzAxBgNVBAMTKkVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAt
  62028. IEVDMTB2MBAGByqGSM49AgEGBSuBBAAiA2IABIQTydC6bUF74mzQ61VfZgIaJPRbiWlH47jCffHy
  62029. AsWfoPZb1YsGGYZPUxBtByQnoaD41UcZYUx9ypMn6nQM72+WCf5j7HBdNq1nd67JnXxVRDqiY1Ef
  62030. 9eNi1KlHBz7MIKNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
  62031. FLdj5xrdjekIplWDpOBqUEFlEUJJMAoGCCqGSM49BAMDA2cAMGQCMGF52OVCR98crlOZF7ZvHH3h
  62032. vxGU0QOIdeSNiaSKd0bebWHvAvX7td/M/k7//qnmpwIwW5nXhTcGtXsI/esni0qU+eH6p44mCOh8
  62033. kmhtc9hvJqwhAriZtyZBWyVgrtBIGu4G
  62034. -----END CERTIFICATE-----
  62035. CFCA EV ROOT
  62036. ============
  62037. -----BEGIN CERTIFICATE-----
  62038. MIIFjTCCA3WgAwIBAgIEGErM1jANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJDTjEwMC4GA1UE
  62039. CgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQDDAxDRkNB
  62040. IEVWIFJPT1QwHhcNMTIwODA4MDMwNzAxWhcNMjkxMjMxMDMwNzAxWjBWMQswCQYDVQQGEwJDTjEw
  62041. MC4GA1UECgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQD
  62042. DAxDRkNBIEVWIFJPT1QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDXXWvNED8fBVnV
  62043. BU03sQ7smCuOFR36k0sXgiFxEFLXUWRwFsJVaU2OFW2fvwwbwuCjZ9YMrM8irq93VCpLTIpTUnrD
  62044. 7i7es3ElweldPe6hL6P3KjzJIx1qqx2hp/Hz7KDVRM8Vz3IvHWOX6Jn5/ZOkVIBMUtRSqy5J35DN
  62045. uF++P96hyk0g1CXohClTt7GIH//62pCfCqktQT+x8Rgp7hZZLDRJGqgG16iI0gNyejLi6mhNbiyW
  62046. ZXvKWfry4t3uMCz7zEasxGPrb382KzRzEpR/38wmnvFyXVBlWY9ps4deMm/DGIq1lY+wejfeWkU7
  62047. xzbh72fROdOXW3NiGUgthxwG+3SYIElz8AXSG7Ggo7cbcNOIabla1jj0Ytwli3i/+Oh+uFzJlU9f
  62048. py25IGvPa931DfSCt/SyZi4QKPaXWnuWFo8BGS1sbn85WAZkgwGDg8NNkt0yxoekN+kWzqotaK8K
  62049. gWU6cMGbrU1tVMoqLUuFG7OA5nBFDWteNfB/O7ic5ARwiRIlk9oKmSJgamNgTnYGmE69g60dWIol
  62050. hdLHZR4tjsbftsbhf4oEIRUpdPA+nJCdDC7xij5aqgwJHsfVPKPtl8MeNPo4+QgO48BdK4PRVmrJ
  62051. tqhUUy54Mmc9gn900PvhtgVguXDbjgv5E1hvcWAQUhC5wUEJ73IfZzF4/5YFjQIDAQABo2MwYTAf
  62052. BgNVHSMEGDAWgBTj/i39KNALtbq2osS/BqoFjJP7LzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB
  62053. /wQEAwIBBjAdBgNVHQ4EFgQU4/4t/SjQC7W6tqLEvwaqBYyT+y8wDQYJKoZIhvcNAQELBQADggIB
  62054. ACXGumvrh8vegjmWPfBEp2uEcwPenStPuiB/vHiyz5ewG5zz13ku9Ui20vsXiObTej/tUxPQ4i9q
  62055. ecsAIyjmHjdXNYmEwnZPNDatZ8POQQaIxffu2Bq41gt/UP+TqhdLjOztUmCypAbqTuv0axn96/Ua
  62056. 4CUqmtzHQTb3yHQFhDmVOdYLO6Qn+gjYXB74BGBSESgoA//vU2YApUo0FmZ8/Qmkrp5nGm9BC2sG
  62057. E5uPhnEFtC+NiWYzKXZUmhH4J/qyP5Hgzg0b8zAarb8iXRvTvyUFTeGSGn+ZnzxEk8rUQElsgIfX
  62058. BDrDMlI1Dlb4pd19xIsNER9Tyx6yF7Zod1rg1MvIB671Oi6ON7fQAUtDKXeMOZePglr4UeWJoBjn
  62059. aH9dCi77o0cOPaYjesYBx4/IXr9tgFa+iiS6M+qf4TIRnvHST4D2G0CvOJ4RUHlzEhLN5mydLIhy
  62060. PDCBBpEi6lmt2hkuIsKNuYyH4Ga8cyNfIWRjgEj1oDwYPZTISEEdQLpe/v5WOaHIz16eGWRGENoX
  62061. kbcFgKyLmZJ956LYBws2J+dIeWCKw9cTXPhyQN9Ky8+ZAAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3C
  62062. ekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su
  62063. -----END CERTIFICATE-----
  62064. OISTE WISeKey Global Root GB CA
  62065. ===============================
  62066. -----BEGIN CERTIFICATE-----
  62067. MIIDtTCCAp2gAwIBAgIQdrEgUnTwhYdGs/gjGvbCwDANBgkqhkiG9w0BAQsFADBtMQswCQYDVQQG
  62068. EwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNl
  62069. ZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQiBDQTAeFw0xNDEyMDExNTAw
  62070. MzJaFw0zOTEyMDExNTEwMzFaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYD
  62071. VQQLExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEds
  62072. b2JhbCBSb290IEdCIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2Be3HEokKtaX
  62073. scriHvt9OO+Y9bI5mE4nuBFde9IllIiCFSZqGzG7qFshISvYD06fWvGxWuR51jIjK+FTzJlFXHtP
  62074. rby/h0oLS5daqPZI7H17Dc0hBt+eFf1Biki3IPShehtX1F1Q/7pn2COZH8g/497/b1t3sWtuuMlk
  62075. 9+HKQUYOKXHQuSP8yYFfTvdv37+ErXNku7dCjmn21HYdfp2nuFeKUWdy19SouJVUQHMD9ur06/4o
  62076. Qnc/nSMbsrY9gBQHTC5P99UKFg29ZkM3fiNDecNAhvVMKdqOmq0NpQSHiB6F4+lT1ZvIiwNjeOvg
  62077. GUpuuy9rM2RYk61pv48b74JIxwIDAQABo1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB
  62078. /zAdBgNVHQ4EFgQUNQ/INmNe4qPs+TtmFc5RUuORmj0wEAYJKwYBBAGCNxUBBAMCAQAwDQYJKoZI
  62079. hvcNAQELBQADggEBAEBM+4eymYGQfp3FsLAmzYh7KzKNbrghcViXfa43FK8+5/ea4n32cZiZBKpD
  62080. dHij40lhPnOMTZTg+XHEthYOU3gf1qKHLwI5gSk8rxWYITD+KJAAjNHhy/peyP34EEY7onhCkRd0
  62081. VQreUGdNZtGn//3ZwLWoo4rOZvUPQ82nK1d7Y0Zqqi5S2PTt4W2tKZB4SLrhI6qjiey1q5bAtEui
  62082. HZeeevJuQHHfaPFlTc58Bd9TZaml8LGXBHAVRgOY1NK/VLSgWH1Sb9pWJmLU2NuJMW8c8CLC02Ic
  62083. Nc1MaRVUGpCY3useX8p3x8uOPUNpnJpY0CQ73xtAln41rYHHTnG6iBM=
  62084. -----END CERTIFICATE-----
  62085. SZAFIR ROOT CA2
  62086. ===============
  62087. -----BEGIN CERTIFICATE-----
  62088. MIIDcjCCAlqgAwIBAgIUPopdB+xV0jLVt+O2XwHrLdzk1uQwDQYJKoZIhvcNAQELBQAwUTELMAkG
  62089. A1UEBhMCUEwxKDAmBgNVBAoMH0tyYWpvd2EgSXpiYSBSb3psaWN6ZW5pb3dhIFMuQS4xGDAWBgNV
  62090. BAMMD1NaQUZJUiBST09UIENBMjAeFw0xNTEwMTkwNzQzMzBaFw0zNTEwMTkwNzQzMzBaMFExCzAJ
  62091. BgNVBAYTAlBMMSgwJgYDVQQKDB9LcmFqb3dhIEl6YmEgUm96bGljemVuaW93YSBTLkEuMRgwFgYD
  62092. VQQDDA9TWkFGSVIgUk9PVCBDQTIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC3vD5Q
  62093. qEvNQLXOYeeWyrSh2gwisPq1e3YAd4wLz32ohswmUeQgPYUM1ljj5/QqGJ3a0a4m7utT3PSQ1hNK
  62094. DJA8w/Ta0o4NkjrcsbH/ON7Dui1fgLkCvUqdGw+0w8LBZwPd3BucPbOw3gAeqDRHu5rr/gsUvTaE
  62095. 2g0gv/pby6kWIK05YO4vdbbnl5z5Pv1+TW9NL++IDWr63fE9biCloBK0TXC5ztdyO4mTp4CEHCdJ
  62096. ckm1/zuVnsHMyAHs6A6KCpbns6aH5db5BSsNl0BwPLqsdVqc1U2dAgrSS5tmS0YHF2Wtn2yIANwi
  62097. ieDhZNRnvDF5YTy7ykHNXGoAyDw4jlivAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0P
  62098. AQH/BAQDAgEGMB0GA1UdDgQWBBQuFqlKGLXLzPVvUPMjX/hd56zwyDANBgkqhkiG9w0BAQsFAAOC
  62099. AQEAtXP4A9xZWx126aMqe5Aosk3AM0+qmrHUuOQn/6mWmc5G4G18TKI4pAZw8PRBEew/R40/cof5
  62100. O/2kbytTAOD/OblqBw7rHRz2onKQy4I9EYKL0rufKq8h5mOGnXkZ7/e7DDWQw4rtTw/1zBLZpD67
  62101. oPwglV9PJi8RI4NOdQcPv5vRtB3pEAT+ymCPoky4rc/hkA/NrgrHXXu3UNLUYfrVFdvXn4dRVOul
  62102. 4+vJhaAlIDf7js4MNIThPIGyd05DpYhfhmehPea0XGG2Ptv+tyjFogeutcrKjSoS75ftwjCkySp6
  62103. +/NNIxuZMzSgLvWpCz/UXeHPhJ/iGcJfitYgHuNztw==
  62104. -----END CERTIFICATE-----
  62105. Certum Trusted Network CA 2
  62106. ===========================
  62107. -----BEGIN CERTIFICATE-----
  62108. MIIF0jCCA7qgAwIBAgIQIdbQSk8lD8kyN/yqXhKN6TANBgkqhkiG9w0BAQ0FADCBgDELMAkGA1UE
  62109. BhMCUEwxIjAgBgNVBAoTGVVuaXpldG8gVGVjaG5vbG9naWVzIFMuQS4xJzAlBgNVBAsTHkNlcnR1
  62110. bSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEkMCIGA1UEAxMbQ2VydHVtIFRydXN0ZWQgTmV0d29y
  62111. ayBDQSAyMCIYDzIwMTExMDA2MDgzOTU2WhgPMjA0NjEwMDYwODM5NTZaMIGAMQswCQYDVQQGEwJQ
  62112. TDEiMCAGA1UEChMZVW5pemV0byBUZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENl
  62113. cnRpZmljYXRpb24gQXV0aG9yaXR5MSQwIgYDVQQDExtDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENB
  62114. IDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC9+Xj45tWADGSdhhuWZGc/IjoedQF9
  62115. 7/tcZ4zJzFxrqZHmuULlIEub2pt7uZld2ZuAS9eEQCsn0+i6MLs+CRqnSZXvK0AkwpfHp+6bJe+o
  62116. CgCXhVqqndwpyeI1B+twTUrWwbNWuKFBOJvR+zF/j+Bf4bE/D44WSWDXBo0Y+aomEKsq09DRZ40b
  62117. Rr5HMNUuctHFY9rnY3lEfktjJImGLjQ/KUxSiyqnwOKRKIm5wFv5HdnnJ63/mgKXwcZQkpsCLL2p
  62118. uTRZCr+ESv/f/rOf69me4Jgj7KZrdxYq28ytOxykh9xGc14ZYmhFV+SQgkK7QtbwYeDBoz1mo130
  62119. GO6IyY0XRSmZMnUCMe4pJshrAua1YkV/NxVaI2iJ1D7eTiew8EAMvE0Xy02isx7QBlrd9pPPV3WZ
  62120. 9fqGGmd4s7+W/jTcvedSVuWz5XV710GRBdxdaeOVDUO5/IOWOZV7bIBaTxNyxtd9KXpEulKkKtVB
  62121. Rgkg/iKgtlswjbyJDNXXcPiHUv3a76xRLgezTv7QCdpw75j6VuZt27VXS9zlLCUVyJ4ueE742pye
  62122. hizKV/Ma5ciSixqClnrDvFASadgOWkaLOusm+iPJtrCBvkIApPjW/jAux9JG9uWOdf3yzLnQh1vM
  62123. BhBgu4M1t15n3kfsmUjxpKEV/q2MYo45VU85FrmxY53/twIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  62124. AQH/MB0GA1UdDgQWBBS2oVQ5AsOgP46KvPrU+Bym0ToO/TAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZI
  62125. hvcNAQENBQADggIBAHGlDs7k6b8/ONWJWsQCYftMxRQXLYtPU2sQF/xlhMcQSZDe28cmk4gmb3DW
  62126. Al45oPePq5a1pRNcgRRtDoGCERuKTsZPpd1iHkTfCVn0W3cLN+mLIMb4Ck4uWBzrM9DPhmDJ2vuA
  62127. L55MYIR4PSFk1vtBHxgP58l1cb29XN40hz5BsA72udY/CROWFC/emh1auVbONTqwX3BNXuMp8SMo
  62128. clm2q8KMZiYcdywmdjWLKKdpoPk79SPdhRB0yZADVpHnr7pH1BKXESLjokmUbOe3lEu6LaTaM4tM
  62129. pkT/WjzGHWTYtTHkpjx6qFcL2+1hGsvxznN3Y6SHb0xRONbkX8eftoEq5IVIeVheO/jbAoJnwTnb
  62130. w3RLPTYe+SmTiGhbqEQZIfCn6IENLOiTNrQ3ssqwGyZ6miUfmpqAnksqP/ujmv5zMnHCnsZy4Ypo
  62131. J/HkD7TETKVhk/iXEAcqMCWpuchxuO9ozC1+9eB+D4Kob7a6bINDd82Kkhehnlt4Fj1F4jNy3eFm
  62132. ypnTycUm/Q1oBEauttmbjL4ZvrHG8hnjXALKLNhvSgfZyTXaQHXyxKcZb55CEJh15pWLYLztxRLX
  62133. is7VmFxWlgPF7ncGNf/P5O4/E2Hu29othfDNrp2yGAlFw5Khchf8R7agCyzxxN5DaAhqXzvwdmP7
  62134. zAYspsbiDrW5viSP
  62135. -----END CERTIFICATE-----
  62136. Hellenic Academic and Research Institutions RootCA 2015
  62137. =======================================================
  62138. -----BEGIN CERTIFICATE-----
  62139. MIIGCzCCA/OgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcT
  62140. BkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0
  62141. aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNVBAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNl
  62142. YXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIwMTUwHhcNMTUwNzA3MTAxMTIxWhcNNDAwNjMwMTAx
  62143. MTIxWjCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMg
  62144. QWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNV
  62145. BAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIw
  62146. MTUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDC+Kk/G4n8PDwEXT2QNrCROnk8Zlrv
  62147. bTkBSRq0t89/TSNTt5AA4xMqKKYx8ZEA4yjsriFBzh/a/X0SWwGDD7mwX5nh8hKDgE0GPt+sr+eh
  62148. iGsxr/CL0BgzuNtFajT0AoAkKAoCFZVedioNmToUW/bLy1O8E00BiDeUJRtCvCLYjqOWXjrZMts+
  62149. 6PAQZe104S+nfK8nNLspfZu2zwnI5dMK/IhlZXQK3HMcXM1AsRzUtoSMTFDPaI6oWa7CJ06CojXd
  62150. FPQf/7J31Ycvqm59JCfnxssm5uX+Zwdj2EUN3TpZZTlYepKZcj2chF6IIbjV9Cz82XBST3i4vTwr
  62151. i5WY9bPRaM8gFH5MXF/ni+X1NYEZN9cRCLdmvtNKzoNXADrDgfgXy5I2XdGj2HUb4Ysn6npIQf1F
  62152. GQatJ5lOwXBH3bWfgVMS5bGMSF0xQxfjjMZ6Y5ZLKTBOhE5iGV48zpeQpX8B653g+IuJ3SWYPZK2
  62153. fu/Z8VFRfS0myGlZYeCsargqNhEEelC9MoS+L9xy1dcdFkfkR2YgP/SWxa+OAXqlD3pk9Q0Yh9mu
  62154. iNX6hME6wGkoLfINaFGq46V3xqSQDqE3izEjR8EJCOtu93ib14L8hCCZSRm2Ekax+0VVFqmjZayc
  62155. Bw/qa9wfLgZy7IaIEuQt218FL+TwA9MmM+eAws1CoRc0CwIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  62156. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUcRVnyMjJvXVdctA4GGqd83EkVAswDQYJKoZI
  62157. hvcNAQELBQADggIBAHW7bVRLqhBYRjTyYtcWNl0IXtVsyIe9tC5G8jH4fOpCtZMWVdyhDBKg2mF+
  62158. D1hYc2Ryx+hFjtyp8iY/xnmMsVMIM4GwVhO+5lFc2JsKT0ucVlMC6U/2DWDqTUJV6HwbISHTGzrM
  62159. d/K4kPFox/la/vot9L/J9UUbzjgQKjeKeaO04wlshYaT/4mWJ3iBj2fjRnRUjtkNaeJK9E10A/+y
  62160. d+2VZ5fkscWrv2oj6NSU4kQoYsRL4vDY4ilrGnB+JGGTe08DMiUNRSQrlrRGar9KC/eaj8GsGsVn
  62161. 82800vpzY4zvFrCopEYq+OsS7HK07/grfoxSwIuEVPkvPuNVqNxmsdnhX9izjFk0WaSrT2y7Hxjb
  62162. davYy5LNlDhhDgcGH0tGEPEVvo2FXDtKK4F5D7Rpn0lQl033DlZdwJVqwjbDG2jJ9SrcR5q+ss7F
  62163. Jej6A7na+RZukYT1HCjI/CbM1xyQVqdfbzoEvM14iQuODy+jqk+iGxI9FghAD/FGTNeqewjBCvVt
  62164. J94Cj8rDtSvK6evIIVM4pcw72Hc3MKJP2W/R8kCtQXoXxdZKNYm3QdV8hn9VTYNKpXMgwDqvkPGa
  62165. JI7ZjnHKe7iG2rKPmT4dEw0SEe7Uq/DpFXYC5ODfqiAeW2GFZECpkJcNrVPSWh2HagCXZWK0vm9q
  62166. p/UsQu0yrbYhnr68
  62167. -----END CERTIFICATE-----
  62168. Hellenic Academic and Research Institutions ECC RootCA 2015
  62169. ===========================================================
  62170. -----BEGIN CERTIFICATE-----
  62171. MIICwzCCAkqgAwIBAgIBADAKBggqhkjOPQQDAjCBqjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0
  62172. aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9u
  62173. cyBDZXJ0LiBBdXRob3JpdHkxRDBCBgNVBAMTO0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJj
  62174. aCBJbnN0aXR1dGlvbnMgRUNDIFJvb3RDQSAyMDE1MB4XDTE1MDcwNzEwMzcxMloXDTQwMDYzMDEw
  62175. MzcxMlowgaoxCzAJBgNVBAYTAkdSMQ8wDQYDVQQHEwZBdGhlbnMxRDBCBgNVBAoTO0hlbGxlbmlj
  62176. IEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9yaXR5MUQwQgYD
  62177. VQQDEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25zIEVDQyBSb290
  62178. Q0EgMjAxNTB2MBAGByqGSM49AgEGBSuBBAAiA2IABJKgQehLgoRc4vgxEZmGZE4JJS+dQS8KrjVP
  62179. dJWyUWRrjWvmP3CV8AVER6ZyOFB2lQJajq4onvktTpnvLEhvTCUp6NFxW98dwXU3tNf6e3pCnGoK
  62180. Vlp8aQuqgAkkbH7BRqNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O
  62181. BBYEFLQiC4KZJAEOnLvkDv2/+5cgk5kqMAoGCCqGSM49BAMCA2cAMGQCMGfOFmI4oqxiRaeplSTA
  62182. GiecMjvAwNW6qef4BENThe5SId6d9SWDPp5YSy/XZxMOIQIwBeF1Ad5o7SofTUwJCA3sS61kFyjn
  62183. dc5FZXIhF8siQQ6ME5g4mlRtm8rifOoCWCKR
  62184. -----END CERTIFICATE-----
  62185. ISRG Root X1
  62186. ============
  62187. -----BEGIN CERTIFICATE-----
  62188. MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAwTzELMAkGA1UE
  62189. BhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2VhcmNoIEdyb3VwMRUwEwYDVQQD
  62190. EwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQG
  62191. EwJVUzEpMCcGA1UEChMgSW50ZXJuZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMT
  62192. DElTUkcgUm9vdCBYMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54r
  62193. Vygch77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+0TM8ukj1
  62194. 3Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6UA5/TR5d8mUgjU+g4rk8K
  62195. b4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sWT8KOEUt+zwvo/7V3LvSye0rgTBIlDHCN
  62196. Aymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyHB5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ
  62197. 4Q7e2RCOFvu396j3x+UCB5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf
  62198. 1b0SHzUvKBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWnOlFu
  62199. hjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTnjh8BCNAw1FtxNrQH
  62200. usEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbwqHyGO0aoSCqI3Haadr8faqU9GY/r
  62201. OPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CIrU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4G
  62202. A1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY
  62203. 9umbbjANBgkqhkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL
  62204. ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ3BebYhtF8GaV
  62205. 0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KKNFtY2PwByVS5uCbMiogziUwt
  62206. hDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJw
  62207. TdwJx4nLCgdNbOhdjsnvzqvHu7UrTkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nx
  62208. e5AW0wdeRlN8NwdCjNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZA
  62209. JzVcoyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq4RgqsahD
  62210. YVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPAmRGunUHBcnWEvgJBQl9n
  62211. JEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57demyPxgcYxn/eR44/KJ4EBs+lVDR3veyJ
  62212. m+kXQ99b21/+jh5Xos1AnX5iItreGCc=
  62213. -----END CERTIFICATE-----
  62214. AC RAIZ FNMT-RCM
  62215. ================
  62216. -----BEGIN CERTIFICATE-----
  62217. MIIFgzCCA2ugAwIBAgIPXZONMGc2yAYdGsdUhGkHMA0GCSqGSIb3DQEBCwUAMDsxCzAJBgNVBAYT
  62218. AkVTMREwDwYDVQQKDAhGTk1ULVJDTTEZMBcGA1UECwwQQUMgUkFJWiBGTk1ULVJDTTAeFw0wODEw
  62219. MjkxNTU5NTZaFw0zMDAxMDEwMDAwMDBaMDsxCzAJBgNVBAYTAkVTMREwDwYDVQQKDAhGTk1ULVJD
  62220. TTEZMBcGA1UECwwQQUMgUkFJWiBGTk1ULVJDTTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
  62221. ggIBALpxgHpMhm5/yBNtwMZ9HACXjywMI7sQmkCpGreHiPibVmr75nuOi5KOpyVdWRHbNi63URcf
  62222. qQgfBBckWKo3Shjf5TnUV/3XwSyRAZHiItQDwFj8d0fsjz50Q7qsNI1NOHZnjrDIbzAzWHFctPVr
  62223. btQBULgTfmxKo0nRIBnuvMApGGWn3v7v3QqQIecaZ5JCEJhfTzC8PhxFtBDXaEAUwED653cXeuYL
  62224. j2VbPNmaUtu1vZ5Gzz3rkQUCwJaydkxNEJY7kvqcfw+Z374jNUUeAlz+taibmSXaXvMiwzn15Cou
  62225. 08YfxGyqxRxqAQVKL9LFwag0Jl1mpdICIfkYtwb1TplvqKtMUejPUBjFd8g5CSxJkjKZqLsXF3mw
  62226. WsXmo8RZZUc1g16p6DULmbvkzSDGm0oGObVo/CK67lWMK07q87Hj/LaZmtVC+nFNCM+HHmpxffnT
  62227. tOmlcYF7wk5HlqX2doWjKI/pgG6BU6VtX7hI+cL5NqYuSf+4lsKMB7ObiFj86xsc3i1w4peSMKGJ
  62228. 47xVqCfWS+2QrYv6YyVZLag13cqXM7zlzced0ezvXg5KkAYmY6252TUtB7p2ZSysV4999AeU14EC
  62229. ll2jB0nVetBX+RvnU0Z1qrB5QstocQjpYL05ac70r8NWQMetUqIJ5G+GR4of6ygnXYMgrwTJbFaa
  62230. i0b1AgMBAAGjgYMwgYAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE
  62231. FPd9xf3E6Jobd2Sn9R2gzL+HYJptMD4GA1UdIAQ3MDUwMwYEVR0gADArMCkGCCsGAQUFBwIBFh1o
  62232. dHRwOi8vd3d3LmNlcnQuZm5tdC5lcy9kcGNzLzANBgkqhkiG9w0BAQsFAAOCAgEAB5BK3/MjTvDD
  62233. nFFlm5wioooMhfNzKWtN/gHiqQxjAb8EZ6WdmF/9ARP67Jpi6Yb+tmLSbkyU+8B1RXxlDPiyN8+s
  62234. D8+Nb/kZ94/sHvJwnvDKuO+3/3Y3dlv2bojzr2IyIpMNOmqOFGYMLVN0V2Ue1bLdI4E7pWYjJ2cJ
  62235. j+F3qkPNZVEI7VFY/uY5+ctHhKQV8Xa7pO6kO8Rf77IzlhEYt8llvhjho6Tc+hj507wTmzl6NLrT
  62236. Qfv6MooqtyuGC2mDOL7Nii4LcK2NJpLuHvUBKwrZ1pebbuCoGRw6IYsMHkCtA+fdZn71uSANA+iW
  62237. +YJF1DngoABd15jmfZ5nc8OaKveri6E6FO80vFIOiZiaBECEHX5FaZNXzuvO+FB8TxxuBEOb+dY7
  62238. Ixjp6o7RTUaN8Tvkasq6+yO3m/qZASlaWFot4/nUbQ4mrcFuNLwy+AwF+mWj2zs3gyLp1txyM/1d
  62239. 8iC9djwj2ij3+RvrWWTV3F9yfiD8zYm1kGdNYno/Tq0dwzn+evQoFt9B9kiABdcPUXmsEKvU7ANm
  62240. 5mqwujGSQkBqvjrTcuFqN1W8rB2Vt2lh8kORdOag0wokRqEIr9baRRmW1FMdW4R58MD3R++Lj8UG
  62241. rp1MYp3/RgT408m2ECVAdf4WqslKYIYvuu8wd+RU4riEmViAqhOLUTpPSPaLtrM=
  62242. -----END CERTIFICATE-----
  62243. Amazon Root CA 1
  62244. ================
  62245. -----BEGIN CERTIFICATE-----
  62246. MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsFADA5MQswCQYD
  62247. VQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAxMB4XDTE1
  62248. MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpv
  62249. bjEZMBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
  62250. ggEBALJ4gHHKeNXjca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgH
  62251. FzZM9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qwIFAGbHrQ
  62252. gLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6VOujw5H5SNz/0egwLX0t
  62253. dHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L93FcXmn/6pUCyziKrlA4b9v7LWIbxcce
  62254. VOF34GfID5yHI9Y/QCB/IIDEgEw+OyQmjgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB
  62255. /zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3
  62256. DQEBCwUAA4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDIU5PM
  62257. CCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUsN+gDS63pYaACbvXy
  62258. 8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vvo/ufQJVtMVT8QtPHRh8jrdkPSHCa
  62259. 2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2
  62260. xJNDd2ZhwLnoQdeXeGADbkpyrqXRfboQnoZsG4q5WTP468SQvvG5
  62261. -----END CERTIFICATE-----
  62262. Amazon Root CA 2
  62263. ================
  62264. -----BEGIN CERTIFICATE-----
  62265. MIIFQTCCAymgAwIBAgITBmyf0pY1hp8KD+WGePhbJruKNzANBgkqhkiG9w0BAQwFADA5MQswCQYD
  62266. VQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAyMB4XDTE1
  62267. MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpv
  62268. bjEZMBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
  62269. ggIBAK2Wny2cSkxKgXlRmeyKy2tgURO8TW0G/LAIjd0ZEGrHJgw12MBvIITplLGbhQPDW9tK6Mj4
  62270. kHbZW0/jTOgGNk3Mmqw9DJArktQGGWCsN0R5hYGCrVo34A3MnaZMUnbqQ523BNFQ9lXg1dKmSYXp
  62271. N+nKfq5clU1Imj+uIFptiJXZNLhSGkOQsL9sBbm2eLfq0OQ6PBJTYv9K8nu+NQWpEjTj82R0Yiw9
  62272. AElaKP4yRLuH3WUnAnE72kr3H9rN9yFVkE8P7K6C4Z9r2UXTu/Bfh+08LDmG2j/e7HJV63mjrdvd
  62273. fLC6HM783k81ds8P+HgfajZRRidhW+mez/CiVX18JYpvL7TFz4QuK/0NURBs+18bvBt+xa47mAEx
  62274. kv8LV/SasrlX6avvDXbR8O70zoan4G7ptGmh32n2M8ZpLpcTnqWHsFcQgTfJU7O7f/aS0ZzQGPSS
  62275. btqDT6ZjmUyl+17vIWR6IF9sZIUVyzfpYgwLKhbcAS4y2j5L9Z469hdAlO+ekQiG+r5jqFoz7Mt0
  62276. Q5X5bGlSNscpb/xVA1wf+5+9R+vnSUeVC06JIglJ4PVhHvG/LopyboBZ/1c6+XUyo05f7O0oYtlN
  62277. c/LMgRdg7c3r3NunysV+Ar3yVAhU/bQtCSwXVEqY0VThUWcI0u1ufm8/0i2BWSlmy5A5lREedCf+
  62278. 3euvAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSw
  62279. DPBMMPQFWAJI/TPlUq9LhONmUjANBgkqhkiG9w0BAQwFAAOCAgEAqqiAjw54o+Ci1M3m9Zh6O+oA
  62280. A7CXDpO8Wqj2LIxyh6mx/H9z/WNxeKWHWc8w4Q0QshNabYL1auaAn6AFC2jkR2vHat+2/XcycuUY
  62281. +gn0oJMsXdKMdYV2ZZAMA3m3MSNjrXiDCYZohMr/+c8mmpJ5581LxedhpxfL86kSk5Nrp+gvU5LE
  62282. YFiwzAJRGFuFjWJZY7attN6a+yb3ACfAXVU3dJnJUH/jWS5E4ywl7uxMMne0nxrpS10gxdr9HIcW
  62283. xkPo1LsmmkVwXqkLN1PiRnsn/eBG8om3zEK2yygmbtmlyTrIQRNg91CMFa6ybRoVGld45pIq2WWQ
  62284. gj9sAq+uEjonljYE1x2igGOpm/HlurR8FLBOybEfdF849lHqm/osohHUqS0nGkWxr7JOcQ3AWEbW
  62285. aQbLU8uz/mtBzUF+fUwPfHJ5elnNXkoOrJupmHN5fLT0zLm4BwyydFy4x2+IoZCn9Kr5v2c69BoV
  62286. Yh63n749sSmvZ6ES8lgQGVMDMBu4Gon2nL2XA46jCfMdiyHxtN/kHNGfZQIG6lzWE7OE76KlXIx3
  62287. KadowGuuQNKotOrN8I1LOJwZmhsoVLiJkO/KdYE+HvJkJMcYr07/R54H9jVlpNMKVv/1F2Rs76gi
  62288. JUmTtt8AF9pYfl3uxRuw0dFfIRDH+fO6AgonB8Xx1sfT4PsJYGw=
  62289. -----END CERTIFICATE-----
  62290. Amazon Root CA 3
  62291. ================
  62292. -----BEGIN CERTIFICATE-----
  62293. MIIBtjCCAVugAwIBAgITBmyf1XSXNmY/Owua2eiedgPySjAKBggqhkjOPQQDAjA5MQswCQYDVQQG
  62294. EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAzMB4XDTE1MDUy
  62295. NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ
  62296. MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCmXp8ZB
  62297. f8ANm+gBG1bG8lKlui2yEujSLtf6ycXYqm0fc4E7O5hrOXwzpcVOho6AF2hiRVd9RFgdszflZwjr
  62298. Zt6jQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSrttvXBp43
  62299. rDCGB5Fwx5zEGbF4wDAKBggqhkjOPQQDAgNJADBGAiEA4IWSoxe3jfkrBqWTrBqYaGFy+uGh0Psc
  62300. eGCmQ5nFuMQCIQCcAu/xlJyzlvnrxir4tiz+OpAUFteMYyRIHN8wfdVoOw==
  62301. -----END CERTIFICATE-----
  62302. Amazon Root CA 4
  62303. ================
  62304. -----BEGIN CERTIFICATE-----
  62305. MIIB8jCCAXigAwIBAgITBmyf18G7EEwpQ+Vxe3ssyBrBDjAKBggqhkjOPQQDAzA5MQswCQYDVQQG
  62306. EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSA0MB4XDTE1MDUy
  62307. NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ
  62308. MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgNDB2MBAGByqGSM49AgEGBSuBBAAiA2IABNKrijdPo1MN
  62309. /sGKe0uoe0ZLY7Bi9i0b2whxIdIA6GO9mif78DluXeo9pcmBqqNbIJhFXRbb/egQbeOc4OO9X4Ri
  62310. 83BkM6DLJC9wuoihKqB1+IGuYgbEgds5bimwHvouXKNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV
  62311. HQ8BAf8EBAMCAYYwHQYDVR0OBBYEFNPsxzplbszh2naaVvuc84ZtV+WBMAoGCCqGSM49BAMDA2gA
  62312. MGUCMDqLIfG9fhGt0O9Yli/W651+kI0rz2ZVwyzjKKlwCkcO8DdZEv8tmZQoTipPNU0zWgIxAOp1
  62313. AE47xDqUEpHJWEadIRNyp4iciuRMStuW1KyLa2tJElMzrdfkviT8tQp21KW8EA==
  62314. -----END CERTIFICATE-----
  62315. TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1
  62316. =============================================
  62317. -----BEGIN CERTIFICATE-----
  62318. MIIEYzCCA0ugAwIBAgIBATANBgkqhkiG9w0BAQsFADCB0jELMAkGA1UEBhMCVFIxGDAWBgNVBAcT
  62319. D0dlYnplIC0gS29jYWVsaTFCMEAGA1UEChM5VHVya2l5ZSBCaWxpbXNlbCB2ZSBUZWtub2xvamlr
  62320. IEFyYXN0aXJtYSBLdXJ1bXUgLSBUVUJJVEFLMS0wKwYDVQQLEyRLYW11IFNlcnRpZmlrYXN5b24g
  62321. TWVya2V6aSAtIEthbXUgU00xNjA0BgNVBAMTLVRVQklUQUsgS2FtdSBTTSBTU0wgS29rIFNlcnRp
  62322. ZmlrYXNpIC0gU3VydW0gMTAeFw0xMzExMjUwODI1NTVaFw00MzEwMjUwODI1NTVaMIHSMQswCQYD
  62323. VQQGEwJUUjEYMBYGA1UEBxMPR2ViemUgLSBLb2NhZWxpMUIwQAYDVQQKEzlUdXJraXllIEJpbGlt
  62324. c2VsIHZlIFRla25vbG9qaWsgQXJhc3Rpcm1hIEt1cnVtdSAtIFRVQklUQUsxLTArBgNVBAsTJEth
  62325. bXUgU2VydGlmaWthc3lvbiBNZXJrZXppIC0gS2FtdSBTTTE2MDQGA1UEAxMtVFVCSVRBSyBLYW11
  62326. IFNNIFNTTCBLb2sgU2VydGlmaWthc2kgLSBTdXJ1bSAxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  62327. MIIBCgKCAQEAr3UwM6q7a9OZLBI3hNmNe5eA027n/5tQlT6QlVZC1xl8JoSNkvoBHToP4mQ4t4y8
  62328. 6Ij5iySrLqP1N+RAjhgleYN1Hzv/bKjFxlb4tO2KRKOrbEz8HdDc72i9z+SqzvBV96I01INrN3wc
  62329. wv61A+xXzry0tcXtAA9TNypN9E8Mg/uGz8v+jE69h/mniyFXnHrfA2eJLJ2XYacQuFWQfw4tJzh0
  62330. 3+f92k4S400VIgLI4OD8D62K18lUUMw7D8oWgITQUVbDjlZ/iSIzL+aFCr2lqBs23tPcLG07xxO9
  62331. WSMs5uWk99gL7eqQQESolbuT1dCANLZGeA4fAJNG4e7p+exPFwIDAQABo0IwQDAdBgNVHQ4EFgQU
  62332. ZT/HiobGPN08VFw1+DrtUgxHV8gwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJ
  62333. KoZIhvcNAQELBQADggEBACo/4fEyjq7hmFxLXs9rHmoJ0iKpEsdeV31zVmSAhHqT5Am5EM2fKifh
  62334. AHe+SMg1qIGf5LgsyX8OsNJLN13qudULXjS99HMpw+0mFZx+CFOKWI3QSyjfwbPfIPP54+M638yc
  62335. lNhOT8NrF7f3cuitZjO1JVOr4PhMqZ398g26rrnZqsZr+ZO7rqu4lzwDGrpDxpa5RXI4s6ehlj2R
  62336. e37AIVNMh+3yC1SVUZPVIqUNivGTDj5UDrDYyU7c8jEyVupk+eq1nRZmQnLzf9OxMUP8pI4X8W0j
  62337. q5Rm+K37DwhuJi1/FwcJsoz7UMCflo3Ptv0AnVoUmr8CRPXBwp8iXqIPoeM=
  62338. -----END CERTIFICATE-----
  62339. GDCA TrustAUTH R5 ROOT
  62340. ======================
  62341. -----BEGIN CERTIFICATE-----
  62342. MIIFiDCCA3CgAwIBAgIIfQmX/vBH6nowDQYJKoZIhvcNAQELBQAwYjELMAkGA1UEBhMCQ04xMjAw
  62343. BgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZIENPLixMVEQuMR8wHQYDVQQD
  62344. DBZHRENBIFRydXN0QVVUSCBSNSBST09UMB4XDTE0MTEyNjA1MTMxNVoXDTQwMTIzMTE1NTk1OVow
  62345. YjELMAkGA1UEBhMCQ04xMjAwBgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZ
  62346. IENPLixMVEQuMR8wHQYDVQQDDBZHRENBIFRydXN0QVVUSCBSNSBST09UMIICIjANBgkqhkiG9w0B
  62347. AQEFAAOCAg8AMIICCgKCAgEA2aMW8Mh0dHeb7zMNOwZ+Vfy1YI92hhJCfVZmPoiC7XJjDp6L3TQs
  62348. AlFRwxn9WVSEyfFrs0yw6ehGXTjGoqcuEVe6ghWinI9tsJlKCvLriXBjTnnEt1u9ol2x8kECK62p
  62349. OqPseQrsXzrj/e+APK00mxqriCZ7VqKChh/rNYmDf1+uKU49tm7srsHwJ5uu4/Ts765/94Y9cnrr
  62350. pftZTqfrlYwiOXnhLQiPzLyRuEH3FMEjqcOtmkVEs7LXLM3GKeJQEK5cy4KOFxg2fZfmiJqwTTQJ
  62351. 9Cy5WmYqsBebnh52nUpmMUHfP/vFBu8btn4aRjb3ZGM74zkYI+dndRTVdVeSN72+ahsmUPI2JgaQ
  62352. xXABZG12ZuGR224HwGGALrIuL4xwp9E7PLOR5G62xDtw8mySlwnNR30YwPO7ng/Wi64HtloPzgsM
  62353. R6flPri9fcebNaBhlzpBdRfMK5Z3KpIhHtmVdiBnaM8Nvd/WHwlqmuLMc3GkL30SgLdTMEZeS1SZ
  62354. D2fJpcjyIMGC7J0R38IC+xo70e0gmu9lZJIQDSri3nDxGGeCjGHeuLzRL5z7D9Ar7Rt2ueQ5Vfj4
  62355. oR24qoAATILnsn8JuLwwoC8N9VKejveSswoAHQBUlwbgsQfZxw9cZX08bVlX5O2ljelAU58VS6Bx
  62356. 9hoh49pwBiFYFIeFd3mqgnkCAwEAAaNCMEAwHQYDVR0OBBYEFOLJQJ9NzuiaoXzPDj9lxSmIahlR
  62357. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQDRSVfg
  62358. p8xoWLoBDysZzY2wYUWsEe1jUGn4H3++Fo/9nesLqjJHdtJnJO29fDMylyrHBYZmDRd9FBUb1Ov9
  62359. H5r2XpdptxolpAqzkT9fNqyL7FeoPueBihhXOYV0GkLH6VsTX4/5COmSdI31R9KrO9b7eGZONn35
  62360. 6ZLpBN79SWP8bfsUcZNnL0dKt7n/HipzcEYwv1ryL3ml4Y0M2fmyYzeMN2WFcGpcWwlyua1jPLHd
  62361. +PwyvzeG5LuOmCd+uh8W4XAR8gPfJWIyJyYYMoSf/wA6E7qaTfRPuBRwIrHKK5DOKcFw9C+df/KQ
  62362. HtZa37dG/OaG+svgIHZ6uqbL9XzeYqWxi+7egmaKTjowHz+Ay60nugxe19CxVsp3cbK1daFQqUBD
  62363. F8Io2c9Si1vIY9RCPqAzekYu9wogRlR+ak8x8YF+QnQ4ZXMn7sZ8uI7XpTrXmKGcjBBV09tL7ECQ
  62364. 8s1uV9JiDnxXk7Gnbc2dg7sq5+W2O3FYrf3RRbxake5TFW/TRQl1brqQXR4EzzffHqhmsYzmIGrv
  62365. /EhOdJhCrylvLmrH+33RZjEizIYAfmaDDEL0vTSSwxrqT8p+ck0LcIymSLumoRT2+1hEmRSuqguT
  62366. aaApJUqlyyvdimYHFngVV3Eb7PVHhPOeMTd61X8kreS8/f3MboPoDKi3QWwH3b08hpcv0g==
  62367. -----END CERTIFICATE-----
  62368. TrustCor RootCert CA-1
  62369. ======================
  62370. -----BEGIN CERTIFICATE-----
  62371. MIIEMDCCAxigAwIBAgIJANqb7HHzA7AZMA0GCSqGSIb3DQEBCwUAMIGkMQswCQYDVQQGEwJQQTEP
  62372. MA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3Ig
  62373. U3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5UcnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3Jp
  62374. dHkxHzAdBgNVBAMMFlRydXN0Q29yIFJvb3RDZXJ0IENBLTEwHhcNMTYwMjA0MTIzMjE2WhcNMjkx
  62375. MjMxMTcyMzE2WjCBpDELMAkGA1UEBhMCUEExDzANBgNVBAgMBlBhbmFtYTEUMBIGA1UEBwwLUGFu
  62376. YW1hIENpdHkxJDAiBgNVBAoMG1RydXN0Q29yIFN5c3RlbXMgUy4gZGUgUi5MLjEnMCUGA1UECwwe
  62377. VHJ1c3RDb3IgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR8wHQYDVQQDDBZUcnVzdENvciBSb290Q2Vy
  62378. dCBDQS0xMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv463leLCJhJrMxnHQFgKq1mq
  62379. jQCj/IDHUHuO1CAmujIS2CNUSSUQIpidRtLByZ5OGy4sDjjzGiVoHKZaBeYei0i/mJZ0PmnK6bV4
  62380. pQa81QBeCQryJ3pS/C3Vseq0iWEk8xoT26nPUu0MJLq5nux+AHT6k61sKZKuUbS701e/s/OojZz0
  62381. JEsq1pme9J7+wH5COucLlVPat2gOkEz7cD+PSiyU8ybdY2mplNgQTsVHCJCZGxdNuWxu72CVEY4h
  62382. gLW9oHPY0LJ3xEXqWib7ZnZ2+AYfYW0PVcWDtxBWcgYHpfOxGgMFZA6dWorWhnAbJN7+KIor0Gqw
  62383. /Hqi3LJ5DotlDwIDAQABo2MwYTAdBgNVHQ4EFgQU7mtJPHo/DeOxCbeKyKsZn3MzUOcwHwYDVR0j
  62384. BBgwFoAU7mtJPHo/DeOxCbeKyKsZn3MzUOcwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  62385. AYYwDQYJKoZIhvcNAQELBQADggEBACUY1JGPE+6PHh0RU9otRCkZoB5rMZ5NDp6tPVxBb5UrJKF5
  62386. mDo4Nvu7Zp5I/5CQ7z3UuJu0h3U/IJvOcs+hVcFNZKIZBqEHMwwLKeXx6quj7LUKdJDHfXLy11yf
  62387. ke+Ri7fc7Waiz45mO7yfOgLgJ90WmMCV1Aqk5IGadZQ1nJBfiDcGrVmVCrDRZ9MZyonnMlo2HD6C
  62388. qFqTvsbQZJG2z9m2GM/bftJlo6bEjhcxwft+dtvTheNYsnd6djtsL1Ac59v2Z3kf9YKVmgenFK+P
  62389. 3CghZwnS1k1aHBkcjndcw5QkPTJrS37UeJSDvjdNzl/HHk484IkzlQsPpTLWPFp5LBk=
  62390. -----END CERTIFICATE-----
  62391. TrustCor RootCert CA-2
  62392. ======================
  62393. -----BEGIN CERTIFICATE-----
  62394. MIIGLzCCBBegAwIBAgIIJaHfyjPLWQIwDQYJKoZIhvcNAQELBQAwgaQxCzAJBgNVBAYTAlBBMQ8w
  62395. DQYDVQQIDAZQYW5hbWExFDASBgNVBAcMC1BhbmFtYSBDaXR5MSQwIgYDVQQKDBtUcnVzdENvciBT
  62396. eXN0ZW1zIFMuIGRlIFIuTC4xJzAlBgNVBAsMHlRydXN0Q29yIENlcnRpZmljYXRlIEF1dGhvcml0
  62397. eTEfMB0GA1UEAwwWVHJ1c3RDb3IgUm9vdENlcnQgQ0EtMjAeFw0xNjAyMDQxMjMyMjNaFw0zNDEy
  62398. MzExNzI2MzlaMIGkMQswCQYDVQQGEwJQQTEPMA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5h
  62399. bWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3IgU3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5U
  62400. cnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHzAdBgNVBAMMFlRydXN0Q29yIFJvb3RDZXJ0
  62401. IENBLTIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCnIG7CKqJiJJWQdsg4foDSq8Gb
  62402. ZQWU9MEKENUCrO2fk8eHyLAnK0IMPQo+QVqedd2NyuCb7GgypGmSaIwLgQ5WoD4a3SwlFIIvl9Nk
  62403. RvRUqdw6VC0xK5mC8tkq1+9xALgxpL56JAfDQiDyitSSBBtlVkxs1Pu2YVpHI7TYabS3OtB0PAx1
  62404. oYxOdqHp2yqlO/rOsP9+aij9JxzIsekp8VduZLTQwRVtDr4uDkbIXvRR/u8OYzo7cbrPb1nKDOOb
  62405. XUm4TOJXsZiKQlecdu/vvdFoqNL0Cbt3Nb4lggjEFixEIFapRBF37120Hapeaz6LMvYHL1cEksr1
  62406. /p3C6eizjkxLAjHZ5DxIgif3GIJ2SDpxsROhOdUuxTTCHWKF3wP+TfSvPd9cW436cOGlfifHhi5q
  62407. jxLGhF5DUVCcGZt45vz27Ud+ez1m7xMTiF88oWP7+ayHNZ/zgp6kPwqcMWmLmaSISo5uZk3vFsQP
  62408. eSghYA2FFn3XVDjxklb9tTNMg9zXEJ9L/cb4Qr26fHMC4P99zVvh1Kxhe1fVSntb1IVYJ12/+Ctg
  62409. rKAmrhQhJ8Z3mjOAPF5GP/fDsaOGM8boXg25NSyqRsGFAnWAoOsk+xWq5Gd/bnc/9ASKL3x74xdh
  62410. 8N0JqSDIvgmk0H5Ew7IwSjiqqewYmgeCK9u4nBit2uBGF6zPXQIDAQABo2MwYTAdBgNVHQ4EFgQU
  62411. 2f4hQG6UnrybPZx9mCAZ5YwwYrIwHwYDVR0jBBgwFoAU2f4hQG6UnrybPZx9mCAZ5YwwYrIwDwYD
  62412. VR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQELBQADggIBAJ5Fngw7tu/h
  62413. Osh80QA9z+LqBrWyOrsGS2h60COXdKcs8AjYeVrXWoSK2BKaG9l9XE1wxaX5q+WjiYndAfrs3fnp
  62414. kpfbsEZC89NiqpX+MWcUaViQCqoL7jcjx1BRtPV+nuN79+TMQjItSQzL/0kMmx40/W5ulop5A7Zv
  62415. 2wnL/V9lFDfhOPXzYRZY5LVtDQsEGz9QLX+zx3oaFoBg+Iof6Rsqxvm6ARppv9JYx1RXCI/hOWB3
  62416. S6xZhBqI8d3LT3jX5+EzLfzuQfogsL7L9ziUwOHQhQ+77Sxzq+3+knYaZH9bDTMJBzN7Bj8RpFxw
  62417. PIXAz+OQqIN3+tvmxYxoZxBnpVIt8MSZj3+/0WvitUfW2dCFmU2Umw9Lje4AWkcdEQOsQRivh7dv
  62418. DDqPys/cA8GiCcjl/YBeyGBCARsaU1q7N6a3vLqE6R5sGtRk2tRD/pOLS/IseRYQ1JMLiI+h2IYU
  62419. RpFHmygk71dSTlxCnKr3Sewn6EAes6aJInKc9Q0ztFijMDvd1GpUk74aTfOTlPf8hAs/hCBcNANE
  62420. xdqtvArBAs8e5ZTZ845b2EzwnexhF7sUMlQMAimTHpKG9n/v55IFDlndmQguLvqcAFLTxWYp5KeX
  62421. RKQOKIETNcX2b2TmQcTVL8w0RSXPQQCWPUouwpaYT05KnJe32x+SMsj/D1Fu1uwJ
  62422. -----END CERTIFICATE-----
  62423. TrustCor ECA-1
  62424. ==============
  62425. -----BEGIN CERTIFICATE-----
  62426. MIIEIDCCAwigAwIBAgIJAISCLF8cYtBAMA0GCSqGSIb3DQEBCwUAMIGcMQswCQYDVQQGEwJQQTEP
  62427. MA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3Ig
  62428. U3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5UcnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3Jp
  62429. dHkxFzAVBgNVBAMMDlRydXN0Q29yIEVDQS0xMB4XDTE2MDIwNDEyMzIzM1oXDTI5MTIzMTE3Mjgw
  62430. N1owgZwxCzAJBgNVBAYTAlBBMQ8wDQYDVQQIDAZQYW5hbWExFDASBgNVBAcMC1BhbmFtYSBDaXR5
  62431. MSQwIgYDVQQKDBtUcnVzdENvciBTeXN0ZW1zIFMuIGRlIFIuTC4xJzAlBgNVBAsMHlRydXN0Q29y
  62432. IENlcnRpZmljYXRlIEF1dGhvcml0eTEXMBUGA1UEAwwOVHJ1c3RDb3IgRUNBLTEwggEiMA0GCSqG
  62433. SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDPj+ARtZ+odnbb3w9U73NjKYKtR8aja+3+XzP4Q1HpGjOR
  62434. MRegdMTUpwHmspI+ap3tDvl0mEDTPwOABoJA6LHip1GnHYMma6ve+heRK9jGrB6xnhkB1Zem6g23
  62435. xFUfJ3zSCNV2HykVh0A53ThFEXXQmqc04L/NyFIduUd+Dbi7xgz2c1cWWn5DkR9VOsZtRASqnKmc
  62436. p0yJF4OuowReUoCLHhIlERnXDH19MURB6tuvsBzvgdAsxZohmz3tQjtQJvLsznFhBmIhVE5/wZ0+
  62437. fyCMgMsq2JdiyIMzkX2woloPV+g7zPIlstR8L+xNxqE6FXrntl019fZISjZFZtS6mFjBAgMBAAGj
  62438. YzBhMB0GA1UdDgQWBBREnkj1zG1I1KBLf/5ZJC+Dl5mahjAfBgNVHSMEGDAWgBREnkj1zG1I1KBL
  62439. f/5ZJC+Dl5mahjAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQsF
  62440. AAOCAQEABT41XBVwm8nHc2FvcivUwo/yQ10CzsSUuZQRg2dd4mdsdXa/uwyqNsatR5Nj3B5+1t4u
  62441. /ukZMjgDfxT2AHMsWbEhBuH7rBiVDKP/mZb3Kyeb1STMHd3BOuCYRLDE5D53sXOpZCz2HAF8P11F
  62442. hcCF5yWPldwX8zyfGm6wyuMdKulMY/okYWLW2n62HGz1Ah3UKt1VkOsqEUc8Ll50soIipX1TH0Xs
  62443. J5F95yIW6MBoNtjG8U+ARDL54dHRHareqKucBK+tIA5kmE2la8BIWJZpTdwHjFGTot+fDz2LYLSC
  62444. jaoITmJF4PkL0uDgPFveXHEnJcLmA4GLEFPjx1WitJ/X5g==
  62445. -----END CERTIFICATE-----
  62446. SSL.com Root Certification Authority RSA
  62447. ========================================
  62448. -----BEGIN CERTIFICATE-----
  62449. MIIF3TCCA8WgAwIBAgIIeyyb0xaAMpkwDQYJKoZIhvcNAQELBQAwfDELMAkGA1UEBhMCVVMxDjAM
  62450. BgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24x
  62451. MTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBSU0EwHhcNMTYw
  62452. MjEyMTczOTM5WhcNNDEwMjEyMTczOTM5WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx
  62453. EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NM
  62454. LmNvbSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFJTQTCCAiIwDQYJKoZIhvcNAQEBBQAD
  62455. ggIPADCCAgoCggIBAPkP3aMrfcvQKv7sZ4Wm5y4bunfh4/WvpOz6Sl2RxFdHaxh3a3by/ZPkPQ/C
  62456. Fp4LZsNWlJ4Xg4XOVu/yFv0AYvUiCVToZRdOQbngT0aXqhvIuG5iXmmxX9sqAn78bMrzQdjt0Oj8
  62457. P2FI7bADFB0QDksZ4LtO7IZl/zbzXmcCC52GVWH9ejjt/uIZALdvoVBidXQ8oPrIJZK0bnoix/ge
  62458. oeOy3ZExqysdBP+lSgQ36YWkMyv94tZVNHwZpEpox7Ko07fKoZOI68GXvIz5HdkihCR0xwQ9aqkp
  62459. k8zruFvh/l8lqjRYyMEjVJ0bmBHDOJx+PYZspQ9AhnwC9FwCTyjLrnGfDzrIM/4RJTXq/LrFYD3Z
  62460. fBjVsqnTdXgDciLKOsMf7yzlLqn6niy2UUb9rwPW6mBo6oUWNmuF6R7As93EJNyAKoFBbZQ+yODJ
  62461. gUEAnl6/f8UImKIYLEJAs/lvOCdLToD0PYFH4Ih86hzOtXVcUS4cK38acijnALXRdMbX5J+tB5O2
  62462. UzU1/Dfkw/ZdFr4hc96SCvigY2q8lpJqPvi8ZVWb3vUNiSYE/CUapiVpy8JtynziWV+XrOvvLsi8
  62463. 1xtZPCvM8hnIk2snYxnP/Okm+Mpxm3+T/jRnhE6Z6/yzeAkzcLpmpnbtG3PrGqUNxCITIJRWCk4s
  62464. bE6x/c+cCbqiM+2HAgMBAAGjYzBhMB0GA1UdDgQWBBTdBAkHovV6fVJTEpKV7jiAJQ2mWTAPBgNV
  62465. HRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFN0ECQei9Xp9UlMSkpXuOIAlDaZZMA4GA1UdDwEB/wQE
  62466. AwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAIBgRlCn7Jp0cHh5wYfGVcpNxJK1ok1iOMq8bs3AD/CUr
  62467. dIWQPXhq9LmLpZc7tRiRux6n+UBbkflVma8eEdBcHadm47GUBwwyOabqG7B52B2ccETjit3E+ZUf
  62468. ijhDPwGFpUenPUayvOUiaPd7nNgsPgohyC0zrL/FgZkxdMF1ccW+sfAjRfSda/wZY52jvATGGAsl
  62469. u1OJD7OAUN5F7kR/q5R4ZJjT9ijdh9hwZXT7DrkT66cPYakylszeu+1jTBi7qUD3oFRuIIhxdRjq
  62470. erQ0cuAjJ3dctpDqhiVAq+8zD8ufgr6iIPv2tS0a5sKFsXQP+8hlAqRSAUfdSSLBv9jra6x+3uxj
  62471. MxW3IwiPxg+NQVrdjsW5j+VFP3jbutIbQLH+cU0/4IGiul607BXgk90IH37hVZkLId6Tngr75qNJ
  62472. vTYw/ud3sqB1l7UtgYgXZSD32pAAn8lSzDLKNXz1PQ/YK9f1JmzJBjSWFupwWRoyeXkLtoh/D1JI
  62473. Pb9s2KJELtFOt3JY04kTlf5Eq/jXixtunLwsoFvVagCvXzfh1foQC5ichucmj87w7G6KVwuA406y
  62474. wKBjYZC6VWg3dGq2ktufoYYitmUnDuy2n0Jg5GfCtdpBC8TTi2EbvPofkSvXRAdeuims2cXp71NI
  62475. WuuA8ShYIc2wBlX7Jz9TkHCpBB5XJ7k=
  62476. -----END CERTIFICATE-----
  62477. SSL.com Root Certification Authority ECC
  62478. ========================================
  62479. -----BEGIN CERTIFICATE-----
  62480. MIICjTCCAhSgAwIBAgIIdebfy8FoW6gwCgYIKoZIzj0EAwIwfDELMAkGA1UEBhMCVVMxDjAMBgNV
  62481. BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xMTAv
  62482. BgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEy
  62483. MTgxNDAzWhcNNDEwMjEyMTgxNDAzWjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAO
  62484. BgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNv
  62485. bSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuBBAAiA2IA
  62486. BEVuqVDEpiM2nl8ojRfLliJkP9x6jh3MCLOicSS6jkm5BBtHllirLZXI7Z4INcgn64mMU1jrYor+
  62487. 8FsPazFSY0E7ic3s7LaNGdM0B9y7xgZ/wkWV7Mt/qCPgCemB+vNH06NjMGEwHQYDVR0OBBYEFILR
  62488. hXMw5zUE044CkvvlpNHEIejNMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUgtGFczDnNQTT
  62489. jgKS++Wk0cQh6M0wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2cAMGQCMG/n61kRpGDPYbCW
  62490. e+0F+S8Tkdzt5fxQaxFGRrMcIQBiu77D5+jNB5n5DQtdcj7EqgIwH7y6C+IwJPt8bYBVCpk+gA0z
  62491. 5Wajs6O7pdWLjwkspl1+4vAHCGht0nxpbl/f5Wpl
  62492. -----END CERTIFICATE-----
  62493. SSL.com EV Root Certification Authority RSA R2
  62494. ==============================================
  62495. -----BEGIN CERTIFICATE-----
  62496. MIIF6zCCA9OgAwIBAgIIVrYpzTS8ePYwDQYJKoZIhvcNAQELBQAwgYIxCzAJBgNVBAYTAlVTMQ4w
  62497. DAYDVQQIDAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9u
  62498. MTcwNQYDVQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIy
  62499. MB4XDTE3MDUzMTE4MTQzN1oXDTQyMDUzMDE4MTQzN1owgYIxCzAJBgNVBAYTAlVTMQ4wDAYDVQQI
  62500. DAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMTcwNQYD
  62501. VQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIyMIICIjAN
  62502. BgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAjzZlQOHWTcDXtOlG2mvqM0fNTPl9fb69LT3w23jh
  62503. hqXZuglXaO1XPqDQCEGD5yhBJB/jchXQARr7XnAjssufOePPxU7Gkm0mxnu7s9onnQqG6YE3Bf7w
  62504. cXHswxzpY6IXFJ3vG2fThVUCAtZJycxa4bH3bzKfydQ7iEGonL3Lq9ttewkfokxykNorCPzPPFTO
  62505. Zw+oz12WGQvE43LrrdF9HSfvkusQv1vrO6/PgN3B0pYEW3p+pKk8OHakYo6gOV7qd89dAFmPZiw+
  62506. B6KjBSYRaZfqhbcPlgtLyEDhULouisv3D5oi53+aNxPN8k0TayHRwMwi8qFG9kRpnMphNQcAb9Zh
  62507. CBHqurj26bNg5U257J8UZslXWNvNh2n4ioYSA0e/ZhN2rHd9NCSFg83XqpyQGp8hLH94t2S42Oim
  62508. 9HizVcuE0jLEeK6jj2HdzghTreyI/BXkmg3mnxp3zkyPuBQVPWKchjgGAGYS5Fl2WlPAApiiECto
  62509. RHuOec4zSnaqW4EWG7WK2NAAe15itAnWhmMOpgWVSbooi4iTsjQc2KRVbrcc0N6ZVTsj9CLg+Slm
  62510. JuwgUHfbSguPvuUCYHBBXtSuUDkiFCbLsjtzdFVHB3mBOagwE0TlBIqulhMlQg+5U8Sb/M3kHN48
  62511. +qvWBkofZ6aYMBzdLNvcGJVXZsb/XItW9XcCAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNV
  62512. HSMEGDAWgBT5YLvU49U09rj1BoAlp3PbRmmonjAdBgNVHQ4EFgQU+WC71OPVNPa49QaAJadz20Zp
  62513. qJ4wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQBWs47LCp1Jjr+kxJG7ZhcFUZh1
  62514. ++VQLHqe8RT6q9OKPv+RKY9ji9i0qVQBDb6Thi/5Sm3HXvVX+cpVHBK+Rw82xd9qt9t1wkclf7nx
  62515. Y/hoLVUE0fKNsKTPvDxeH3jnpaAgcLAExbf3cqfeIg29MyVGjGSSJuM+LmOW2puMPfgYCdcDzH2G
  62516. guDKBAdRUNf/ktUM79qGn5nX67evaOI5JpS6aLe/g9Pqemc9YmeuJeVy6OLk7K4S9ksrPJ/psEDz
  62517. OFSz/bdoyNrGj1E8svuR3Bznm53htw1yj+KkxKl4+esUrMZDBcJlOSgYAsOCsp0FvmXtll9ldDz7
  62518. CTUue5wT/RsPXcdtgTpWD8w74a8CLyKsRspGPKAcTNZEtF4uXBVmCeEmKf7GUmG6sXP/wwyc5Wxq
  62519. lD8UykAWlYTzWamsX0xhk23RO8yilQwipmdnRC652dKKQbNmC1r7fSOl8hqw/96bg5Qu0T/fkreR
  62520. rwU7ZcegbLHNYhLDkBvjJc40vG93drEQw/cFGsDWr3RiSBd3kmmQYRzelYB0VI8YHMPzA9C/pEN1
  62521. hlMYegouCRw2n5H9gooiS9EOUCXdywMMF8mDAAhONU2Ki+3wApRmLER/y5UnlhetCTCstnEXbosX
  62522. 9hwJ1C07mKVx01QT2WDz9UtmT/rx7iASjbSsV7FFY6GsdqnC+w==
  62523. -----END CERTIFICATE-----
  62524. SSL.com EV Root Certification Authority ECC
  62525. ===========================================
  62526. -----BEGIN CERTIFICATE-----
  62527. MIIClDCCAhqgAwIBAgIILCmcWxbtBZUwCgYIKoZIzj0EAwIwfzELMAkGA1UEBhMCVVMxDjAMBgNV
  62528. BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xNDAy
  62529. BgNVBAMMK1NTTC5jb20gRVYgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYw
  62530. MjEyMTgxNTIzWhcNNDEwMjEyMTgxNTIzWjB/MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx
  62531. EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjE0MDIGA1UEAwwrU1NM
  62532. LmNvbSBFViBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuB
  62533. BAAiA2IABKoSR5CYG/vvw0AHgyBO8TCCogbR8pKGYfL2IWjKAMTH6kMAVIbc/R/fALhBYlzccBYy
  62534. 3h+Z1MzFB8gIH2EWB1E9fVwHU+M1OIzfzZ/ZLg1KthkuWnBaBu2+8KGwytAJKaNjMGEwHQYDVR0O
  62535. BBYEFFvKXuXe0oGqzagtZFG22XKbl+ZPMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUW8pe
  62536. 5d7SgarNqC1kUbbZcpuX5k8wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2gAMGUCMQCK5kCJ
  62537. N+vp1RPZytRrJPOwPYdGWBrssd9v+1a6cGvHOMzosYxPD/fxZ3YOg9AeUY8CMD32IygmTMZgh5Mm
  62538. m7I1HrrW9zzRHM76JTymGoEVW/MSD2zuZYrJh6j5B+BimoxcSg==
  62539. -----END CERTIFICATE-----
  62540. GlobalSign Root CA - R6
  62541. =======================
  62542. -----BEGIN CERTIFICATE-----
  62543. MIIFgzCCA2ugAwIBAgIORea7A4Mzw4VlSOb/RVEwDQYJKoZIhvcNAQEMBQAwTDEgMB4GA1UECxMX
  62544. R2xvYmFsU2lnbiBSb290IENBIC0gUjYxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkds
  62545. b2JhbFNpZ24wHhcNMTQxMjEwMDAwMDAwWhcNMzQxMjEwMDAwMDAwWjBMMSAwHgYDVQQLExdHbG9i
  62546. YWxTaWduIFJvb3QgQ0EgLSBSNjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFs
  62547. U2lnbjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAJUH6HPKZvnsFMp7PPcNCPG0RQss
  62548. grRIxutbPK6DuEGSMxSkb3/pKszGsIhrxbaJ0cay/xTOURQh7ErdG1rG1ofuTToVBu1kZguSgMpE
  62549. 3nOUTvOniX9PeGMIyBJQbUJmL025eShNUhqKGoC3GYEOfsSKvGRMIRxDaNc9PIrFsmbVkJq3MQbF
  62550. vuJtMgamHvm566qjuL++gmNQ0PAYid/kD3n16qIfKtJwLnvnvJO7bVPiSHyMEAc4/2ayd2F+4OqM
  62551. PKq0pPbzlUoSB239jLKJz9CgYXfIWHSw1CM69106yqLbnQneXUQtkPGBzVeS+n68UARjNN9rkxi+
  62552. azayOeSsJDa38O+2HBNXk7besvjihbdzorg1qkXy4J02oW9UivFyVm4uiMVRQkQVlO6jxTiWm05O
  62553. WgtH8wY2SXcwvHE35absIQh1/OZhFj931dmRl4QKbNQCTXTAFO39OfuD8l4UoQSwC+n+7o/hbguy
  62554. CLNhZglqsQY6ZZZZwPA1/cnaKI0aEYdwgQqomnUdnjqGBQCe24DWJfncBZ4nWUx2OVvq+aWh2IMP
  62555. 0f/fMBH5hc8zSPXKbWQULHpYT9NLCEnFlWQaYw55PfWzjMpYrZxCRXluDocZXFSxZba/jJvcE+kN
  62556. b7gu3GduyYsRtYQUigAZcIN5kZeR1BonvzceMgfYFGM8KEyvAgMBAAGjYzBhMA4GA1UdDwEB/wQE
  62557. AwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSubAWjkxPioufi1xzWx/B/yGdToDAfBgNV
  62558. HSMEGDAWgBSubAWjkxPioufi1xzWx/B/yGdToDANBgkqhkiG9w0BAQwFAAOCAgEAgyXt6NH9lVLN
  62559. nsAEoJFp5lzQhN7craJP6Ed41mWYqVuoPId8AorRbrcWc+ZfwFSY1XS+wc3iEZGtIxg93eFyRJa0
  62560. lV7Ae46ZeBZDE1ZXs6KzO7V33EByrKPrmzU+sQghoefEQzd5Mr6155wsTLxDKZmOMNOsIeDjHfrY
  62561. BzN2VAAiKrlNIC5waNrlU/yDXNOd8v9EDERm8tLjvUYAGm0CuiVdjaExUd1URhxN25mW7xocBFym
  62562. Fe944Hn+Xds+qkxV/ZoVqW/hpvvfcDDpw+5CRu3CkwWJ+n1jez/QcYF8AOiYrg54NMMl+68KnyBr
  62563. 3TsTjxKM4kEaSHpzoHdpx7Zcf4LIHv5YGygrqGytXm3ABdJ7t+uA/iU3/gKbaKxCXcPu9czc8FB1
  62564. 0jZpnOZ7BN9uBmm23goJSFmH63sUYHpkqmlD75HHTOwY3WzvUy2MmeFe8nI+z1TIvWfspA9MRf/T
  62565. uTAjB0yPEL+GltmZWrSZVxykzLsViVO6LAUP5MSeGbEYNNVMnbrt9x+vJJUEeKgDu+6B5dpffItK
  62566. oZB0JaezPkvILFa9x8jvOOJckvB595yEunQtYQEgfn7R8k8HWV+LLUNS60YMlOH1Zkd5d9VUWx+t
  62567. JDfLRVpOoERIyNiwmcUVhAn21klJwGW45hpxbqCo8YLoRT5s1gLXCmeDBVrJpBA=
  62568. -----END CERTIFICATE-----
  62569. OISTE WISeKey Global Root GC CA
  62570. ===============================
  62571. -----BEGIN CERTIFICATE-----
  62572. MIICaTCCAe+gAwIBAgIQISpWDK7aDKtARb8roi066jAKBggqhkjOPQQDAzBtMQswCQYDVQQGEwJD
  62573. SDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNlZDEo
  62574. MCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQyBDQTAeFw0xNzA1MDkwOTQ4MzRa
  62575. Fw00MjA1MDkwOTU4MzNaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYDVQQL
  62576. ExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEdsb2Jh
  62577. bCBSb290IEdDIENBMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAETOlQwMYPchi82PG6s4nieUqjFqdr
  62578. VCTbUf/q9Akkwwsin8tqJ4KBDdLArzHkdIJuyiXZjHWd8dvQmqJLIX4Wp2OQ0jnUsYd4XxiWD1Ab
  62579. NTcPasbc2RNNpI6QN+a9WzGRo1QwUjAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd
  62580. BgNVHQ4EFgQUSIcUrOPDnpBgOtfKie7TrYy0UGYwEAYJKwYBBAGCNxUBBAMCAQAwCgYIKoZIzj0E
  62581. AwMDaAAwZQIwJsdpW9zV57LnyAyMjMPdeYwbY9XJUpROTYJKcx6ygISpJcBMWm1JKWB4E+J+SOtk
  62582. AjEA2zQgMgj/mkkCtojeFK9dbJlxjRo/i9fgojaGHAeCOnZT/cKi7e97sIBPWA9LUzm9
  62583. -----END CERTIFICATE-----
  62584. GTS Root R1
  62585. ===========
  62586. -----BEGIN CERTIFICATE-----
  62587. MIIFWjCCA0KgAwIBAgIQbkepxUtHDA3sM9CJuRz04TANBgkqhkiG9w0BAQwFADBHMQswCQYDVQQG
  62588. EwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJv
  62589. b3QgUjEwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAG
  62590. A1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjEwggIi
  62591. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2EQKLHuOhd5s73L+UPreVp0A8of2C+X0yBoJx
  62592. 9vaMf/vo27xqLpeXo4xL+Sv2sfnOhB2x+cWX3u+58qPpvBKJXqeqUqv4IyfLpLGcY9vXmX7wCl7r
  62593. aKb0xlpHDU0QM+NOsROjyBhsS+z8CZDfnWQpJSMHobTSPS5g4M/SCYe7zUjwTcLCeoiKu7rPWRnW
  62594. r4+wB7CeMfGCwcDfLqZtbBkOtdh+JhpFAz2weaSUKK0PfyblqAj+lug8aJRT7oM6iCsVlgmy4HqM
  62595. LnXWnOunVmSPlk9orj2XwoSPwLxAwAtcvfaHszVsrBhQf4TgTM2S0yDpM7xSma8ytSmzJSq0SPly
  62596. 4cpk9+aCEI3oncKKiPo4Zor8Y/kB+Xj9e1x3+naH+uzfsQ55lVe0vSbv1gHR6xYKu44LtcXFilWr
  62597. 06zqkUspzBmkMiVOKvFlRNACzqrOSbTqn3yDsEB750Orp2yjj32JgfpMpf/VjsPOS+C12LOORc92
  62598. wO1AK/1TD7Cn1TsNsYqiA94xrcx36m97PtbfkSIS5r762DL8EGMUUXLeXdYWk70paDPvOmbsB4om
  62599. 3xPXV2V4J95eSRQAogB/mqghtqmxlbCluQ0WEdrHbEg8QOB+DVrNVjzRlwW5y0vtOUucxD/SVRNu
  62600. JLDWcfr0wbrM7Rv1/oFB2ACYPTrIrnqYNxgFlQIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD
  62601. VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU5K8rJnEaK0gnhS9SZizv8IkTcT4wDQYJKoZIhvcNAQEM
  62602. BQADggIBADiWCu49tJYeX++dnAsznyvgyv3SjgofQXSlfKqE1OXyHuY3UjKcC9FhHb8owbZEKTV1
  62603. d5iyfNm9dKyKaOOpMQkpAWBz40d8U6iQSifvS9efk+eCNs6aaAyC58/UEBZvXw6ZXPYfcX3v73sv
  62604. fuo21pdwCxXu11xWajOl40k4DLh9+42FpLFZXvRq4d2h9mREruZRgyFmxhE+885H7pwoHyXa/6xm
  62605. ld01D1zvICxi/ZG6qcz8WpyTgYMpl0p8WnK0OdC3d8t5/Wk6kjftbjhlRn7pYL15iJdfOBL07q9b
  62606. gsiG1eGZbYwE8na6SfZu6W0eX6DvJ4J2QPim01hcDyxC2kLGe4g0x8HYRZvBPsVhHdljUEn2NIVq
  62607. 4BjFbkerQUIpm/ZgDdIx02OYI5NaAIFItO/Nis3Jz5nu2Z6qNuFoS3FJFDYoOj0dzpqPJeaAcWEr
  62608. tXvM+SUWgeExX6GjfhaknBZqlxi9dnKlC54dNuYvoS++cJEPqOba+MSSQGwlfnuzCdyyF62ARPBo
  62609. pY+Udf90WuioAnwMCeKpSwughQtiue+hMZL77/ZRBIls6Kl0obsXs7X9SQ98POyDGCBDTtWTurQ0
  62610. sR8WNh8M5mQ5Fkzc4P4dyKliPUDqysU0ArSuiYgzNdwsE3PYJ/HQcu51OyLemGhmW/HGY0dVHLql
  62611. CFF1pkgl
  62612. -----END CERTIFICATE-----
  62613. GTS Root R2
  62614. ===========
  62615. -----BEGIN CERTIFICATE-----
  62616. MIIFWjCCA0KgAwIBAgIQbkepxlqz5yDFMJo/aFLybzANBgkqhkiG9w0BAQwFADBHMQswCQYDVQQG
  62617. EwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJv
  62618. b3QgUjIwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAG
  62619. A1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjIwggIi
  62620. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDO3v2m++zsFDQ8BwZabFn3GTXd98GdVarTzTuk
  62621. k3LvCvptnfbwhYBboUhSnznFt+4orO/LdmgUud+tAWyZH8QiHZ/+cnfgLFuv5AS/T3KgGjSY6Dlo
  62622. 7JUle3ah5mm5hRm9iYz+re026nO8/4Piy33B0s5Ks40FnotJk9/BW9BuXvAuMC6C/Pq8tBcKSOWI
  62623. m8Wba96wyrQD8Nr0kLhlZPdcTK3ofmZemde4wj7I0BOdre7kRXuJVfeKH2JShBKzwkCX44ofR5Gm
  62624. dFrS+LFjKBC4swm4VndAoiaYecb+3yXuPuWgf9RhD1FLPD+M2uFwdNjCaKH5wQzpoeJ/u1U8dgbu
  62625. ak7MkogwTZq9TwtImoS1mKPV+3PBV2HdKFZ1E66HjucMUQkQdYhMvI35ezzUIkgfKtzra7tEscsz
  62626. cTJGr61K8YzodDqs5xoic4DSMPclQsciOzsSrZYuxsN2B6ogtzVJV+mSSeh2FnIxZyuWfoqjx5RW
  62627. Ir9qS34BIbIjMt/kmkRtWVtd9QCgHJvGeJeNkP+byKq0rxFROV7Z+2et1VsRnTKaG73Vululycsl
  62628. aVNVJ1zgyjbLiGH7HrfQy+4W+9OmTN6SpdTi3/UGVN4unUu0kzCqgc7dGtxRcw1PcOnlthYhGXmy
  62629. 5okLdWTK1au8CcEYof/UVKGFPP0UJAOyh9OktwIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD
  62630. VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUu//KjiOfT5nK2+JopqUVJxce2Q4wDQYJKoZIhvcNAQEM
  62631. BQADggIBALZp8KZ3/p7uC4Gt4cCpx/k1HUCCq+YEtN/L9x0Pg/B+E02NjO7jMyLDOfxA325BS0JT
  62632. vhaI8dI4XsRomRyYUpOM52jtG2pzegVATX9lO9ZY8c6DR2Dj/5epnGB3GFW1fgiTz9D2PGcDFWEJ
  62633. +YF59exTpJ/JjwGLc8R3dtyDovUMSRqodt6Sm2T4syzFJ9MHwAiApJiS4wGWAqoC7o87xdFtCjMw
  62634. c3i5T1QWvwsHoaRc5svJXISPD+AVdyx+Jn7axEvbpxZ3B7DNdehyQtaVhJ2Gg/LkkM0JR9SLA3Da
  62635. WsYDQvTtN6LwG1BUSw7YhN4ZKJmBR64JGz9I0cNv4rBgF/XuIwKl2gBbbZCr7qLpGzvpx0QnRY5r
  62636. n/WkhLx3+WuXrD5RRaIRpsyF7gpo8j5QOHokYh4XIDdtak23CZvJ/KRY9bb7nE4Yu5UC56Gtmwfu
  62637. Nmsk0jmGwZODUNKBRqhfYlcsu2xkiAhu7xNUX90txGdj08+JN7+dIPT7eoOboB6BAFDC5AwiWVIQ
  62638. 7UNWhwD4FFKnHYuTjKJNRn8nxnGbJN7k2oaLDX5rIMHAnuFl2GqjpuiFizoHCBy69Y9Vmhh1fuXs
  62639. gWbRIXOhNUQLgD1bnF5vKheW0YMjiGZt5obicDIvUiLnyOd/xCxgXS/Dr55FBcOEArf9LAhST4Ld
  62640. o/DUhgkC
  62641. -----END CERTIFICATE-----
  62642. GTS Root R3
  62643. ===========
  62644. -----BEGIN CERTIFICATE-----
  62645. MIICDDCCAZGgAwIBAgIQbkepx2ypcyRAiQ8DVd2NHTAKBggqhkjOPQQDAzBHMQswCQYDVQQGEwJV
  62646. UzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3Qg
  62647. UjMwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UE
  62648. ChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjMwdjAQBgcq
  62649. hkjOPQIBBgUrgQQAIgNiAAQfTzOHMymKoYTey8chWEGJ6ladK0uFxh1MJ7x/JlFyb+Kf1qPKzEUU
  62650. Rout736GjOyxfi//qXGdGIRFBEFVbivqJn+7kAHjSxm65FSWRQmx1WyRRK2EE46ajA2ADDL24Cej
  62651. QjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTB8Sa6oC2uhYHP
  62652. 0/EqEr24Cmf9vDAKBggqhkjOPQQDAwNpADBmAjEAgFukfCPAlaUs3L6JbyO5o91lAFJekazInXJ0
  62653. glMLfalAvWhgxeG4VDvBNhcl2MG9AjEAnjWSdIUlUfUk7GRSJFClH9voy8l27OyCbvWFGFPouOOa
  62654. KaqW04MjyaR7YbPMAuhd
  62655. -----END CERTIFICATE-----
  62656. GTS Root R4
  62657. ===========
  62658. -----BEGIN CERTIFICATE-----
  62659. MIICCjCCAZGgAwIBAgIQbkepyIuUtui7OyrYorLBmTAKBggqhkjOPQQDAzBHMQswCQYDVQQGEwJV
  62660. UzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3Qg
  62661. UjQwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UE
  62662. ChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjQwdjAQBgcq
  62663. hkjOPQIBBgUrgQQAIgNiAATzdHOnaItgrkO4NcWBMHtLSZ37wWHO5t5GvWvVYRg1rkDdc/eJkTBa
  62664. 6zzuhXyiQHY7qca4R9gq55KRanPpsXI5nymfopjTX15YhmUPoYRlBtHci8nHc8iMai/lxKvRHYqj
  62665. QjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSATNbrdP9JNqPV
  62666. 2Py1PsVq8JQdjDAKBggqhkjOPQQDAwNnADBkAjBqUFJ0CMRw3J5QdCHojXohw0+WbhXRIjVhLfoI
  62667. N+4Zba3bssx9BzT1YBkstTTZbyACMANxsbqjYAuG7ZoIapVon+Kz4ZNkfF6Tpt95LY2F45TPI11x
  62668. zPKwTdb+mciUqXWi4w==
  62669. -----END CERTIFICATE-----
  62670. UCA Global G2 Root
  62671. ==================
  62672. -----BEGIN CERTIFICATE-----
  62673. MIIFRjCCAy6gAwIBAgIQXd+x2lqj7V2+WmUgZQOQ7zANBgkqhkiG9w0BAQsFADA9MQswCQYDVQQG
  62674. EwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxGzAZBgNVBAMMElVDQSBHbG9iYWwgRzIgUm9vdDAeFw0x
  62675. NjAzMTEwMDAwMDBaFw00MDEyMzEwMDAwMDBaMD0xCzAJBgNVBAYTAkNOMREwDwYDVQQKDAhVbmlU
  62676. cnVzdDEbMBkGA1UEAwwSVUNBIEdsb2JhbCBHMiBSb290MIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  62677. MIICCgKCAgEAxeYrb3zvJgUno4Ek2m/LAfmZmqkywiKHYUGRO8vDaBsGxUypK8FnFyIdK+35KYmT
  62678. oni9kmugow2ifsqTs6bRjDXVdfkX9s9FxeV67HeToI8jrg4aA3++1NDtLnurRiNb/yzmVHqUwCoV
  62679. 8MmNsHo7JOHXaOIxPAYzRrZUEaalLyJUKlgNAQLx+hVRZ2zA+te2G3/RVogvGjqNO7uCEeBHANBS
  62680. h6v7hn4PJGtAnTRnvI3HLYZveT6OqTwXS3+wmeOwcWDcC/Vkw85DvG1xudLeJ1uK6NjGruFZfc8o
  62681. LTW4lVYa8bJYS7cSN8h8s+1LgOGN+jIjtm+3SJUIsUROhYw6AlQgL9+/V087OpAh18EmNVQg7Mc/
  62682. R+zvWr9LesGtOxdQXGLYD0tK3Cv6brxzks3sx1DoQZbXqX5t2Okdj4q1uViSukqSKwxW/YDrCPBe
  62683. KW4bHAyvj5OJrdu9o54hyokZ7N+1wxrrFv54NkzWbtA+FxyQF2smuvt6L78RHBgOLXMDj6DlNaBa
  62684. 4kx1HXHhOThTeEDMg5PXCp6dW4+K5OXgSORIskfNTip1KnvyIvbJvgmRlld6iIis7nCs+dwp4wwc
  62685. OxJORNanTrAmyPPZGpeRaOrvjUYG0lZFWJo8DA+DuAUlwznPO6Q0ibd5Ei9Hxeepl2n8pndntd97
  62686. 8XplFeRhVmUCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O
  62687. BBYEFIHEjMz15DD/pQwIX4wVZyF0Ad/fMA0GCSqGSIb3DQEBCwUAA4ICAQATZSL1jiutROTL/7lo
  62688. 5sOASD0Ee/ojL3rtNtqyzm325p7lX1iPyzcyochltq44PTUbPrw7tgTQvPlJ9Zv3hcU2tsu8+Mg5
  62689. 1eRfB70VVJd0ysrtT7q6ZHafgbiERUlMjW+i67HM0cOU2kTC5uLqGOiiHycFutfl1qnN3e92mI0A
  62690. Ds0b+gO3joBYDic/UvuUospeZcnWhNq5NXHzJsBPd+aBJ9J3O5oUb3n09tDh05S60FdRvScFDcH9
  62691. yBIw7m+NESsIndTUv4BFFJqIRNow6rSn4+7vW4LVPtateJLbXDzz2K36uGt/xDYotgIVilQsnLAX
  62692. c47QN6MUPJiVAAwpBVueSUmxX8fjy88nZY41F7dXyDDZQVu5FLbowg+UMaeUmMxq67XhJ/UQqAHo
  62693. jhJi6IjMtX9Gl8CbEGY4GjZGXyJoPd/JxhMnq1MGrKI8hgZlb7F+sSlEmqO6SWkoaY/X5V+tBIZk
  62694. bxqgDMUIYs6Ao9Dz7GjevjPHF1t/gMRMTLGmhIrDO7gJzRSBuhjjVFc2/tsvfEehOjPI+Vg7RE+x
  62695. ygKJBJYoaMVLuCaJu9YzL1DV/pqJuhgyklTGW+Cd+V7lDSKb9triyCGyYiGqhkCyLmTTX8jjfhFn
  62696. RR8F/uOi77Oos/N9j/gMHyIfLXC0uAE0djAA5SN4p1bXUB+K+wb1whnw0A==
  62697. -----END CERTIFICATE-----
  62698. UCA Extended Validation Root
  62699. ============================
  62700. -----BEGIN CERTIFICATE-----
  62701. MIIFWjCCA0KgAwIBAgIQT9Irj/VkyDOeTzRYZiNwYDANBgkqhkiG9w0BAQsFADBHMQswCQYDVQQG
  62702. EwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9u
  62703. IFJvb3QwHhcNMTUwMzEzMDAwMDAwWhcNMzgxMjMxMDAwMDAwWjBHMQswCQYDVQQGEwJDTjERMA8G
  62704. A1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9uIFJvb3QwggIi
  62705. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCpCQcoEwKwmeBkqh5DFnpzsZGgdT6o+uM4AHrs
  62706. iWogD4vFsJszA1qGxliG1cGFu0/GnEBNyr7uaZa4rYEwmnySBesFK5pI0Lh2PpbIILvSsPGP2KxF
  62707. Rv+qZ2C0d35qHzwaUnoEPQc8hQ2E0B92CvdqFN9y4zR8V05WAT558aopO2z6+I9tTcg1367r3CTu
  62708. eUWnhbYFiN6IXSV8l2RnCdm/WhUFhvMJHuxYMjMR83dksHYf5BA1FxvyDrFspCqjc/wJHx4yGVMR
  62709. 59mzLC52LqGj3n5qiAno8geK+LLNEOfic0CTuwjRP+H8C5SzJe98ptfRr5//lpr1kXuYC3fUfugH
  62710. 0mK1lTnj8/FtDw5lhIpjVMWAtuCeS31HJqcBCF3RiJ7XwzJE+oJKCmhUfzhTA8ykADNkUVkLo4KR
  62711. el7sFsLzKuZi2irbWWIQJUoqgQtHB0MGcIfS+pMRKXpITeuUx3BNr2fVUbGAIAEBtHoIppB/TuDv
  62712. B0GHr2qlXov7z1CymlSvw4m6WC31MJixNnI5fkkE/SmnTHnkBVfblLkWU41Gsx2VYVdWf6/wFlth
  62713. WG82UBEL2KwrlRYaDh8IzTY0ZRBiZtWAXxQgXy0MoHgKaNYs1+lvK9JKBZP8nm9rZ/+I8U6laUpS
  62714. NwXqxhaN0sSZ0YIrO7o1dfdRUVjzyAfd5LQDfwIDAQABo0IwQDAdBgNVHQ4EFgQU2XQ65DA9DfcS
  62715. 3H5aBZ8eNJr34RQwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQEL
  62716. BQADggIBADaNl8xCFWQpN5smLNb7rhVpLGsaGvdftvkHTFnq88nIua7Mui563MD1sC3AO6+fcAUR
  62717. ap8lTwEpcOPlDOHqWnzcSbvBHiqB9RZLcpHIojG5qtr8nR/zXUACE/xOHAbKsxSQVBcZEhrxH9cM
  62718. aVr2cXj0lH2RC47skFSOvG+hTKv8dGT9cZr4QQehzZHkPJrgmzI5c6sq1WnIeJEmMX3ixzDx/BR4
  62719. dxIOE/TdFpS/S2d7cFOFyrC78zhNLJA5wA3CXWvp4uXViI3WLL+rG761KIcSF3Ru/H38j9CHJrAb
  62720. +7lsq+KePRXBOy5nAliRn+/4Qh8st2j1da3Ptfb/EX3C8CSlrdP6oDyp+l3cpaDvRKS+1ujl5BOW
  62721. F3sGPjLtx7dCvHaj2GU4Kzg1USEODm8uNBNA4StnDG1KQTAYI1oyVZnJF+A83vbsea0rWBmirSwi
  62722. GpWOvpaQXUJXxPkUAzUrHC1RVwinOt4/5Mi0A3PCwSaAuwtCH60NryZy2sy+s6ODWA2CxR9GUeOc
  62723. GMyNm43sSet1UNWMKFnKdDTajAshqx7qG+XH/RU+wBeq+yNuJkbL+vmxcmtpzyKEC2IPrNkZAJSi
  62724. djzULZrtBJ4tBmIQN1IchXIbJ+XMxjHsN+xjWZsLHXbMfjKaiJUINlK73nZfdklJrX+9ZSCyycEr
  62725. dhh2n1ax
  62726. -----END CERTIFICATE-----
  62727. Certigna Root CA
  62728. ================
  62729. -----BEGIN CERTIFICATE-----
  62730. MIIGWzCCBEOgAwIBAgIRAMrpG4nxVQMNo+ZBbcTjpuEwDQYJKoZIhvcNAQELBQAwWjELMAkGA1UE
  62731. BhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczEcMBoGA1UECwwTMDAwMiA0ODE0NjMwODEwMDAzNjEZ
  62732. MBcGA1UEAwwQQ2VydGlnbmEgUm9vdCBDQTAeFw0xMzEwMDEwODMyMjdaFw0zMzEwMDEwODMyMjda
  62733. MFoxCzAJBgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxHDAaBgNVBAsMEzAwMDIgNDgxNDYz
  62734. MDgxMDAwMzYxGTAXBgNVBAMMEENlcnRpZ25hIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  62735. DwAwggIKAoICAQDNGDllGlmx6mQWDoyUJJV8g9PFOSbcDO8WV43X2KyjQn+Cyu3NW9sOty3tRQgX
  62736. stmzy9YXUnIo245Onoq2C/mehJpNdt4iKVzSs9IGPjA5qXSjklYcoW9MCiBtnyN6tMbaLOQdLNyz
  62737. KNAT8kxOAkmhVECe5uUFoC2EyP+YbNDrihqECB63aCPuI9Vwzm1RaRDuoXrC0SIxwoKF0vJVdlB8
  62738. JXrJhFwLrN1CTivngqIkicuQstDuI7pmTLtipPlTWmR7fJj6o0ieD5Wupxj0auwuA0Wv8HT4Ks16
  62739. XdG+RCYyKfHx9WzMfgIhC59vpD++nVPiz32pLHxYGpfhPTc3GGYo0kDFUYqMwy3OU4gkWGQwFsWq
  62740. 4NYKpkDfePb1BHxpE4S80dGnBs8B92jAqFe7OmGtBIyT46388NtEbVncSVmurJqZNjBBe3YzIoej
  62741. wpKGbvlw7q6Hh5UbxHq9MfPU0uWZ/75I7HX1eBYdpnDBfzwboZL7z8g81sWTCo/1VTp2lc5ZmIoJ
  62742. lXcymoO6LAQ6l73UL77XbJuiyn1tJslV1c/DeVIICZkHJC1kJWumIWmbat10TWuXekG9qxf5kBdI
  62743. jzb5LdXF2+6qhUVB+s06RbFo5jZMm5BX7CO5hwjCxAnxl4YqKE3idMDaxIzb3+KhF1nOJFl0Mdp/
  62744. /TBt2dzhauH8XwIDAQABo4IBGjCCARYwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYw
  62745. HQYDVR0OBBYEFBiHVuBud+4kNTxOc5of1uHieX4rMB8GA1UdIwQYMBaAFBiHVuBud+4kNTxOc5of
  62746. 1uHieX4rMEQGA1UdIAQ9MDswOQYEVR0gADAxMC8GCCsGAQUFBwIBFiNodHRwczovL3d3d3cuY2Vy
  62747. dGlnbmEuZnIvYXV0b3JpdGVzLzBtBgNVHR8EZjBkMC+gLaArhilodHRwOi8vY3JsLmNlcnRpZ25h
  62748. LmZyL2NlcnRpZ25hcm9vdGNhLmNybDAxoC+gLYYraHR0cDovL2NybC5kaGlteW90aXMuY29tL2Nl
  62749. cnRpZ25hcm9vdGNhLmNybDANBgkqhkiG9w0BAQsFAAOCAgEAlLieT/DjlQgi581oQfccVdV8AOIt
  62750. OoldaDgvUSILSo3L6btdPrtcPbEo/uRTVRPPoZAbAh1fZkYJMyjhDSSXcNMQH+pkV5a7XdrnxIxP
  62751. TGRGHVyH41neQtGbqH6mid2PHMkwgu07nM3A6RngatgCdTer9zQoKJHyBApPNeNgJgH60BGM+RFq
  62752. 7q89w1DTj18zeTyGqHNFkIwgtnJzFyO+B2XleJINugHA64wcZr+shncBlA2c5uk5jR+mUYyZDDl3
  62753. 4bSb+hxnV29qao6pK0xXeXpXIs/NX2NGjVxZOob4Mkdio2cNGJHc+6Zr9UhhcyNZjgKnvETq9Emd
  62754. 8VRY+WCv2hikLyhF3HqgiIZd8zvn/yk1gPxkQ5Tm4xxvvq0OKmOZK8l+hfZx6AYDlf7ej0gcWtSS
  62755. 6Cvu5zHbugRqh5jnxV/vfaci9wHYTfmJ0A6aBVmknpjZbyvKcL5kwlWj9Omvw5Ip3IgWJJk8jSaY
  62756. tlu3zM63Nwf9JtmYhST/WSMDmu2dnajkXjjO11INb9I/bbEFa0nOipFGc/T2L/Coc3cOZayhjWZS
  62757. aX5LaAzHHjcng6WMxwLkFM1JAbBzs/3GkDpv0mztO+7skb6iQ12LAEpmJURw3kAP+HwV96LOPNde
  62758. E4yBFxgX0b3xdxA61GU5wSesVywlVP+i2k+KYTlerj1KjL0=
  62759. -----END CERTIFICATE-----
  62760. emSign Root CA - G1
  62761. ===================
  62762. -----BEGIN CERTIFICATE-----
  62763. MIIDlDCCAnygAwIBAgIKMfXkYgxsWO3W2DANBgkqhkiG9w0BAQsFADBnMQswCQYDVQQGEwJJTjET
  62764. MBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRl
  62765. ZDEcMBoGA1UEAxMTZW1TaWduIFJvb3QgQ0EgLSBHMTAeFw0xODAyMTgxODMwMDBaFw00MzAyMTgx
  62766. ODMwMDBaMGcxCzAJBgNVBAYTAklOMRMwEQYDVQQLEwplbVNpZ24gUEtJMSUwIwYDVQQKExxlTXVk
  62767. aHJhIFRlY2hub2xvZ2llcyBMaW1pdGVkMRwwGgYDVQQDExNlbVNpZ24gUm9vdCBDQSAtIEcxMIIB
  62768. IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk0u76WaK7p1b1TST0Bsew+eeuGQzf2N4aLTN
  62769. LnF115sgxk0pvLZoYIr3IZpWNVrzdr3YzZr/k1ZLpVkGoZM0Kd0WNHVO8oG0x5ZOrRkVUkr+PHB1
  62770. cM2vK6sVmjM8qrOLqs1D/fXqcP/tzxE7lM5OMhbTI0Aqd7OvPAEsbO2ZLIvZTmmYsvePQbAyeGHW
  62771. DV/D+qJAkh1cF+ZwPjXnorfCYuKrpDhMtTk1b+oDafo6VGiFbdbyL0NVHpENDtjVaqSW0RM8LHhQ
  62772. 6DqS0hdW5TUaQBw+jSztOd9C4INBdN+jzcKGYEho42kLVACL5HZpIQ15TjQIXhTCzLG3rdd8cIrH
  62773. hQIDAQABo0IwQDAdBgNVHQ4EFgQU++8Nhp6w492pufEhF38+/PB3KxowDgYDVR0PAQH/BAQDAgEG
  62774. MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAFn/8oz1h31xPaOfG1vR2vjTnGs2
  62775. vZupYeveFix0PZ7mddrXuqe8QhfnPZHr5X3dPpzxz5KsbEjMwiI/aTvFthUvozXGaCocV685743Q
  62776. NcMYDHsAVhzNixl03r4PEuDQqqE/AjSxcM6dGNYIAwlG7mDgfrbESQRRfXBgvKqy/3lyeqYdPV8q
  62777. +Mri/Tm3R7nrft8EI6/6nAYH6ftjk4BAtcZsCjEozgyfz7MjNYBBjWzEN3uBL4ChQEKF6dk4jeih
  62778. U80Bv2noWgbyRQuQ+q7hv53yrlc8pa6yVvSLZUDp/TGBLPQ5Cdjua6e0ph0VpZj3AYHYhX3zUVxx
  62779. iN66zB+Afko=
  62780. -----END CERTIFICATE-----
  62781. emSign ECC Root CA - G3
  62782. =======================
  62783. -----BEGIN CERTIFICATE-----
  62784. MIICTjCCAdOgAwIBAgIKPPYHqWhwDtqLhDAKBggqhkjOPQQDAzBrMQswCQYDVQQGEwJJTjETMBEG
  62785. A1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRlZDEg
  62786. MB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0gRzMwHhcNMTgwMjE4MTgzMDAwWhcNNDMwMjE4
  62787. MTgzMDAwWjBrMQswCQYDVQQGEwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11
  62788. ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0g
  62789. RzMwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQjpQy4LRL1KPOxst3iAhKAnjlfSU2fySU0WXTsuwYc
  62790. 58Byr+iuL+FBVIcUqEqy6HyC5ltqtdyzdc6LBtCGI79G1Y4PPwT01xySfvalY8L1X44uT6EYGQIr
  62791. MgqCZH0Wk9GjQjBAMB0GA1UdDgQWBBR8XQKEE9TMipuBzhccLikenEhjQjAOBgNVHQ8BAf8EBAMC
  62792. AQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNpADBmAjEAvvNhzwIQHWSVB7gYboiFBS+D
  62793. CBeQyh+KTOgNG3qxrdWBCUfvO6wIBHxcmbHtRwfSAjEAnbpV/KlK6O3t5nYBQnvI+GDZjVGLVTv7
  62794. jHvrZQnD+JbNR6iC8hZVdyR+EhCVBCyj
  62795. -----END CERTIFICATE-----
  62796. emSign Root CA - C1
  62797. ===================
  62798. -----BEGIN CERTIFICATE-----
  62799. MIIDczCCAlugAwIBAgILAK7PALrEzzL4Q7IwDQYJKoZIhvcNAQELBQAwVjELMAkGA1UEBhMCVVMx
  62800. EzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQDExNlbVNp
  62801. Z24gUm9vdCBDQSAtIEMxMB4XDTE4MDIxODE4MzAwMFoXDTQzMDIxODE4MzAwMFowVjELMAkGA1UE
  62802. BhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQD
  62803. ExNlbVNpZ24gUm9vdCBDQSAtIEMxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz+up
  62804. ufGZBczYKCFK83M0UYRWEPWgTywS4/oTmifQz/l5GnRfHXk5/Fv4cI7gklL35CX5VIPZHdPIWoU/
  62805. Xse2B+4+wM6ar6xWQio5JXDWv7V7Nq2s9nPczdcdioOl+yuQFTdrHCZH3DspVpNqs8FqOp099cGX
  62806. OFgFixwR4+S0uF2FHYP+eF8LRWgYSKVGczQ7/g/IdrvHGPMF0Ybzhe3nudkyrVWIzqa2kbBPrH4V
  62807. I5b2P/AgNBbeCsbEBEV5f6f9vtKppa+cxSMq9zwhbL2vj07FOrLzNBL834AaSaTUqZX3noleooms
  62808. lMuoaJuvimUnzYnu3Yy1aylwQ6BpC+S5DwIDAQABo0IwQDAdBgNVHQ4EFgQU/qHgcB4qAzlSWkK+
  62809. XJGFehiqTbUwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQAD
  62810. ggEBAMJKVvoVIXsoounlHfv4LcQ5lkFMOycsxGwYFYDGrK9HWS8mC+M2sO87/kOXSTKZEhVb3xEp
  62811. /6tT+LvBeA+snFOvV71ojD1pM/CjoCNjO2RnIkSt1XHLVip4kqNPEjE2NuLe/gDEo2APJ62gsIq1
  62812. NnpSob0n9CAnYuhNlCQT5AoE6TyrLshDCUrGYQTlSTR+08TI9Q/Aqum6VF7zYytPT1DU/rl7mYw9
  62813. wC68AivTxEDkigcxHpvOJpkT+xHqmiIMERnHXhuBUDDIlhJu58tBf5E7oke3VIAb3ADMmpDqw8NQ
  62814. BmIMMMAVSKeoWXzhriKi4gp6D/piq1JM4fHfyr6DDUI=
  62815. -----END CERTIFICATE-----
  62816. emSign ECC Root CA - C3
  62817. =======================
  62818. -----BEGIN CERTIFICATE-----
  62819. MIICKzCCAbGgAwIBAgIKe3G2gla4EnycqDAKBggqhkjOPQQDAzBaMQswCQYDVQQGEwJVUzETMBEG
  62820. A1UECxMKZW1TaWduIFBLSTEUMBIGA1UEChMLZU11ZGhyYSBJbmMxIDAeBgNVBAMTF2VtU2lnbiBF
  62821. Q0MgUm9vdCBDQSAtIEMzMB4XDTE4MDIxODE4MzAwMFoXDTQzMDIxODE4MzAwMFowWjELMAkGA1UE
  62822. BhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMSAwHgYDVQQD
  62823. ExdlbVNpZ24gRUNDIFJvb3QgQ0EgLSBDMzB2MBAGByqGSM49AgEGBSuBBAAiA2IABP2lYa57JhAd
  62824. 6bciMK4G9IGzsUJxlTm801Ljr6/58pc1kjZGDoeVjbk5Wum739D+yAdBPLtVb4OjavtisIGJAnB9
  62825. SMVK4+kiVCJNk7tCDK93nCOmfddhEc5lx/h//vXyqaNCMEAwHQYDVR0OBBYEFPtaSNCAIEDyqOkA
  62826. B2kZd6fmw/TPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MAoGCCqGSM49BAMDA2gA
  62827. MGUCMQC02C8Cif22TGK6Q04ThHK1rt0c3ta13FaPWEBaLd4gTCKDypOofu4SQMfWh0/434UCMBwU
  62828. ZOR8loMRnLDRWmFLpg9J0wD8ofzkpf9/rdcw0Md3f76BB1UwUCAU9Vc4CqgxUQ==
  62829. -----END CERTIFICATE-----
  62830. Hongkong Post Root CA 3
  62831. =======================
  62832. -----BEGIN CERTIFICATE-----
  62833. MIIFzzCCA7egAwIBAgIUCBZfikyl7ADJk0DfxMauI7gcWqQwDQYJKoZIhvcNAQELBQAwbzELMAkG
  62834. A1UEBhMCSEsxEjAQBgNVBAgTCUhvbmcgS29uZzESMBAGA1UEBxMJSG9uZyBLb25nMRYwFAYDVQQK
  62835. Ew1Ib25na29uZyBQb3N0MSAwHgYDVQQDExdIb25na29uZyBQb3N0IFJvb3QgQ0EgMzAeFw0xNzA2
  62836. MDMwMjI5NDZaFw00MjA2MDMwMjI5NDZaMG8xCzAJBgNVBAYTAkhLMRIwEAYDVQQIEwlIb25nIEtv
  62837. bmcxEjAQBgNVBAcTCUhvbmcgS29uZzEWMBQGA1UEChMNSG9uZ2tvbmcgUG9zdDEgMB4GA1UEAxMX
  62838. SG9uZ2tvbmcgUG9zdCBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCz
  62839. iNfqzg8gTr7m1gNt7ln8wlffKWihgw4+aMdoWJwcYEuJQwy51BWy7sFOdem1p+/l6TWZ5Mwc50tf
  62840. jTMwIDNT2aa71T4Tjukfh0mtUC1Qyhi+AViiE3CWu4mIVoBc+L0sPOFMV4i707mV78vH9toxdCim
  62841. 5lSJ9UExyuUmGs2C4HDaOym71QP1mbpV9WTRYA6ziUm4ii8F0oRFKHyPaFASePwLtVPLwpgchKOe
  62842. sL4jpNrcyCse2m5FHomY2vkALgbpDDtw1VAliJnLzXNg99X/NWfFobxeq81KuEXryGgeDQ0URhLj
  62843. 0mRiikKYvLTGCAj4/ahMZJx2Ab0vqWwzD9g/KLg8aQFChn5pwckGyuV6RmXpwtZQQS4/t+TtbNe/
  62844. JgERohYpSms0BpDsE9K2+2p20jzt8NYt3eEV7KObLyzJPivkaTv/ciWxNoZbx39ri1UbSsUgYT2u
  62845. y1DhCDq+sI9jQVMwCFk8mB13umOResoQUGC/8Ne8lYePl8X+l2oBlKN8W4UdKjk60FSh0Tlxnf0h
  62846. +bV78OLgAo9uliQlLKAeLKjEiafv7ZkGL7YKTE/bosw3Gq9HhS2KX8Q0NEwA/RiTZxPRN+ZItIsG
  62847. xVd7GYYKecsAyVKvQv83j+GjHno9UKtjBucVtT+2RTeUN7F+8kjDf8V1/peNRY8apxpyKBpADwID
  62848. AQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAfBgNVHSMEGDAWgBQXnc0e
  62849. i9Y5K3DTXNSguB+wAPzFYTAdBgNVHQ4EFgQUF53NHovWOStw01zUoLgfsAD8xWEwDQYJKoZIhvcN
  62850. AQELBQADggIBAFbVe27mIgHSQpsY1Q7XZiNc4/6gx5LS6ZStS6LG7BJ8dNVI0lkUmcDrudHr9Egw
  62851. W62nV3OZqdPlt9EuWSRY3GguLmLYauRwCy0gUCCkMpXRAJi70/33MvJJrsZ64Ee+bs7Lo3I6LWld
  62852. y8joRTnU+kLBEUx3XZL7av9YROXrgZ6voJmtvqkBZss4HTzfQx/0TW60uhdG/H39h4F5ag0zD/ov
  62853. +BS5gLNdTaqX4fnkGMX41TiMJjz98iji7lpJiCzfeT2OnpA8vUFKOt1b9pq0zj8lMH8yfaIDlNDc
  62854. eqFS3m6TjRgm/VWsvY+b0s+v54Ysyx8Jb6NvqYTUc79NoXQbTiNg8swOqn+knEwlqLJmOzj/2ZQw
  62855. 9nKEvmhVEA/GcywWaZMH/rFF7buiVWqw2rVKAiUnhde3t4ZEFolsgCs+l6mc1X5VTMbeRRAc6uk7
  62856. nwNT7u56AQIWeNTowr5GdogTPyK7SBIdUgC0An4hGh6cJfTzPV4e0hz5sy229zdcxsshTrD3mUcY
  62857. hcErulWuBurQB7Lcq9CClnXO0lD+mefPL5/ndtFhKvshuzHQqp9HpLIiyhY6UFfEW0NnxWViA0kB
  62858. 60PZ2Pierc+xYw5F9KBaLJstxabArahH9CdMOA0uG0k7UvToiIMrVCjU8jVStDKDYmlkDJGcn5fq
  62859. dBb9HxEGmpv0
  62860. -----END CERTIFICATE-----
  62861. Entrust Root Certification Authority - G4
  62862. =========================================
  62863. -----BEGIN CERTIFICATE-----
  62864. MIIGSzCCBDOgAwIBAgIRANm1Q3+vqTkPAAAAAFVlrVgwDQYJKoZIhvcNAQELBQAwgb4xCzAJBgNV
  62865. BAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3Qu
  62866. bmV0L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxNSBFbnRydXN0LCBJbmMuIC0gZm9yIGF1
  62867. dGhvcml6ZWQgdXNlIG9ubHkxMjAwBgNVBAMTKUVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1
  62868. dGhvcml0eSAtIEc0MB4XDTE1MDUyNzExMTExNloXDTM3MTIyNzExNDExNlowgb4xCzAJBgNVBAYT
  62869. AlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0
  62870. L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxNSBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhv
  62871. cml6ZWQgdXNlIG9ubHkxMjAwBgNVBAMTKUVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhv
  62872. cml0eSAtIEc0MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAsewsQu7i0TD/pZJH4i3D
  62873. umSXbcr3DbVZwbPLqGgZ2K+EbTBwXX7zLtJTmeH+H17ZSK9dE43b/2MzTdMAArzE+NEGCJR5WIoV
  62874. 3imz/f3ET+iq4qA7ec2/a0My3dl0ELn39GjUu9CH1apLiipvKgS1sqbHoHrmSKvS0VnM1n4j5pds
  62875. 8ELl3FFLFUHtSUrJ3hCX1nbB76W1NhSXNdh4IjVS70O92yfbYVaCNNzLiGAMC1rlLAHGVK/XqsEQ
  62876. e9IFWrhAnoanw5CGAlZSCXqc0ieCU0plUmr1POeo8pyvi73TDtTUXm6Hnmo9RR3RXRv06QqsYJn7
  62877. ibT/mCzPfB3pAqoEmh643IhuJbNsZvc8kPNXwbMv9W3y+8qh+CmdRouzavbmZwe+LGcKKh9asj5X
  62878. xNMhIWNlUpEbsZmOeX7m640A2Vqq6nPopIICR5b+W45UYaPrL0swsIsjdXJ8ITzI9vF01Bx7owVV
  62879. 7rtNOzK+mndmnqxpkCIHH2E6lr7lmk/MBTwoWdPBDFSoWWG9yHJM6Nyfh3+9nEg2XpWjDrk4JFX8
  62880. dWbrAuMINClKxuMrLzOg2qOGpRKX/YAr2hRC45K9PvJdXmd0LhyIRyk0X+IyqJwlN4y6mACXi0mW
  62881. Hv0liqzc2thddG5msP9E36EYxr5ILzeUePiVSj9/E15dWf10hkNjc0kCAwEAAaNCMEAwDwYDVR0T
  62882. AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJ84xFYjwznooHFs6FRM5Og6sb9n
  62883. MA0GCSqGSIb3DQEBCwUAA4ICAQAS5UKme4sPDORGpbZgQIeMJX6tuGguW8ZAdjwD+MlZ9POrYs4Q
  62884. jbRaZIxowLByQzTSGwv2LFPSypBLhmb8qoMi9IsabyZIrHZ3CL/FmFz0Jomee8O5ZDIBf9PD3Vht
  62885. 7LGrhFV0d4QEJ1JrhkzO3bll/9bGXp+aEJlLdWr+aumXIOTkdnrG0CSqkM0gkLpHZPt/B7NTeLUK
  62886. YvJzQ85BK4FqLoUWlFPUa19yIqtRLULVAJyZv967lDtX/Zr1hstWO1uIAeV8KEsD+UmDfLJ/fOPt
  62887. jqF/YFOOVZ1QNBIPt5d7bIdKROf1beyAN/BYGW5KaHbwH5Lk6rWS02FREAutp9lfx1/cH6NcjKF+
  62888. m7ee01ZvZl4HliDtC3T7Zk6LERXpgUl+b7DUUH8i119lAg2m9IUe2K4GS0qn0jFmwvjO5QimpAKW
  62889. RGhXxNUzzxkvFMSUHHuk2fCfDrGA4tGeEWSpiBE6doLlYsKA2KSD7ZPvfC+QsDJMlhVoSFLUmQjA
  62890. JOgc47OlIQ6SwJAfzyBfyjs4x7dtOvPmRLgOMWuIjnDrnBdSqEGULoe256YSxXXfW8AKbnuk5F6G
  62891. +TaU33fD6Q3AOfF5u0aOq0NZJ7cguyPpVkAh7DE9ZapD8j3fcEThuk0mEDuYn/PIjhs4ViFqUZPT
  62892. kcpG2om3PVODLAgfi49T3f+sHw==
  62893. -----END CERTIFICATE-----
  62894. Microsoft ECC Root Certificate Authority 2017
  62895. =============================================
  62896. -----BEGIN CERTIFICATE-----
  62897. MIICWTCCAd+gAwIBAgIQZvI9r4fei7FK6gxXMQHC7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV
  62898. UzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQgRUND
  62899. IFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwHhcNMTkxMjE4MjMwNjQ1WhcNNDIwNzE4
  62900. MjMxNjA0WjBlMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYw
  62901. NAYDVQQDEy1NaWNyb3NvZnQgRUNDIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwdjAQ
  62902. BgcqhkjOPQIBBgUrgQQAIgNiAATUvD0CQnVBEyPNgASGAlEvaqiBYgtlzPbKnR5vSmZRogPZnZH6
  62903. thaxjG7efM3beaYvzrvOcS/lpaso7GMEZpn4+vKTEAXhgShC48Zo9OYbhGBKia/teQ87zvH2RPUB
  62904. eMCjVDBSMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTIy5lycFIM
  62905. +Oa+sgRXKSrPQhDtNTAQBgkrBgEEAYI3FQEEAwIBADAKBggqhkjOPQQDAwNoADBlAjBY8k3qDPlf
  62906. Xu5gKcs68tvWMoQZP3zVL8KxzJOuULsJMsbG7X7JNpQS5GiFBqIb0C8CMQCZ6Ra0DvpWSNSkMBaR
  62907. eNtUjGUBiudQZsIxtzm6uBoiB078a1QWIP8rtedMDE2mT3M=
  62908. -----END CERTIFICATE-----
  62909. Microsoft RSA Root Certificate Authority 2017
  62910. =============================================
  62911. -----BEGIN CERTIFICATE-----
  62912. MIIFqDCCA5CgAwIBAgIQHtOXCV/YtLNHcB6qvn9FszANBgkqhkiG9w0BAQwFADBlMQswCQYDVQQG
  62913. EwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQg
  62914. UlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwHhcNMTkxMjE4MjI1MTIyWhcNNDIw
  62915. NzE4MjMwMDIzWjBlMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9u
  62916. MTYwNAYDVQQDEy1NaWNyb3NvZnQgUlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcw
  62917. ggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKW76UM4wplZEWCpW9R2LBifOZNt9GkMml
  62918. 7Xhqb0eRaPgnZ1AzHaGm++DlQ6OEAlcBXZxIQIJTELy/xztokLaCLeX0ZdDMbRnMlfl7rEqUrQ7e
  62919. S0MdhweSE5CAg2Q1OQT85elss7YfUJQ4ZVBcF0a5toW1HLUX6NZFndiyJrDKxHBKrmCk3bPZ7Pw7
  62920. 1VdyvD/IybLeS2v4I2wDwAW9lcfNcztmgGTjGqwu+UcF8ga2m3P1eDNbx6H7JyqhtJqRjJHTOoI+
  62921. dkC0zVJhUXAoP8XFWvLJjEm7FFtNyP9nTUwSlq31/niol4fX/V4ggNyhSyL71Imtus5Hl0dVe49F
  62922. yGcohJUcaDDv70ngNXtk55iwlNpNhTs+VcQor1fznhPbRiefHqJeRIOkpcrVE7NLP8TjwuaGYaRS
  62923. MLl6IE9vDzhTyzMMEyuP1pq9KsgtsRx9S1HKR9FIJ3Jdh+vVReZIZZ2vUpC6W6IYZVcSn2i51BVr
  62924. lMRpIpj0M+Dt+VGOQVDJNE92kKz8OMHY4Xu54+OU4UZpyw4KUGsTuqwPN1q3ErWQgR5WrlcihtnJ
  62925. 0tHXUeOrO8ZV/R4O03QK0dqq6mm4lyiPSMQH+FJDOvTKVTUssKZqwJz58oHhEmrARdlns87/I6KJ
  62926. ClTUFLkqqNfs+avNJVgyeY+QW5g5xAgGwax/Dj0ApQIDAQABo1QwUjAOBgNVHQ8BAf8EBAMCAYYw
  62927. DwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUCctZf4aycI8awznjwNnpv7tNsiMwEAYJKwYBBAGC
  62928. NxUBBAMCAQAwDQYJKoZIhvcNAQEMBQADggIBAKyvPl3CEZaJjqPnktaXFbgToqZCLgLNFgVZJ8og
  62929. 6Lq46BrsTaiXVq5lQ7GPAJtSzVXNUzltYkyLDVt8LkS/gxCP81OCgMNPOsduET/m4xaRhPtthH80
  62930. dK2Jp86519efhGSSvpWhrQlTM93uCupKUY5vVau6tZRGrox/2KJQJWVggEbbMwSubLWYdFQl3JPk
  62931. +ONVFT24bcMKpBLBaYVu32TxU5nhSnUgnZUP5NbcA/FZGOhHibJXWpS2qdgXKxdJ5XbLwVaZOjex
  62932. /2kskZGT4d9Mozd2TaGf+G0eHdP67Pv0RR0Tbc/3WeUiJ3IrhvNXuzDtJE3cfVa7o7P4NHmJweDy
  62933. AmH3pvwPuxwXC65B2Xy9J6P9LjrRk5Sxcx0ki69bIImtt2dmefU6xqaWM/5TkshGsRGRxpl/j8nW
  62934. ZjEgQRCHLQzWwa80mMpkg/sTV9HB8Dx6jKXB/ZUhoHHBk2dxEuqPiAppGWSZI1b7rCoucL5mxAyE
  62935. 7+WL85MB+GqQk2dLsmijtWKP6T+MejteD+eMuMZ87zf9dOLITzNy4ZQ5bb0Sr74MTnB8G2+NszKT
  62936. c0QWbej09+CVgI+WXTik9KveCjCHk9hNAHFiRSdLOkKEW39lt2c0Ui2cFmuqqNh7o0JMcccMyj6D
  62937. 5KbvtwEwXlGjefVwaaZBRA+GsCyRxj3qrg+E
  62938. -----END CERTIFICATE-----
  62939. e-Szigno Root CA 2017
  62940. =====================
  62941. -----BEGIN CERTIFICATE-----
  62942. MIICQDCCAeWgAwIBAgIMAVRI7yH9l1kN9QQKMAoGCCqGSM49BAMCMHExCzAJBgNVBAYTAkhVMREw
  62943. DwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UECgwNTWljcm9zZWMgTHRkLjEXMBUGA1UEYQwOVkFUSFUt
  62944. MjM1ODQ0OTcxHjAcBgNVBAMMFWUtU3ppZ25vIFJvb3QgQ0EgMjAxNzAeFw0xNzA4MjIxMjA3MDZa
  62945. Fw00MjA4MjIxMjA3MDZaMHExCzAJBgNVBAYTAkhVMREwDwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UE
  62946. CgwNTWljcm9zZWMgTHRkLjEXMBUGA1UEYQwOVkFUSFUtMjM1ODQ0OTcxHjAcBgNVBAMMFWUtU3pp
  62947. Z25vIFJvb3QgQ0EgMjAxNzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABJbcPYrYsHtvxie+RJCx
  62948. s1YVe45DJH0ahFnuY2iyxl6H0BVIHqiQrb1TotreOpCmYF9oMrWGQd+HWyx7xf58etqjYzBhMA8G
  62949. A1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBSHERUI0arBeAyxr87GyZDv
  62950. vzAEwDAfBgNVHSMEGDAWgBSHERUI0arBeAyxr87GyZDvvzAEwDAKBggqhkjOPQQDAgNJADBGAiEA
  62951. tVfd14pVCzbhhkT61NlojbjcI4qKDdQvfepz7L9NbKgCIQDLpbQS+ue16M9+k/zzNY9vTlp8tLxO
  62952. svxyqltZ+efcMQ==
  62953. -----END CERTIFICATE-----
  62954. certSIGN Root CA G2
  62955. ===================
  62956. -----BEGIN CERTIFICATE-----
  62957. MIIFRzCCAy+gAwIBAgIJEQA0tk7GNi02MA0GCSqGSIb3DQEBCwUAMEExCzAJBgNVBAYTAlJPMRQw
  62958. EgYDVQQKEwtDRVJUU0lHTiBTQTEcMBoGA1UECxMTY2VydFNJR04gUk9PVCBDQSBHMjAeFw0xNzAy
  62959. MDYwOTI3MzVaFw00MjAyMDYwOTI3MzVaMEExCzAJBgNVBAYTAlJPMRQwEgYDVQQKEwtDRVJUU0lH
  62960. TiBTQTEcMBoGA1UECxMTY2VydFNJR04gUk9PVCBDQSBHMjCCAiIwDQYJKoZIhvcNAQEBBQADggIP
  62961. ADCCAgoCggIBAMDFdRmRfUR0dIf+DjuW3NgBFszuY5HnC2/OOwppGnzC46+CjobXXo9X69MhWf05
  62962. N0IwvlDqtg+piNguLWkh59E3GE59kdUWX2tbAMI5Qw02hVK5U2UPHULlj88F0+7cDBrZuIt4Imfk
  62963. abBoxTzkbFpG583H+u/E7Eu9aqSs/cwoUe+StCmrqzWaTOTECMYmzPhpn+Sc8CnTXPnGFiWeI8Mg
  62964. wT0PPzhAsP6CRDiqWhqKa2NYOLQV07YRaXseVO6MGiKscpc/I1mbySKEwQdPzH/iV8oScLumZfNp
  62965. dWO9lfsbl83kqK/20U6o2YpxJM02PbyWxPFsqa7lzw1uKA2wDrXKUXt4FMMgL3/7FFXhEZn91Qqh
  62966. ngLjYl/rNUssuHLoPj1PrCy7Lobio3aP5ZMqz6WryFyNSwb/EkaseMsUBzXgqd+L6a8VTxaJW732
  62967. jcZZroiFDsGJ6x9nxUWO/203Nit4ZoORUSs9/1F3dmKh7Gc+PoGD4FapUB8fepmrY7+EF3fxDTvf
  62968. 95xhszWYijqy7DwaNz9+j5LP2RIUZNoQAhVB/0/E6xyjyfqZ90bp4RjZsbgyLcsUDFDYg2WD7rlc
  62969. z8sFWkz6GZdr1l0T08JcVLwyc6B49fFtHsufpaafItzRUZ6CeWRgKRM+o/1Pcmqr4tTluCRVLERL
  62970. iohEnMqE0yo7AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1Ud
  62971. DgQWBBSCIS1mxteg4BXrzkwJd8RgnlRuAzANBgkqhkiG9w0BAQsFAAOCAgEAYN4auOfyYILVAzOB
  62972. ywaK8SJJ6ejqkX/GM15oGQOGO0MBzwdw5AgeZYWR5hEit/UCI46uuR59H35s5r0l1ZUa8gWmr4UC
  62973. b6741jH/JclKyMeKqdmfS0mbEVeZkkMR3rYzpMzXjWR91M08KCy0mpbqTfXERMQlqiCA2ClV9+BB
  62974. /AYm/7k29UMUA2Z44RGx2iBfRgB4ACGlHgAoYXhvqAEBj500mv/0OJD7uNGzcgbJceaBxXntC6Z5
  62975. 8hMLnPddDnskk7RI24Zf3lCGeOdA5jGokHZwYa+cNywRtYK3qq4kNFtyDGkNzVmf9nGvnAvRCjj5
  62976. BiKDUyUM/FHE5r7iOZULJK2v0ZXkltd0ZGtxTgI8qoXzIKNDOXZbbFD+mpwUHmUUihW9o4JFWklW
  62977. atKcsWMy5WHgUyIOpwpJ6st+H6jiYoD2EEVSmAYY3qXNL3+q1Ok+CHLsIwMCPKaq2LxndD0UF/tU
  62978. Sxfj03k9bWtJySgOLnRQvwzZRjoQhsmnP+mg7H/rpXdYaXHmgwo38oZJar55CJD2AhZkPuXaTH4M
  62979. NMn5X7azKFGnpyuqSfqNZSlO42sTp5SjLVFteAxEy9/eCG/Oo2Sr05WE1LlSVHJ7liXMvGnjSG4N
  62980. 0MedJ5qq+BOS3R7fY581qRY27Iy4g/Q9iY/NtBde17MXQRBdJ3NghVdJIgc=
  62981. -----END CERTIFICATE-----
  62982. <?php
  62983. if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
  62984. echo 'Warning: Composer should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
  62985. }
  62986. setlocale(LC_ALL, 'C');
  62987. require __DIR__.'/../src/bootstrap.php';
  62988. use Composer\Console\Application;
  62989. use Composer\XdebugHandler\XdebugHandler;
  62990. error_reporting(-1);
  62991. // Restart without Xdebug
  62992. $xdebug = new XdebugHandler('Composer', '--ansi');
  62993. $xdebug->check();
  62994. unset($xdebug);
  62995. if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '4.0', '>=')) {
  62996. echo 'HHVM 4.0 has dropped support for Composer, please use PHP instead. Aborting.'.PHP_EOL;
  62997. exit(1);
  62998. }
  62999. if (function_exists('ini_set')) {
  63000. @ini_set('display_errors', 1);
  63001. // Set user defined memory limit
  63002. if ($memoryLimit = getenv('COMPOSER_MEMORY_LIMIT')) {
  63003. @ini_set('memory_limit', $memoryLimit);
  63004. } else {
  63005. $memoryInBytes = function ($value) {
  63006. $unit = strtolower(substr($value, -1, 1));
  63007. $value = (int) $value;
  63008. switch($unit) {
  63009. case 'g':
  63010. $value *= 1024;
  63011. // no break (cumulative multiplier)
  63012. case 'm':
  63013. $value *= 1024;
  63014. // no break (cumulative multiplier)
  63015. case 'k':
  63016. $value *= 1024;
  63017. }
  63018. return $value;
  63019. };
  63020. $memoryLimit = trim(ini_get('memory_limit'));
  63021. // Increase memory_limit if it is lower than 1.5GB
  63022. if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1536) {
  63023. @ini_set('memory_limit', '1536M');
  63024. }
  63025. unset($memoryInBytes);
  63026. }
  63027. unset($memoryLimit);
  63028. }
  63029. putenv('COMPOSER_BINARY='.realpath($_SERVER['argv'][0]));
  63030. // run the command application
  63031. $application = new Application();
  63032. $application->run();
  63033. Copyright (c) Nils Adermann, Jordi Boggiano
  63034. Permission is hereby granted, free of charge, to any person obtaining a copy
  63035. of this software and associated documentation files (the "Software"), to deal
  63036. in the Software without restriction, including without limitation the rights
  63037. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  63038. copies of the Software, and to permit persons to whom the Software is furnished
  63039. to do so, subject to the following conditions:
  63040. The above copyright notice and this permission notice shall be included in all
  63041. copies or substantial portions of the Software.
  63042. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  63043. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  63044. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  63045. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  63046. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  63047. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  63048. THE SOFTWARE.
  63049. :©õ‚]ˆ=Dim³�'(ðæ….¡���GBMB